Why route Codex
Codex is built on the OpenAI Responses API. That is the expensive part of a heavy coding day, and it assumes an OpenAI account and a card many builders outside the US do not have.
Because Codex reads its provider and key from config, you can route it through a compatible gateway. Cradler Router aggregates supply and passes the same Responses API straight through, so the agent behaves identically — you change only where the request goes and what it costs.
Connecting Codex to Cradler Router, step by step
One provider block in your Codex config — that is the integration.
- 01
Create a Cradler account and get a Router key
Sign up at cradler.ai, open the Router section, top up by card, and create an API key. The same account also runs your Cradler database and file storage.
- 02
Add Cradler Router as a Codex model provider
Fastest: run npx @cradler/router-setup with your key — it writes the provider block and verifies the key for you. Or define it manually in ~/.codex/config.toml with wire_api set to "responses".
- 03
Point your key at it
Set the environment variable your provider block references to your Router key, then run Codex. No other change to your workflow is needed.
- 04
Build — with the agent loop intact
Codex's Responses-API agent loop, shell commands, and file edits all pass through. Optionally add a fast mode for higher throughput on the models that support it.
The configuration
Add a provider block to ~/.codex/config.toml and point Codex at it:
# ~/.codex/config.toml
model = "gpt-5.5"
model_provider = "cradler"
[model_providers.cradler]
name = "Cradler Router"
base_url = "https://router.cradler.ai/v1"
wire_api = "responses"
env_key = "CRADLER_ROUTER_KEY"Then set your key and run Codex:
export CRADLER_ROUTER_KEY="<your-router-key>"
# Run Codex as usual
codex
# …or pin a model for a run
codex --model gpt-5.6-solFast mode, when you want it
For latency-sensitive work, request a fast tier on supported GPT models. It trades cost for speed — roughly 2x the price for up to about 2.5x the throughput — and is entirely optional.
# OpenAI SDK against Cradler Router
from openai import OpenAI
client = OpenAI(
api_key="<your-router-key>",
base_url="https://router.cradler.ai/v1",
)
resp = client.responses.create(
model="gpt-5.6-sol",
input="Refactor this module for readability",
service_tier="fast", # higher throughput, ~2x price
)
print(resp.output_text)Gotchas worth knowing
Use the Responses API for GPT. Codex expects wire_api = "responses". The Responses endpoint serves the GPT series; send it a non-GPT model and it will reject the request.
Read the model list, don't guess it. Available model IDs are whatever /v1/models returns for your key. A name from an old doc may 404 — check the live list first.
Keep your Router key out of your repo. It is a billable credential — environment variable or secrets manager, never a committed file. Rotate it if it is ever exposed.
One account, model access and a backend
Cradler Router is part of Cradler — the same account that gives your app a managed PostgreSQL database and file storage through a typed SDK, with no SQL and no migrations. The key that makes Codex cheaper is the key that stores what Codex helps you build. One signup, one bill.