* feat(cli): keep the ChatGPT login with lite codex --subscription `lite codex --subscription` points Codex at a `litellm_subscription` provider with requires_openai_auth on and no env_key, so Codex keeps its own ChatGPT login and the LiteLLM key is sent only in the x-litellm-api-key header from LITELLM_PROXY_API_KEY. OPENAI_API_KEY is left exactly as the user had it, and the pre-launch key check sends the key the same way `codex_subscription` is a new `lite config` key that turns the flag on by default, like `claude_subscription` does for `lite claude`. The Claude `--settings` overlay now applies to Claude Code only * fix(cli): leave the Codex Stop hook out of subscription launches and load tomli on Python 3.10 * fix(cli): leave OPENAI_BASE_URL as the user had it with lite codex --subscription * fix(cli): give lite codex --subscription its own Codex provider id * test(cli): type the Codex config override helpers * fix(cli): leave the Codex model list to Codex in subscription mode --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
4.9 KiB
Use your ChatGPT subscription through LiteLLM
Sign into ChatGPT in Codex or Pi and send model requests through your existing LiteLLM proxy. The client keeps your login and refreshes it. Each request uses that client's ChatGPT account, while a separate LiteLLM virtual key controls gateway access and usage attribution.
An administrator adds a chatgpt/ model using the usual model configuration. No ChatGPT login needs to be added to the proxy. This uses the same separate-key convention as provider passthrough, including Claude Code subscription forwarding.
Add a model to the proxy
Reuse your existing proxy. If you need one, follow the proxy quickstart. Merge this entry into its model list and restart the proxy:
model_list:
- model_name: gpt-6-luna
litellm_params:
model: chatgpt/gpt-6-luna
model_info:
mode: responses
Use a model available to the caller's subscription. The virtual key must allow the exposed model name. Leave saved ChatGPT logins and API credentials unset for a client-only deployment. Explicit cross-provider fallbacks can incur separate API charges; do not configure them for subscription-only traffic.
Configure Codex
Use your existing LiteLLM URL and a virtual key assigned to your gateway user. Export that key as LITELLM_API_KEY in the environment that launches Codex. Keep the value out of committed configuration.
Add this provider to ~/.codex/config.toml, preserving your other settings:
model = "gpt-6-luna"
model_provider = "litellm_subscription"
[model_providers.litellm_subscription]
name = "LiteLLM subscription"
base_url = "https://litellm.example.com/v1"
wire_api = "responses"
supports_websockets = false
requires_openai_auth = true
env_http_headers = { "x-litellm-api-key" = "LITELLM_API_KEY" }
Replace https://litellm.example.com with your proxy URL. A local proxy normally uses http://localhost:4000/v1. Launch Codex, sign into ChatGPT if needed, and send a prompt with a model available to your subscription. The selected model must match the name exposed by the gateway.
The lite CLI can set up this provider each time it starts Codex, with no config.toml edit. Export LITELLM_PROXY_URL and LITELLM_PROXY_API_KEY, then run lite codex --subscription. Run lite config set codex_subscription true to make it the default.
For a managed workspace rollout, use OpenAI's gateway configuration guide.
Native compatibility and Pi
For a native Codex model catalog and request format, change Codex's base_url to https://litellm.example.com/backend-api/codex. This route uses the same credentials but does not need a model deployment or resolve model aliases. Restricted keys must allow the upstream model name.
Configure Pi
Sign into the built-in openai-codex provider in Pi. Merge this override into ~/.pi/agent/models.json and export your LiteLLM virtual key as LITELLM_API_KEY before launching Pi:
{
"providers": {
"openai-codex": {
"baseUrl": "https://litellm.example.com/backend-api/codex",
"headers": {
"x-litellm-api-key": "LITELLM_API_KEY"
}
}
}
}
Keep Pi's subscription login as the provider credential. The header value names an environment variable, not a key to paste into the file.
Verify account usage
Send a prompt and check the completed request in LiteLLM's Logs page. Its gateway user/key and token counts should match the caller. Give each person their own LiteLLM virtual key for separate attribution. The gateway credential and ChatGPT login are independently authenticated; LiteLLM does not establish that both identities belong to the same person.
The native routes are GET /backend-api/codex/models and POST /backend-api/codex/responses. Model requests use the upstream model name, so a restricted LiteLLM key must allow that name. OpenAI's model catalog is returned in its native format; seeing a model there does not override gateway permissions.
The proxy forwards the ChatGPT bearer and account header to the fixed OpenAI Codex endpoint. It removes gateway credentials and cookies from the upstream request and redacts credential headers in logging callbacks. The client remains responsible for refresh and reauthentication. Native passthrough returns authentication and quota errors without switching subscriptions. Standard model routes retain the caller login across ChatGPT retries; explicitly configured cross-provider fallbacks use their own credentials. An explicit workspace header is preserved for OpenAI to validate.
This flow does not connect accounts through the dashboard or pool subscription allowances. Use a Codex build that supports ChatGPT authentication with a custom model provider. The integration forwards HTTP and SSE requests; it does not add native WebSocket or other Codex backend routes.