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 choose a model that supports the Responses API on your upstream channel.

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?
Chat Completions support alone does not establish Codex compatibility. Codex requires the Responses API; verify the model and upstream channel before selecting a non-OpenAI model.
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.
Guides and comparisons
TutorialCodex CLI Installation Guide: Setup OpenAI's AI Coding Agent in Minutes
Complete guide to installing and configuring OpenAI Codex CLI, the AI-powered terminal coding agent. Step-by-step setup for macOS, Linux, and Windows with troubleshooting tips.
GuideAI Coding Tools ROI Calculator: Claude Code vs Codex CLI vs Gemini CLI Cost Analysis 2026
A comprehensive ROI framework for evaluating AI coding tools in 2026. Compare Claude Code, Codex CLI, and Gemini CLI on cost per task, productivity gains, and total cost of ownersh
Tutorial"Codex CLI Installation Guide 2026: Install, Configure, and Route Coding Tasks"
"A practical Codex CLI installation guide covering prerequisites, authentication, project setup, safe permissions, troubleshooting, and API-compatible model routing."
Podcast
AI Dev Tools: The Crazyrouter Podcast
Short episodes for developers on AI APIs, gateways, cost control and coding tools.
Latest episodes
EP196 · Oct 29, 2026 · 6:53
AI API Security Posture — Turn Controls Into Continuous Evidence
A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.
EP195 · Oct 28, 2026 · 7:21
AI API Policy Drift — Detect When Production Rules Stop Matching Intent
A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.