Skip to content

Codex CLI ​

Codex CLI is OpenAI's command-line coding assistant. It uses the Responses API.

Preparation ​

  1. Install Codex: npm install -g @openai/codex
  2. In the console, create a token in the codex_gpt group (lowest price) or the gpt group.

Configuration ​

Edit ~/.codex/config.toml (on Windows %USERPROFILE%\.codex\config.toml), or create it if it does not exist:

toml
model = "gpt-6.1-sol"
model_provider = "codingrouter"
model_reasoning_effort = "high"

[model_providers.codingrouter]
name = "CodingRouter"
base_url = "https://api.codingrouter.ai/v1"
env_key = "CODINGROUTER_KEY"
wire_api = "responses"
SettingDescription
modelDefault model, such as gpt-6.1-sol or gpt-5.5
model_reasoning_effortReasoning effort: low, medium, high
base_urlMust include /v1
env_keyThe environment variable Codex reads the token from
wire_apiAlways responses

Then set the token and start:

bash
export CODINGROUTER_KEY="sk-your-token"
codex
powershell
$env:CODINGROUTER_KEY = "sk-your-token"
codex

To make this permanent, add the export to ~/.zshrc or ~/.bashrc.

Verify ​

bash
codex exec --skip-git-repo-check "Reply with exactly: CODINGROUTER OK"

If the output contains provider: codingrouter and CODINGROUTER OK, the setup works.

Switching models ​

After starting, type /model, or specify it at startup: codex -m gpt-5.5.

Troubleshooting ​

SymptomWhat to do
401CODINGROUTER_KEY is not set in the terminal that starts codex
404 or HTML returnedbase_url must include /v1
503The model name is wrong, or the token's group does not contain this model
Still asks you to log in to ChatGPTmodel_provider does not point to codingrouter; check the location and spelling of config.toml