Run Codex CLI through Crazyrouter
Codex CLI supports custom providers in config.toml. The installer adds a Crazyrouter provider, keeps the Responses wire API, and lets you pick any GPT-5, Codex or non-OpenAI model as the default.
One-command setup
The recommended path is the current config.toml provider setup, not the older environment-only style. --switch reconfigures an existing install in seconds; --full also installs Node.js and Codex on a clean machine.
- 1Run the command
Pulls the script from GitHub; nothing else is downloaded.
- 2Paste your Crazyrouter key
Pick a default model when asked; you can change it later.
- 3Tool talks to Crazyrouter
Config or env vars are written; the next launch routes through your key.
curl -fsSL https://raw.githubusercontent.com/xujfcn/crazyrouter-codex-cli/main/install-crazyrouter-codex.sh | bash -s -- --switch
$env:CRAZYROUTER_CODEX_MODE='switch'; iwr -UseB https://raw.githubusercontent.com/xujfcn/crazyrouter-codex-cli/main/install-crazyrouter-codex.ps1 | iex
What the script does
- --switch: Codex is already installed; only the provider config changes
- --full: fresh machine — installs Node.js 22 and @openai/codex first
- Asks for your key and default model, writes OPENAI_API_KEY and OPENAI_BASE_URL
- Adds a [model_providers.crazyrouter] block to ~/.codex/config.toml and sets it as model_provider
Scripts are fetched from the public GitHub repo linked below. Read them before piping to a shell if that's your policy; the download-then-run form is in the README.
Manual configuration
~/.codex/config.toml
model = "gpt-5.6-sol" model_provider = "crazyrouter" [model_providers.crazyrouter] name = "Crazyrouter" base_url = "https://api.crazyrouter.com/v1" env_key = "OPENAI_API_KEY" wire_api = "responses"
wire_api = "responses" keeps Codex on the Responses API, which Crazyrouter relays natively for GPT-5 / Codex models.
Environment variable
export OPENAI_API_KEY=sk-your-crazyrouter-key # Windows: setx OPENAI_API_KEY "sk-your-crazyrouter-key"
https://api.crazyrouter.com/v1 — This tool is OpenAI-compatible and appends /chat/completions (or /responses) itself. Use the /v1 base URL exactly as shown.
Recommended models
Live Crazyrouter prices, refreshed hourly. Any model in the catalogue works; these are the ones we'd start with.
FAQ
Which wire API should I use?
responses. GPT-5 and Codex models are relayed on the Responses API with reasoning items preserved across turns.
Can I use Claude or DeepSeek from Codex?
Yes. Any chat model in the Crazyrouter catalogue can be set as model; the provider block does not change.
Do I still need ChatGPT login?
No. With a custom provider and OPENAI_API_KEY set, Codex never uses the ChatGPT auth flow.
The script says my key is invalid
Make sure the token's model allowlist includes the model you chose and that OPENAI_BASE_URL has no UTM parameters or trailing path beyond /v1.
