Connect custom GPT to the internet (Google X ChatGPT)
Tags: chatgpt, ai, showdev
Published: 2023-12-05 08:23:35

OpenAI announced a new mindblowing feature on the DevDay (Nov 2023). It's the **custom GPT**. With it, you can create your custom-tailored chat GPT. The most exciting part is you can feed your custom GPT with a PDF or even connect it to the internet!

*   Read more about [custom GPT here](https://openai.com/blog/introducing-gpts).

_In this blog post, we'll learn how to connect custom chatGPT with Google (a.k.a. internet!)_

![Connect custom GPT to the internet (Google)](https://serpapi.com/blog/content/images/2023/12/connect-custom-ChatGPT-and-Google-internet-1.webp)

What are we going to build?
---------------------------

We'll create an SEO tool that analyzes Google Search results page (Google SERP) and give us advice accordingly. By default, custom GPT can browse the web with Bing Search but not with Google. We can extend its capabilities by [using an external API with Actions](https://platform.openai.com/docs/actions).

**Flow of our custom GPT:**  
\- A user will give a keyword to analyze.  
\- We'll get information from Google SERP using external API in Actions.  
\- Chat GPT will give advice based on this accurate live data.

_Note: The sky is the limit of what we can do with the ability of custom GPT to connect to external API._

*   Since we need access to Google, we will use a simple API from SerpApi. SerpApi has APIs to connect to various search engines, including Google. Therefore, register at [serpapi.com](https://serpapi.com/) and get your API key for free.
*   Register and subscribe to [chat GPT Plus](https://chat.openai.com/).
*   Feel free to read the basics of [how to create a custom GPT? Feel free to follow our step-by-step tutorial here](https://serpapi.com/blog/create-a-custom-chat-gpt-openai/).

Documentation link: [Google Search API](https://serpapi.com/search-api) .

Step-by-step tutorial to connect custom GPT to the internet
-----------------------------------------------------------

Make sure you have already subscribed to Chat GPT to follow along.

**Step 1: Create a new custom GPT**

From your chat.openai.com dashboard, Click on the "explore" button.

![Click explore button](https://serpapi.com/blog/content/images/2023/11/step-1-click-explore-button.png)

Click the "Create a GPT" button.

![Click to create custom GPT](https://serpapi.com/blog/content/images/2023/11/step-2-click-create-custom-GPT.png)

**Step 2: Fill in the basic information**

It will redirect you to the "GPT Builder" section. You need to provide this data:  
\- What it does (in short sentences)  
\- GPT's name (It will give you a suggestion)  
\- A profile picture (It will auto-generate for you as well)

![connect custom GPT to internet initial setup](https://serpapi.com/blog/content/images/2023/12/custom-GPT-with-internet-builder.webp)

**Step 3: Give specific instruction**  
Next, tell the builder about the details of what it will do in the background. Here is mine for this "SEO tool sample":

```
- It will analyze Google Serp for the user. 
- User will provide a keyword
- It analyze Google SERP (Via actions - external API)
- It returns with advices to suggest user what to cover on their page
```


Follow up instruction

```
- It take top 5 results from Google SERP
- It analyze what the user-intent based on that top ranking results
- It analyze the people-also-ask-for or related-search
- Return a complete advice based on that (not general SEO advise)
```

![Give specific instructions to custom GPT](https://serpapi.com/blog/content/images/2023/12/connect-ChatGPT-to-Google-instructions.webp)

**Step 4: Define user interaction**  
Explain how the user (or you) will interact with this tool. Here is mine:

```
if user type this: "keyword: $input" - then $input is the keyword user want to cover.
```


![How custom GPT will interact with the user](https://serpapi.com/blog/content/images/2023/12/how-to-interact-with-user.webp)

**Step 5: (Optional) Choose capabilities**  
Since we will only use an external API, I'll uncheck all capabilities in the "configure tab". To make sure it only relies on SerpApi.

![Uncheck capabilities at GPT Builder](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.22.58.png)

**Step 6: Create the OpenAPI schema**  
We'll need an [OpenAPI schema](https://swagger.io/specification/) for our actions. Therefore, we need to create the structure of our schema first.

You can learn and build it yourself, or if you're lazy like me, ask chatGPT to build it for you. I'm copy-pasting the sample curl request from the API documentation.

![Ask ChatGPT to create openAPI schema](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.27.07.png)

The returned result is imperfect, but it is enough for the base structure. In my case, I need to add the "servers" block and "operationId." Here is my complete schema:

```
{
  "openapi": "3.0.0",
  "info": {
    "title": "SerpApi Search Service",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://serpapi.com"
    }
  ],
  "paths": {
    "/search": {
      "get": {
        "summary": "Perform a search using SerpApi",
        "operationId": "seachGoogle",
        "parameters": [
          {
            "name": "api_key",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["YOUR_REAL_SERPAPI_API_KEY"]
            }
          },
          {
            "in": "query",
            "name": "engine",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The search engine to use, e.g., 'google'."
          },
          {
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The query string for the search."
          },
          {
            "in": "query",
            "name": "location",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The geographical location for the search."
          },
          {
            "in": "query",
            "name": "google_domain",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The specific Google domain to use for the search."
          },
          {
            "in": "query",
            "name": "gl",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The country to use for the search."
          },
          {
            "in": "query",
            "name": "hl",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The language setting for the search."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad request"
          }
        }
      }
    }
  }
}

```


Feel free to add or remove parameters based on your needs. **The code above is my "final schema." Feel free to copy and paste it.**

Just for your information, I needed to change the `api_key` structure from this.

```
 {
            "in": "query",
            "name": "api_key",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The API key for authentication."
},
```


to store the api\_key value in the enum array like this:

```
{
  "name": "api_key",
  "in": "query",
  "required": true,
  "schema": {
    "type": "string",
    "enum": ["YOUR_REAL_SERPAPI_API_KEY"]
  }
}
```


Otherwise, the chatGPT won't be able to validate your API key.

**Step 7: Use it in action configuration**  
To add the schema, click on the "create new action" in the configure tab

![Create actions in custom GPT](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.32.08.png)

Now, add the schema inside the textbox

![Adding OpenAPI schema in the actions tab](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.39.45.png)

**Step 8: Test the GPT SEO tool**

You can click on the "test button" below.

![Test custom GPT](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.40.43.png)

The GPT will test and run the results for us. You'll receive an error message if anything is wrong.

![results preview](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.41.59.png)

It will also run a search with a sample keyword for us. It shows us the top 5 results with a link to the content to ensure the GPT is not hallucinating.

![compare top-ranking results from Google vs custom GPT](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.46.13.png)

**Step 9: Test with a user input**

We've determined that the user can put the keyword like this:

![Custom GPT usage example](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.52.24.png)

Besides the accurate top-ranking results, our custom GPT reflects the actual "people also search" content from the Google Live results page.

![People also ask for results.](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.55.01.png)

It returns concrete SEO tips after giving us information from the top-ranking results.

![SEO recommendation](https://serpapi.com/blog/content/images/2023/12/CleanShot-2023-12-05-at-13.54.13.png)

Optional Extended feature
-------------------------

**More specific action**  
You can adjust our GPT by interacting in the chat box or from the configure tab. For example, you can ask the GPT to return 5 article ideas for you instead of only returning SEO tips.

**Scraping individual page**

You can add multiple APIs from different resources at customGPT. You can add tools like [Webpilot AI](https://www.webpilot.ai/) to scrape the individual top-ranking pages. To analyze the header, structure, and more.

FAQ  

------

**Is ChatGPT connected to the internet?**

With the recent update, ChatGPT can use Bing search results to get information from the internet.

**How much does custom GPT by OpenAI cost?**  
It costs $20/month since you must subscribe to ChatGPT Plus to use it.