How to connect the ChatGPT API to Google Sheets

In this tutorial, we’ll show you how to connect the ChatGPT REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain your API key
  3. Choose the ChatGPT endpoint from OpenAI API
  4. Enter your ChatGPT API request into Apipheny
  5. Run the OpenAI – ChatGPT API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace:

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser:

Step 2.) Obtain an API key

In your OpenAI account, click the user icon, then go to the View API keys option:

OpenAI account
OpenAI account

In the API keys section, click the +Create new secret key button to generate an API key:

API Keys section
API Keys section

Your API key is now generated:

API key generated popup
API key generated popup

Copy it to a safe location because you’ll need it later. Click the OK button to return to the API keys section, where your key will be listed.

Step 3.) Choose the ChatGPT endpoint from OpenAI API

In this section, we’ll show you how to browse the OpenAI API documentation to find the ChatGPT endpoint that retrieves the information you need. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the OpenAI API documentation page:

The menu on the left contains general information about the OpenAI API and a list of categories for the OpenAI API endpoints:

OpenAI documentation page
OpenAI documentation page

If you scroll down to the API Reference section, you’ll find the endpoints’ categories.

An example endpoint is Create chat completion under Chat category, which creates a model response for the given chat conversation. The URL for this endpoint is:

Each endpoint’s documentation contains a descriptive title, a paragraph describing the endpoint’s purpose, the request body parameters if it’s a POST. In a distinct section on the right, you will see the endpoint’s HTTP method (GET) and URL, as well as an example request and response:

Create chat completion endpoint documentation

All API calls to OpenAI should be made to the base domain. All endpoints should be appended to this base URL.

Step 4.) Enter your OpenAI API request into Apipheny

Now, to get your OpenAI data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened on the Import tab. In the Import tab of Apipheny, enter the following details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET, POST, PUT, PATCH or DELETE) required by your OpenAI API endpoint. For this example, we are using the “POST” method.

API URL: In Step 4, we explained how you can find the OpenAI API endpoint that you need. Now copy your complete OpenAI API URL into the Apipheny add-on, in the field that says API URL Path, followed by any POST parameters required for your query (if applicable).

For this example, we are using the above Create chat completion endpoint, that creates a model response for the given chat conversation. The URL for this specific endpoint is:

If you’re following the same example as us, just copy and paste the above URL into Apipheny.

Headers: In the Headers section of the Apipheny add-on, add one row with the following key and value:



Bearer your_key

Make sure to replace your_key with the same value of the token that you’ve generated previously, in Step 2. Leave a literal space between “Bearer” and your key in the Header Value field.

Body: In the Body section of Apipheny, add the ID of the model to use and the messages (a list of messages describing the conversation so far) :

	"model": "gpt-3.5-turbo",
	"messages": [{
		"role": "user",
		"content": "Hello!"

Here’s what your ChatGPT API request should look like when entered into Apipheny, if you’re following the same example as us:

ChatGPT API request entered in the Apipheny add-on
ChatGPT API request entered in the Apipheny add-on

Step 5.) Run the OpenAI API – ChatGPT Request in Your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your OpenAI – ChatGPT endpoint data will be imported into your Google Sheets. Congratulations!

ChatGPT data imported into Google Sheets using the Apipheny add-on
ChatGPT data imported into Google Sheets using the Apipheny add-on

Popular API Tutorials

API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?

Import JSON to Google Sheets

SEO by SearchCyrus