Connect Codex in ChatGPT Desktop to LiteLLM with SSO
Codex in ChatGPT Desktop reads the same ~/.codex/config.toml as the Codex CLI and runs the same authentication helper. For app onboarding, model selection, and MCP configuration, see the desktop setup guide.
These settings configure the Codex side of the app. Regular ChatGPT chats are not configured by ~/.codex/config.toml and do not go through LiteLLM.
Configure SSO authentication
In place of a long-lived virtual key, Codex can ask the lite CLI for a token whenever it needs one. Each developer runs lite login --pkce once, and requests are then attributed to their LiteLLM user and team
Replace env_key with an auth table in ~/.codex/config.toml:
model_provider = "litellm"
[model_providers.litellm]
name = "LiteLLM"
base_url = "https://litellm.example.com/v1"
wire_api = "responses"
[model_providers.litellm.auth]
command = "/absolute/path/to/lite"
args = ["--base-url", "https://litellm.example.com", "auth", "print-token"]
timeout_ms = 30000
refresh_interval_ms = 300000
Replace /absolute/path/to/lite with the absolute path returned by which lite. The --base-url value must exactly match the URL used for lite login --pkce; a token issued for http://127.0.0.1:4000 is not returned for http://localhost:4000. lite auth print-token writes only the token to stdout and renews it with the refresh token stored by PKCE login. After lite logout, Codex receives 401 responses until you run lite login --pkce again
Codex rejects a provider that sets both auth and env_key with provider auth cannot be combined with env_key, so remove env_key when adding auth. This is OpenAI's command-backed gateway auth, verified with Codex CLI 0.160.0
Desktop apps may not inherit variables exported in your terminal. Use the absolute path to lite shown above. With the auth command in place of env_key, you can skip the LITELLM_API_KEY entry in ~/.codex/.env for the model provider. The desktop MCP setup still uses its own bearer token environment variable.
Restart the app after changing the configuration.
Next steps
See the desktop setup guide for app configuration and the Codex CLI setup guide for model discovery and service tiers.