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.
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: 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 }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.
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.
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
1:42:18
28:14
41:09
9:47
8:23
52:31