Skip to content
ChatGPT API
Documentation

Documentation

Developer quickstart

Last updated:

Take your first steps with the ChatGPT API. It uses the official OpenAI Responses API format, so the official OpenAI SDKs work after you create a key and point them at our base URL.

Create and export an API key

Before you begin, create an API key in your dashboard, which you'll use to securely access the API. Store the key in a safe location, then export it as an environment variable in your terminal.

Export an environment variable on macOS or Linux
export CHATGPT_API_KEY="your_api_key_here"
Set an environment variable on Windows (PowerShell)
setx CHATGPT_API_KEY "your_api_key_here"

Official OpenAI SDKs read your API key from the environment automatically — with ChatGPT API you additionally set the base URL, as shown below.

Install the SDK and run an API call

Install an official OpenAI SDK, create a file with the example code, and set two things: your API key and our base URL. Everything else matches the official API.

Test a basic API request
1curl https://api.chatgpt-api.dev/v1/responses \2  -H "Content-Type: application/json" \3  -H "Authorization: Bearer $CHATGPT_API_KEY" \4  -d '{5    "model": "gpt-5.5",6    "input": "Write a one-sentence bedtime story about a unicorn."7  }'
Install the SDK
pip install openai
Test a basic API request
1from openai import OpenAI2 3client = OpenAI(4    api_key="YOUR_API_KEY",5    base_url="https://api.chatgpt-api.dev/v1",6)7 8response = client.responses.create(9    model="gpt-5.5",10    input="Write a one-sentence bedtime story about a unicorn.",11)12print(response.output_text)
Install the SDK
npm install openai
Test a basic API request
1import OpenAI from "openai";2 3const client = new OpenAI({4  apiKey: "YOUR_API_KEY",5  baseURL: "https://api.chatgpt-api.dev/v1",6});7 8const response = await client.responses.create({9  model: "gpt-5.5",10  input: "Write a one-sentence bedtime story about a unicorn.",11});12console.log(response.output_text);

Run the code (for example `node example.mjs` or `python example.py`). In a few moments you should see the model's reply printed from `response.output_text`.