Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Codex CLI can use a custom model provider when its endpoint supports the Responses API behavior Codex expects. Add the provider and model selection to your user-level ~/.codex/config.toml, then supply the endpoint’s API key through an environment variable. This is a configuration pattern—not a guarantee that every model or router will work.
Set up a custom provider in one config block
Use this as a starting shape, not as a tested configuration for a particular gateway. Replace the model ID with one the endpoint actually offers and your account can use, and replace the base URL with the endpoint’s API base.
As an Amazon Associate I earn from qualifying purchases.
model = "<model-id>"
model_provider = "router"
[model_providers.router]
name = "Router"
base_url = "https://<provider-api-base>/v1"
env_key = "ROUTER_API_KEY"
wire_api = "responses"
Set ROUTER_API_KEY in the shell environment or secret manager used to launch Codex. Avoid putting credentials in a config file that might be committed to a repository.
Where the configuration belongs
Put provider settings in the user-level ~/.codex/config.toml. Codex ignores model_provider and model_providers when they appear in a project-local .codex/config.toml. Project configuration is also loaded only for trusted projects.
#1 Best Overall
Codex resolves configuration from highest to lowest precedence in this order: command-line flags and --config overrides, trusted project configuration, the selected profile, user configuration, cloud-managed defaults, system configuration, and built-in defaults. If your chosen provider does not take effect, check for an override earlier in that order. See the Codex configuration guide and configuration reference.
What “any model” means in practice
The word “any” needs a compatibility condition: the model or gateway must expose the Responses API behavior Codex expects. The current Codex provider reference lists responses as the only supported wire_api value, alongside provider fields such as name, base_url, env_key, requires_openai_auth, and supports_websockets. A server that merely describes itself as OpenAI-compatible is not thereby confirmed to work with this setup.
OpenAI’s documentation for external-model evaluations discusses custom endpoints compatible with Chat Completions and names OpenRouter as a partner for third-party model evaluations. That is a separate feature; it does not certify that OpenRouter, or any other Chat Completions endpoint, works with Codex CLI’s Responses-only provider configuration. Check the endpoint’s documentation for Responses API support and for the specific model IDs and behaviors it provides.
Recommended Free Tools
Keep authentication and model selection endpoint-specific
- Credential: Put the API key in the environment variable named by
env_key, or use an appropriate secret manager. - Model ID: Set
modelto the exact identifier served by the endpoint and available to your account. - Protocol: Verify that the endpoint supports the Responses API behavior Codex requires; the config block alone cannot make an incompatible API work.
The Codex app-server guide includes an example using a Responses provider with a ChatGPT-plan OAuth access token for app-server integration. That example does not establish that a gateway can use the same authentication flow, or that OAuth is the general setup for Codex CLI. See the app-server guide for that distinct integration context.
Rank #3
What this block does—and does not—establish
The documented fields show how Codex selects a custom provider and endpoint. They do not establish that every router or model is compatible, or that a particular third-party endpoint has been tested. Confirm protocol support, authentication requirements, available model IDs, and endpoint terms with the provider before relying on it.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




