Skip to content
ChatGPT API
Documentation

Documentation

Authentication

Last updated:

The ChatGPT API authenticates with a Bearer API key, exactly like the official OpenAI API. The only change from an OpenAI setup is the base URL — reuse your existing key handling for everything else.

How do API keys work?

Generate a key in your dashboard and send it in the Authorization header as `Bearer YOUR_API_KEY`. Keep keys secret, never commit them to source control, and rotate a key from the dashboard if it is ever exposed.

Keep keys out of your code

As with the official API, store your key in an environment variable (for example `CHATGPT_API_KEY` in your shell profile) instead of hardcoding it. Pass it explicitly to the SDK, or let the SDK read it, and never ship a key to the browser.

Base URL

Point your SDK or HTTP client at our base URL instead of api.openai.com. Every other part of the request — paths, headers, body and streaming — stays identical.

Set your key and base URL
# Store your key as an environment variable
export CHATGPT_API_KEY="YOUR_API_KEY"

# Send it as a Bearer token, exactly like the official OpenAI API
Authorization: Bearer $CHATGPT_API_KEY

# Base URL — the only thing you change from an OpenAI setup
https://api.chatgpt-api.dev/v1