October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Configure a Custom Model Provider in Codex CLI

Codex CLI can use a custom model provider when the endpoint supports the Responses API behavior it expects. Here’s the user-level config block and the compatibility checks to make first.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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 model to 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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.