ChatGPT Subscription
Use ChatGPT Pro/Max subscription models through LiteLLM with OAuth device flow authentication.
| Property | Details |
|---|---|
| Description | ChatGPT subscription access (Codex + GPT-5.2 family) via ChatGPT backend API |
| Provider Route on LiteLLM | chatgpt/ |
| Supported Endpoints | /responses, /chat/completions (bridged to Responses for supported models) |
| API Reference | https://chatgpt.com |
ChatGPT subscription access is native to the Responses API. Chat Completions requests are bridged to Responses for supported models (for example chatgpt/gpt-5.2).
Notes:
- The ChatGPT subscription backend rejects token limit fields (
max_tokens,max_output_tokens,max_completion_tokens) andmetadata. LiteLLM strips these fields for this provider. /v1/chat/completionshonorsstream. Whenstreamis false (default), LiteLLM aggregates the Responses stream into a single JSON response.
Authentication​
ChatGPT subscription access uses an OAuth device code flow:
- LiteLLM prints a device code and verification URL
- Open the URL, sign in, and enter the code
- Tokens are stored locally for reuse
Usage - LiteLLM Python SDK​
Responses (recommended for Codex models)​
ChatGPT Responses
import litellm
response = litellm.responses(
model="chatgpt/gpt-5.2-codex",
input="Write a Python hello world"
)
print(response)
Chat Completions (bridged to Responses)​
ChatGPT Chat Completions
import litellm
response = litellm.completion(
model="chatgpt/gpt-5.2",
messages=[{"role": "user", "content": "Write a Python hello world"}]
)
print(response)
Usage - LiteLLM Proxy​
config.yaml
model_list:
- model_name: chatgpt/gpt-5.2
model_info:
mode: responses
litellm_params:
model: chatgpt/gpt-5.2
- model_name: chatgpt/gpt-5.2-codex
model_info:
mode: responses
litellm_params:
model: chatgpt/gpt-5.2-codex
Start LiteLLM Proxy
litellm --config config.yaml
Configuration​
Environment Variables​
CHATGPT_TOKEN_DIR: Custom token storage directoryCHATGPT_AUTH_FILE: Auth file name (default:auth.json)CHATGPT_API_BASE: Override API base (default:https://chatgpt.com/backend-api/codex)OPENAI_CHATGPT_API_BASE: Alias forCHATGPT_API_BASECHATGPT_ORIGINATOR: Override theoriginatorheader valueCHATGPT_USER_AGENT: Override theUser-Agentheader valueCHATGPT_USER_AGENT_SUFFIX: Optional suffix appended to theUser-Agentheader