How To Add ChatGPT API (GPT 3.5 Turbo) into Google Sheets

On March 1st, 2023, OpenAI finally announced the eagerly-awaited API for ChatGPT. And the world took notice! Connecting ChatGPT to Google Sheets has never been easier!

I’ve been looking forward to this for a while because I wanted to connect ChatGPT to Google Sheets so I could quickly speed up a project I’ve been working on.

You might also like: How to connect GPT-4 to Google Sheets.

How to connect ChatGPT with Google Sheets using Google Apps Script

Here’s how you can integrate the ChatGPT API with Google Sheets using the gpt-3.5-turbo model.

Step 1: Get An API Key

You’ll need an API key from Open AI. When logged into your Open AI account, you create your API key here

Step 2: Enter Apps Scripts

From Google Sheets, click on Extensions in the main menu and select Apps Script.

Within the code editor of Apps Script, paste the following code and don’t forget to add your own unique API key where it says “YOUR API KEY” on the first line.

const SECRET_KEY = "YOUR API KEY";
const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;

function AI_ChatGPT(prompt, temperature = 0.4, model = "gpt-3.5-turbo") {
  const url = "https://api.openai.com/v1/chat/completions";
  const payload = {
    model: model,
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: prompt },
    ],
    temperature: TEMPERATURE,
    max_tokens: MAX_TOKENS,
  };
  const options = {
    contentType: "application/json",
    headers: { Authorization: "Bearer " + SECRET_KEY },
    payload: JSON.stringify(payload),
  };
  const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText());
  return res.choices[0].message.content.trim();
}

Once you’ve put your API key into the quotation marks on the first line, click the Save icon and go back into Google Sheets.

NOTE: You may have to give Google certain permissions. I allowed whatever they were looking for to get it working. I can't provide a tutorial on this because it's nuanced and requires a valid Google account etc. Also, Google often change how they do things, so updating this guide would soon become a nightmare for me. Hopefully this part goes easy for you.

Step 3: Complete in Google Sheets

Go back into Google Sheets.

Showing you exactly what you can do with prompts and spreadsheet layout is beyond the scope of this basic guide. I’m sure you’ll figure it out and have fun doing so.

But as a quick example, to show you that it really works, if you have a topic title in cell A1, you can place this formula below in any other cell and then let it do some magic!

=AI_ChatGPT("Create an introduction paragraph for this topic: "&A1&".")

Obviously, that’s just a basic example prompt to get the ChatGPT API working properly with Sheets.

Now, it’s up to you to tweak to your own needs.

Have fun adding the ChatGPT API (GPT 3.5 Turbo model) to Google Sheets!

And wow, this new ChatGPT API is much faster than my previous GPT3 integration.

With a little Google Sheet trickery, you can easily create an entire batch of AI-generated titles, meta descriptions, definitions, paragraphs of text, and if you’re that way inclined, even entire articles.

Honestly, that’s just the tip of the iceberg. When I get time, I’ll update this article with some great case study uses.

Now, let’s get real. Unless your prompts are ultra-amazing, you simply won’t get high-quality “publish-ready” blog posts out of ChatGPT.

Facts will still need to be checked because ChatGPT likes to invent stuff and will sound very convincing when spewing out fictional facts.

Although, some people are having great success ranking content out of the box, I really don’t think it’s a long-term strategy. It’ll work, until it doesn’t.

Anyway, whatever you decide to do with it is entirely up to you.

Frequently Asked Questions About ChatGPT

What is OpenAI’s announcement regarding ChatGPT and Whisper?

OpenAI has announced that third-party developers can integrate ChatGPT and Whisper into their apps and services via an API, which will be significantly cheaper than using its existing language models. Whisper is an AI-powered speech-to-text model, while ChatGPT is a chatbot model that can be used for various non-chat use cases.

What is the cost of using ChatGPT and Whisper through the API?

OpenAI is offering 1,000 tokens for $0.002, which is 10 times cheaper than its existing GPT-3.5 models. However, sending one snippet of text for the API to respond to could cost several tokens, and developers will need to consider how many tokens they need for their specific use cases.

What are the policy changes that OpenAI is introducing?

OpenAI will no longer use data submitted through the API to train its models unless customers explicitly allow such usage. This change addresses concerns about putting proprietary information into the bot. OpenAI is also working on improving uptime and ensuring stability for production use cases.

What are the benefits of using OpenAI’s API for ChatGPT and Whisper?

Developers can integrate AI-powered chatbot and speech-to-text capabilities into their products and services, which were previously out of reach for most developers. The API offers a cost-effective solution and allows for more control over the model being used.

Which companies are using ChatGPT for their products?

Snap’s My AI feature is one example of a product that uses ChatGPT. Other companies that have used it include Quizlet, which is using it for Q-Chat, a virtual tutor, and Instacart, which will soon roll out Ask Instacart to provide shoppable answers to customer queries about recipes and food purchases.

What is the Whisper model, and how can it be used?

The Whisper model is an AI-powered speech-to-text model that can transcribe or translate audio at a cost of $0.006 per minute. While the Whisper model is open source and can be run on one’s own hardware, using the API may be more efficient, especially for low-powered devices like phones.

What is OpenAI’s “gpt-3.5-turbo” model family?

OpenAI’s “gpt-3.5-turbo” model family is its new model family, which it claims is the best model for many non-chat use cases. It is not clear whether this model is the same one that Bing is using, which Microsoft has referred to as a “new, next-generation OpenAI large language model” that’s faster, more accurate, and more capable than ChatGPT and GPT-3.5.

Can I download ChatGPT?

No, ChatGPT is not available for download. It is an AI-powered model developed by OpenAI that can be accessed through its API.

What is the website for ChatGPT?

There is no official website for ChatGPT. It is a product of OpenAI, and information about it can be found on the OpenAI website here.

Is there an official ChatGPT app?

No, there is no official ChatGPT app. ChatGPT is a model that can be accessed through OpenAI’s API and integrated into apps and services.

Is there a desktop app for ChatGPT?

No, there is no desktop app for ChatGPT. It is a model that can be accessed through OpenAI’s API and integrated into apps and services.

Can I run ChatGPT on my computer?

No, ChatGPT cannot be run on your computer. It is an AI-powered model that can only be accessed through OpenAI’s API.

Is ChatGPT API Access free?

No, ChatGPT can be accessed through OpenAI’s API, and there is a cost associated with using the API. As of the latest announcement, the cost is $0.002 per 1,000 tokens.

Can you install ChatGPT locally?

No, ChatGPT cannot be installed locally. It is an AI-powered model that can only be accessed through OpenAI’s API.

How do I get the GPT chat app on my iPhone?

There is no official GPT chat app. However, you can access ChatGPT through apps and services that have integrated it into their systems.

What does GPT stand for?

GPT stands for “Generative Pre-trained Transformer.” It is a type of neural network architecture used in natural language processing, and ChatGPT is a specific model based on this architecture.

Similar Posts