Codex
Route OpenAI's Codex CLI through BitRouter by registering it as a custom model provider.
Codex CLI can run through BitRouter without taking over your Codex config. The quickest path is bitrouter launch --agent codex, which injects one-shot Codex config overrides for that child process only; if you prefer a permanent setup, register BitRouter as a custom provider in ~/.codex/config.toml.
Prerequisites
-
BitRouter running — local proxy at
http://127.0.0.1:4356, or BitRouter Cloud athttps://api.bitrouter.ai. -
Codex installed:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Launch through BitRouter
bitrouter launch --agent codexEverything after -- is forwarded to Codex:
bitrouter launch --agent codex -- --model openai/gpt-5-codexBefore launching a long run, ask BitRouter to check the route it will use:
bitrouter launch --agent codex --check -- --model openai/gpt-5-codexThe check verifies that codex is installed, the BitRouter base URL is reachable, and the forwarded model has at least one Responses-compatible endpoint. It does not require the provider to be openai-codex; any model source that routes over the Responses protocol can be used by the Codex harness.
spawn does not edit ~/.codex/config.toml. It starts from your existing Codex model selection, then points Codex at a transient bitrouter provider with base_url = "<BitRouter>/v1" and wire_api = "responses". If BITROUTER_API_KEY is exported, Codex uses it through env_key; otherwise BitRouter injects a local placeholder that works with the skip_auth: true default written by bitrouter init.
Permanent config
Add a provider block to ~/.codex/config.toml. The base_url includes /v1 — Codex appends the route (/responses) itself.
model_provider = "bitrouter"
[model_providers.bitrouter]
name = "BitRouter"
base_url = "http://127.0.0.1:4356/v1"
wire_api = "responses"
# env_key = "BITROUTER_API_KEY" # Cloud or authenticated local daemoncodexPick a model
The Codex model setting, or a per-run codex --model <id>, can use any registry id in provider/model form — openai/gpt-5-codex, anthropic/claude-sonnet-4-6, google/gemini-2.5-pro — optionally with a :cost or :latency variant. See Models.
Verify
Run codex and issue a prompt; check BitRouter's request finished log line (~/.bitrouter/bitrouter.log for a local install) to see which provider and model answered.
Learn more
How is this guide?