ChatGPTAdvanced

How to Connect a Custom GPT to an API with Actions

Give a custom GPT a live API call by defining an Action from an OpenAPI schema and configuring authentication.

12 minAdvanced

Actions let a custom GPT call a real API, so it can fetch live data or trigger something in another system rather than only talking. You describe the API with an OpenAPI schema, paste it into the GPT, and the model decides when to call each endpoint. This guide wires up a read-only weather lookup as a concrete example.

What you need

  • A custom GPT you can edit
  • An API with a public HTTPS endpoint and, if needed, an API key
  • Basic comfort reading JSON or YAML (an OpenAPI schema)

Step 1: Open the Actions panel

In your GPT, go to Configure and scroll to the bottom. Click Create new action. You get a schema editor, an Authentication selector, and a list of available operations that fills in once your schema is valid.

Step 2: Paste an OpenAPI schema

The schema tells the GPT which endpoints exist, what parameters they take, and what they return. Keep it minimal at first: one path, clear descriptions. The descriptions matter because the model reads them to decide when and how to call the endpoint.

openapi.yaml
openapi: 3.1.0
info:
  title: Weather Lookup
  version: 1.0.0
servers:
  - url: https://api.example-weather.com
paths:
  /v1/current:
    get:
      operationId: getCurrentWeather
      summary: Get current weather for a city
      parameters:
        - name: city
          in: query
          required: true
          description: City name, e.g. "Lisbon"
          schema:
            type: string
      responses:
        "200":
          description: Current conditions
          content:
            application/json:
              schema:
                type: object
                properties:
                  tempC: { type: number }
                  summary: { type: string }
Configure — Add actions
Authentication: [ API Key v ]
Schema: openapi.yaml (valid)
Available actions
GET /v1/current getCurrentWeather
[ Test ]
A valid schema exposes the getCurrentWeather operation.

Step 3: Configure authentication

Click the Authentication gear. For a key-based API choose API Key, paste the key, and pick how it is sent (a custom header is common). For services that need user login, choose OAuth and supply the client ID, secret, and token URLs. Never paste a key into the schema text itself.

Auth types
None is fine for fully public endpoints. API Key sends a fixed credential you provide. OAuth lets each user authorize with their own account, which is what you want for anything that reads or writes private data.

Step 4: Test the action and add guidance

Hit Test next to the operation. The GPT will call the endpoint and show the raw request and response so you can confirm it works. Then add an instruction telling the model when to use the action, which makes its behavior predictable.

Action test output
Request
$GET https://api.example-weather.com/v1/current?city=Lisbon
Response 200
{ "tempC": 21.4, "summary": "Partly cloudy" }
$
Privacy disclosure
When a GPT calls an Action it sends data to a third-party server. ChatGPT shows users which domain the action contacts. Only connect endpoints you trust, and avoid sending sensitive content to them.

Result

Ask the GPT what is the weather in Lisbon and it now calls your API, reads the JSON, and answers with live data instead of a guess. The same pattern extends to any documented HTTPS endpoint.

Watch related tutorials

Tags
#custom-gpt#actions#api#openapi