In this categoryChatGPT · 25
- How to Build Your First Custom GPTStart
- How to Upload Knowledge Files to a Custom GPT
- How to Connect a Custom GPT to an API with Actions
- How to Create a Custom GPT for a Repeated Task
- How to Publish and Share a Custom GPT
- How to Fix a Custom GPT That Ignores Its Instructions
- How to Build a Custom GPT with Clear Instructions
- How to Write a Professional Email With ChatGPT
- How to Debug a Code Error With ChatGPT
- How to Build an Excel or Google Sheets Formula With ChatGPT
- How to Write a Python Automation Script With ChatGPT
- How to Turn Meeting Notes Into Action Items With ChatGPT
- How to Translate and Localize Text With ChatGPT
- How to Prepare for a Job Interview With ChatGPT
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
17:53
1:05:30
30:00
18:40
21:10
135:00New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.