Codex CLI
Codex CLI is OpenAI's command-line coding assistant. It uses the Responses API.
Preparation
- Install Codex:
npm install -g @openai/codex - In the console, create a token in the
codex_gptgroup (lowest price) or thegptgroup.
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"| Setting | Description |
|---|---|
model | Default model, such as gpt-6.1-sol or gpt-5.5 |
model_reasoning_effort | Reasoning effort: low, medium, high |
base_url | Must include /v1 |
env_key | The environment variable Codex reads the token from |
wire_api | Always responses |
Then set the token and start:
bash
export CODINGROUTER_KEY="sk-your-token"
codexpowershell
$env:CODINGROUTER_KEY = "sk-your-token"
codexTo 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
| Symptom | What to do |
|---|---|
| 401 | CODINGROUTER_KEY is not set in the terminal that starts codex |
| 404 or HTML returned | base_url must include /v1 |
| 503 | The model name is wrong, or the token's group does not contain this model |
| Still asks you to log in to ChatGPT | model_provider does not point to codingrouter; check the location and spelling of config.toml |
