Setting up a Codex CLI custom provider used to be a five-line config.toml edit: point base_url at any OpenAI-compatible gateway and start coding. On current Codex releases that recipe no longer works. Codex now talks to providers only through the OpenAI Responses API, and the public AtmoRouter gateway does not implement /v1/responses.
This post is AtmoRouter-authored. It shows the path that works today, a local bridge shipped with the AtmoRouter setup helper, spells out what that bridge does not support, and runs the token math on what a Codex session bills. It is a setup guide with illustrative numbers, not an independent benchmark of how well any model performs inside Codex.
Why the old config.toml recipe fails
Codex reads providers from [model_providers.<id>] in your user-level ~/.codex/config.toml. Three fields matter here:
base_urlis the API root. Codex appends/responsesto it.env_keyis the name of an environment variable holding your key, not the key itself.wire_apiselects the protocol."responses"is the only value current builds accept and it is also the default;"chat"is rejected when the config loads.
That last point is what breaks older tutorials. For a long time wire_api = "chat" let Codex use plain Chat Completions, which is exactly what AtmoRouter's https://atmorouter.dev/v1 endpoint serves. Paste one of those guides today and you get a config error before any request leaves your machine. If you "fix" it by switching to "responses", the request reaches AtmoRouter and returns a 404, because the gateway has no /v1/responses route. Neither outcome means your key or balance is wrong.
Provider definitions also belong in the user-level file. Codex ignores model_provider and model_providers placed in a project-local .codex/config.toml, so a gateway block checked into a repo does nothing for whoever clones it.
What you need before starting
- Codex CLI installed and runnable (
codex --version). - Node.js 22 or newer, to run the helper.
- An AtmoRouter API key exported as
ATMOROUTER_API_KEY. AtmoRouter is prepaid, so the key needs balance behind it. - A model ID copied exactly from the catalogue, family prefix included (
cx/gpt-6.2-sol, notgpt-6.2-sol).
To confirm the key is live before opening Codex, the helper has a check that sends an empty request, so it never runs inference:
bashnpx @atmorouter/[email protected] check-keyA valid active key is rejected locally with HTTP 400 "model is required"; an invalid key returns 401. A 429 is inconclusive rather than a bad key, so wait and try again.
Set up Codex CLI through the helper bridge
Since the gateway has no Responses route, the helper ships an optional bridge: a small server on localhost that accepts the Responses calls Codex makes and translates a limited subset into Chat Completions against AtmoRouter. Three commands cover the whole flow:
bash# 1. Preview the Codex setup (writes nothing, starts nothing)
npx @atmorouter/[email protected] configure --target codex --model cx/gpt-6.2-sol
# 2. Launch Codex through a temporary localhost bridge
npx @atmorouter/[email protected] codex --model cx/gpt-6.2-sol
# 3. Or run a standalone bridge on a fixed port
npx @atmorouter/[email protected] bridge --port 43187The first command previews the setup instructions for your setup without touching your config or starting a server, so run it first. The second is the launcher you will use day to day: it starts a temporary localhost bridge and hands Codex the settings for that one run, preserving Codex's permission defaults, so the agent still asks before editing files or running commands as it does with any provider. The third runs a standalone bridge on a fixed port; use it for a server you want to keep running, and follow what it prints.
Calls through the bridge are billed normally to your AtmoRouter key.
What the bridge does not support
The bridge is deliberately narrow, and it is worth knowing the edges before you rely on it for real work:
- It handles stateless text, function tools, and streaming. That covers normal read-edit-run coding loops.
- Unsupported built-in tools and stateful Responses features are rejected rather than silently degraded.
- Hosted web search is disabled for the run.
- Reasoning summaries and encrypted reasoning output are unavailable.
- Complete Responses compatibility, images, and audio are not promised.
If your workflow depends on any of those, use Codex with a provider that serves the Responses API natively, and route your other agents (Cline, Continue, Roo Code, Zed, Goose) through AtmoRouter's Chat Completions or Anthropic-compatible endpoints instead.
What a Codex session costs
Every model below is a catalogue ID from AtmoRouter's public list at writing time, priced "from" because a model can have several tiers. Rates change; the model page is authoritative.
| Model | From (input / output, USD per million tokens) | Context | |---|---|---| | cx/gpt-6.2-sol | $0.10 / $0.50 | 628k | | cx/gpt-6.1-terra | $0.0375 / $0.1875 | 628k | | cc/claude-sonnet-5-5 | $0.135 / $0.675 | 1M | | alicn/deepseek-v4.1-flash | $0.0375 / $0.15 | 1M |
Cached input is billed at 10% of the input rate where the model supports it, and that dominates the bill in an agent loop, since the same system prompt, tool schemas, and file contents are resent on every turn.
Illustrative math, not a measurement: say each Codex turn sends 15,000 input tokens, 12,000 of which hit the cache, and receives 600 output tokens. A thousand turns is then 15M input (12M cached, 3M uncached) plus 600k output:
cx/gpt-6.2-sol: 3 × $0.10 + 12 × $0.01 + 0.6 × $0.50 = $0.72cx/gpt-6.1-terra: 3 × $0.0375 + 12 × $0.00375 + 0.6 × $0.1875 = $0.27cc/claude-sonnet-5-5: 3 × $0.135 + 12 × $0.0135 + 0.6 × $0.675 = $0.97alicn/deepseek-v4.1-flash: 3 × $0.0375 + 12 × $0.00375 + 0.6 × $0.15 = $0.25
Your numbers will differ with repository size, how often the cache misses, and how much the model writes per turn. Requests the gateway rejects before forwarding (for example a 402 for insufficient balance) are not charged; a per-request minimum charge can make very small calls cost more than the per-token rate suggests. Before pointing an agent at a key, set a price budget on that key in the Budgets dashboard. Budgets cap the per-token rates a request can be served at, not total spend, so keep an eye on your balance and usage log during long sessions.
FAQ
I set wire_api = "chat" and Codex refuses to start. What now?
That is expected on current builds. Use the helper bridge as shown above; there is no Chat Completions switch left to flip.
Does the bridge write to my ~/.codex/config.toml?
The preview (configure --target codex) writes nothing. The launcher uses a temporary bridge for the run it starts. If you run the standalone bridge, follow the instructions it prints.
Is Codex through the bridge as capable as Codex on a native Responses provider?
No. Hosted web search, reasoning summaries, and some built-in tools are off. For plain read-edit-run coding the function-tool path is what matters.
Next step
Export ATMOROUTER_API_KEY, run the configure --target codex preview, then the codex launcher with the model you want. Check live rates on the model page before a long session, and if you'd rather skip the bridge entirely, the Cline setup guide and Roo Code setup guide use the Chat Completions endpoint directly.