Codex
Codex setup guide covering key generation, config.toml / auth.json, and troubleshooting
Keep these values handy
The examples below use the official Routescope deployment:
- OpenAI-compatible Base URL:
https://api.routescope.ai/v1 - API Key: the full
sk-...secret copied from the console - Model: choose a model enabled for your account, such as
gpt-5.4
Step 1: Create a Key in Routescope
- Open your Routescope console and sign in.
- Follow Get Base URL and API Key to open token management.
- Click Add Token and enter a token name.
- If needed, configure quota, allowed models, IP restrictions, and expiration.
- After saving, copy the full secret from the token list. If you need endpoint or auth details, open the auth information entry on the page.
Important
Use the full secret directly. Do not remove the sk- prefix.
Step 2: Parameter Mapping
| Scenario | Field | Value | Notes |
|---|---|---|---|
| Codex CLI | base_url in config.toml | https://api.routescope.ai/v1 | /v1 is required here |
| Codex CLI | OPENAI_API_KEY in auth.json | sk-... | Use the full secret |
| Generic OpenAI-compatible clients | Base URL / API Base / Endpoint | https://api.routescope.ai/v1 | Tools such as Cursor, Cline, and Cherry Studio usually use this |
| Any client | Model | gpt-5.4 or another account-available model | Do not force a model your account cannot access |
Step 3: Configure Codex
1. Locate the Codex Config Directory
~/.codex/%USERPROFILE%\.codex\2. Put This at the Top of config.toml
model_provider = "OpenAI"
model = "gpt-5.4"
review_model = "gpt-5.4"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.routescope.ai/v1"
wire_api = "responses"
requires_openai_auth = true3. Create or Overwrite auth.json
{
"OPENAI_API_KEY": "sk-your-full-secret"
}4. Field Reference
| File | Field | Value | Notes |
|---|---|---|---|
config.toml | model_provider | OpenAI | Keep as shown |
config.toml | model | gpt-5.4 or an available model | Default chat model |
config.toml | review_model | gpt-5.4 or an available model | Review model, can match the main model |
config.toml | base_url | https://api.routescope.ai/v1 | /v1 is required |
config.toml | wire_api | responses | Keep as shown |
auth.json | OPENAI_API_KEY | Full sk-... secret | Copy from token management |
If your account does not have gpt-5.4, replace model and review_model with a model that is actually available.
Step 4: Verify the Setup
The simplest verification is to request the model list:
curl https://api.routescope.ai/v1/models \
-H "Authorization: Bearer sk-your-token"If the model list returns normally, the key and gateway endpoint are configured correctly.
FAQ
Why does config.toml need /v1?
Codex uses an OpenAI-compatible endpoint, so base_url must include the version path: https://api.routescope.ai/v1.
Why am I getting 401 / 403?
Check whether the copied secret is the full sk-... value, whether the token is disabled, expired, out of quota, whether the model is allowed by the token, and whether IP restrictions are blocking the request.
Why am I getting 404?
The most common cause is an incorrect endpoint. Codex base_url and generic OpenAI-compatible clients should use https://api.routescope.ai/v1.
How is this guide?
Last updated on