Codex CLI
Set up a Responses provider and a shell-scoped API key for Codex CLI.
Install and prepare
- Install Node.js, then install the official Codex CLI with the command below. Run
codex --versionin a new terminal. - Create a key on routerra.ai → API Keys. Choose an exact model ID from Models with Responses API and tool-call support; a Chat Completions-only model cannot run this configuration.
npm install -g @openai/codex
codex --version
Define the TOML provider
- Edit
~/.codex/config.toml(Windows:%USERPROFILE%\.codex\config.toml). Merge the TOML below without duplicating an existing provider table.model_providermust matchrouterra;env_keynames an environment variable, not the secret itself. ReplaceYOUR_MODEL_ID. - Export
ROUTERRA_API_KEYin the same shell that launchescodex. These commands last only for that shell; persist the variable in your shell profile if needed. This custom provider uses its own key rather than a ChatGPT login. Restart Codex after editing TOML.
model = "YOUR_MODEL_ID"
model_provider = "routerra"
[model_providers.routerra]
name = "routerra.ai"
base_url = "https://routerra.ai/v1"
env_key = "ROUTERRA_API_KEY"
wire_api = "responses"
Launch with the provider key
A missing-variable error means Codex did not inherit ROUTERRA_API_KEY; launch it from that terminal. A /responses 404 means the URL or protocol is wrong: keep /v1 exactly once and wire_api = "responses". If text works but a file-listing task fails, select a tool-capable model. Confirm the resulting request appears in routerra.ai usage; successful CLI startup alone does not verify routing.
export ROUTERRA_API_KEY="YOUR_API_KEY"
codex
For Windows PowerShell:
$env:ROUTERRA_API_KEY = "YOUR_API_KEY"
codex