ChatGPT Subscription
Use a ChatGPT subscription that includes Codex (see OpenAI's Codex pricing for the plans, from Plus and Pro to Business and Enterprise) through LiteLLM with OAuth device flow authentication.
LiteLLM can also use Claude and GitHub Copilot subscriptions. To compare the three subscriptions, refer to Claude, Codex, and Copilot subscriptions.
| Property | Details |
|---|---|
| Description | ChatGPT subscription access via the 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-6.1-sol).
Use a model that your ChatGPT plan and workspace can call. OpenAI's Codex models page lists the current and retired models. That list differs from the models the OpenAI API serves.
The examples use gpt-6.1-sol and gpt-6-luna. Check the models page for which plans can call them. As of October 2026, OpenAI rolls out GPT-6.1 Sol (gpt-6.1-sol) to Plus, Pro, Business, Enterprise, and Edu plans, and on Enterprise and Edu an admin has to enable GPT-6.1 Sol and GPT-6 Luna (gpt-6-luna) first. Free and Go plans do not get GPT-6.1 Sol at launch, and OpenAI tells them to choose GPT-6 Luna in the ChatGPT desktop app when available, so LiteLLM may not be able to call either model on those plans. A model the backend does not serve to your account, such as a retired one, fails with The '<model>' model is not supported when using Codex with a ChatGPT account.
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.- Send Responses
inputas a list of messages, as the examples below do. On LiteLLM 1.106.0, a plain stringinputfails with{"detail":"Input must be a list"}from both the SDK and the proxy.
Authentication
ChatGPT subscription access uses an OAuth device code flow. The LiteLLM Python SDK runs it the first time it needs a token, provided it is called from a synchronous script on the main thread: it prints a verification URL and a device code, you open the URL, sign in, and enter the code, and the tokens are stored in ~/.config/litellm/chatgpt/auth.json for reuse. Async code, notebooks, worker threads, and the LiteLLM proxy cannot answer that prompt (older releases block on it, newer ones fail with ChatGPT device-code login needs a human), so for the proxy you sign in first and mount the resulting file, as described in Sign in before starting the proxy.
Device code login has to be allowed for the account first: in ChatGPT's security settings for a personal plan, or by a workspace admin in the workspace permissions for Business and Enterprise (OpenAI docs).
Usage - LiteLLM Python SDK
On LiteLLM 1.106.0, the chatgpt/ provider needs the mcp package, which a plain pip install litellm does not include. Install LiteLLM with the mcp extra:
pip install 'litellm[mcp]'
Responses (recommended for Codex models)
import litellm
response = litellm.responses(
model="chatgpt/gpt-6.1-sol",
input=[{"role": "user", "content": "Write a Python hello world"}]
)
print(response)
Chat Completions (bridged to Responses)
import litellm
response = litellm.completion(
model="chatgpt/gpt-6.1-sol",
messages=[{"role": "user", "content": "Write a Python hello world"}]
)
print(response)
Usage - LiteLLM Proxy
Install LiteLLM with the proxy extra, which also includes the mcp package:
pip install 'litellm[proxy]'
Sign in before starting the proxy
The proxy cannot complete the device code flow: it runs in worker processes with no terminal to hand the code to. With no auth.json on disk, older releases print the code from a worker and hold startup on each chatgpt/ deployment while they wait for someone to enter it (from a foreground terminal you can, once per worker, with startup held meanwhile; from a service or container log nobody can), and newer releases refuse to initialize the deployment, logging ChatGPT device-code login needs a human and cannot run inside a running event loop or a worker thread once per deployment in every worker. Either way, every request to those models then returns HTTP 400 There are no healthy deployments for this model. Sign in once from a terminal instead:
python -c "from litellm.llms.chatgpt.authenticator import Authenticator; Authenticator().get_access_token()"
Open the printed URL, sign in, and enter the code. The login stores tokens in ~/.config/litellm/chatgpt/auth.json. Use CHATGPT_TOKEN_DIR and CHATGPT_AUTH_FILE to change the location. If you abandon a login attempt, a second run waits until the five-minute window ends before it prints a new code.
Copy the file to the same path on the proxy host, or set CHATGPT_TOKEN_DIR to its directory. Give the proxy's effective UID write access to the file so it can refresh tokens. Create the file before starting the proxy. The proxy creates model_list deployments at startup, so restart it if you add the file later.
The access token lasts about ten days. When it expires, the proxy trades the refresh token for a new pair and writes it back into auth.json, and each refresh token works only once, so the file must be writable: a read-only copy logs Failed to write ChatGPT auth file and stops working at the first refresh. For the same reason every proxy process has to share one copy of the file. The proxy re-reads it on every request, so whichever worker or pod refreshes first serves the rest, while separate copies diverge at the first refresh and all but one of them stop working until you sign in again. Two workers that hit the expiry at the same moment both try the same refresh token, and the loser logs ChatGPT refresh token failed, re-login required: newer releases fail that one request and pick up the new pair on the next one, older releases block that worker in the device-code poll for up to fifteen minutes first.
On Kubernetes, mount a PersistentVolumeClaim at CHATGPT_TOKEN_DIR. Give every replica access to the same writable token file. Use an init container to copy the file from a Secret when the volume is empty.
For replicas on multiple nodes, use ReadWriteMany with a storage class that supports it, such as Filestore on GKE, EFS on EKS, or Azure Files on AKS. Default disk classes only support ReadWriteOnce. They leave a ReadWriteMany claim Pending and its pods in ContainerCreating. With ReadWriteOnce, run one replica or place all replicas on one node so they can share the volume.
Do not use a Secret volume as the token file because it is read-only. A per-pod emptyDir also loses refreshed tokens when the pod restarts. The proxy overwrites the file in place. If another replica reads during a write, it logs Invalid ChatGPT auth file. At startup, this error removes the deployment until you restart the replica. During a request, the next request reads the file again.
The example uses UID 65532, the default in the shared image source. Match file ownership to your image and any runAsUser override. Under a restricted pod security policy, use a writable fsGroup. Run the init container with the proxy's effective UID and group, and omit the root-only chown. Check that your storage driver applies those volume permissions.
After a new login, update the Secret and delete auth.json from the volume with kubectl exec <pod> -c litellm -- rm /tokens/chatgpt/auth.json. Then restart the pods. The init container only copies into an empty volume. If the old file remains, the proxy logs ChatGPT refresh token failed, re-login required.
kubectl create secret generic litellm-chatgpt-auth --from-file=auth.json=$HOME/.config/litellm/chatgpt/auth.json
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: litellm-chatgpt-tokens
spec:
accessModes: ["ReadWriteMany"]
resources:
requests:
storage: 1Mi
spec:
initContainers:
- name: chatgpt-token
image: busybox:1.37
command:
- sh
- -c
- "test -f /tokens/chatgpt/auth.json || cp /secrets/chatgpt/auth.json /tokens/chatgpt/auth.json && chown 65532 /tokens/chatgpt/auth.json"
volumeMounts:
- name: chatgpt-secret
mountPath: /secrets/chatgpt
readOnly: true
- name: chatgpt-tokens
mountPath: /tokens/chatgpt
containers:
- name: litellm
env:
- name: CHATGPT_TOKEN_DIR
value: /tokens/chatgpt
volumeMounts:
- name: chatgpt-tokens
mountPath: /tokens/chatgpt
volumes:
- name: chatgpt-secret
secret:
secretName: litellm-chatgpt-auth
- name: chatgpt-tokens
persistentVolumeClaim:
claimName: litellm-chatgpt-tokens
Configure and start the proxy
model_list:
- model_name: chatgpt/gpt-6.1-sol
model_info:
mode: responses
litellm_params:
model: chatgpt/gpt-6.1-sol
- model_name: chatgpt/gpt-6-luna
model_info:
mode: responses
litellm_params:
model: chatgpt/gpt-6-luna
export LITELLM_MASTER_KEY="sk-$(openssl rand -hex 32)"
printf 'Local proxy key: %s\n' "$LITELLM_MASTER_KEY"
litellm --config config.yaml
In another terminal, set LITELLM_API_KEY to the key printed above, then call the proxy:
curl http://localhost:4000/v1/responses \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "chatgpt/gpt-6.1-sol", "input": [{"role": "user", "content": "Write a Python hello world"}]}'
Credential Scope and Attribution
A proxy uses exactly one ChatGPT login: the auth.json in CHATGPT_TOKEN_DIR, which is set once for the whole process. Every request to a chatgpt/ model goes upstream with that file's access token and the ChatGPT-Account-Id taken from it, whatever virtual key made the call, and LiteLLM ignores any ChatGPT token a client sends. Every key, user, and team that can call a chatgpt/ model therefore uses the same ChatGPT account and workspace, and users cannot bring their own ChatGPT subscription through this provider. Serving several ChatGPT accounts takes one proxy deployment per account.
LiteLLM attributes chatgpt/ requests to the calling virtual key, user, and team like any other model and records their token counts. The models have no price in the cost map, so recorded spend is $0 and max_budget limits never trigger; cap usage with rpm_limit or tpm_limit on keys and teams instead. On the OpenAI side, all of the usage shows up under the account that signed in.
Refresh Failures and Revocation
LiteLLM refreshes only when the stored access token is expired. A 401 from the ChatGPT backend for a token that has not expired yet, for example after the session was signed out on OpenAI's side, is returned to the caller and does not trigger a refresh. When the refresh token is rejected, the proxy logs ChatGPT refresh token failed, re-login required and requests fail with HTTP 400 ChatGPT device-code login needs a human; sign in again outside the proxy and replace auth.json.
LiteLLM has no logout or revoke call for this provider. To stop the proxy using the account, delete auth.json (and the Secret it was seeded from on Kubernetes) and restart the proxy. To invalidate the tokens themselves, sign the session out from the ChatGPT account's security settings.
Configuration
Environment Variables
CHATGPT_TOKEN_DIR: Custom token storage directory (default:~/.config/litellm/chatgpt)CHATGPT_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