Add a provider pointing at the platform in ~/.codex/config.toml.
This guide connects Codex CLI to the platform so you can reach Claude, GPT, Gemini and others with a single token. Three values are all you need: endpoint, token, model name.
Create a token (starting with sk-) in the console first and make sure the account has credit. New here? Start with your first request in 5 minutes.
Edit ~/.codex/config.toml, add a custom provider and make it the default. Keep the key in an environment variable rather than in the file.
| Field | Value |
|---|---|
| base_url | https://api.router.ai/v1 |
| env_key | ROUTER_API_KEY |
| model | gpt-5.5 |
model = "gpt-5.5"
model_provider = "router"
[model_providers.router]
name = "Router AI"
base_url = "https://api.router.ai/v1"
env_key = "ROUTER_API_KEY"
wire_api = "chat"
# then: export ROUTER_API_KEY=sk-your-token
Before running anything complex, just say hello and check you get a reply. To test the token on its own, call the API directly:
curl https://api.router.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-token" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.5","messages":[{"role":"user","content":"hello"}]}'
A JSON response containing choices means you are connected. The call shows up in your billing records shortly after.
wire_api can be either chat or responses — both are supported. If you hit errors about tools plus reasoning_effort not being supported together, try responses first.
Wrong token, a stray space, or a copy that dropped the leading sk-. Copy it again in full.
Almost always the URL suffix. The OpenAI-compatible format needs a trailing /v1; the native Anthropic and Gemini formats must not have it. Check the table above.
The account is out of credit. See top-up methods.
Model names must match the catalog exactly, including case and hyphens. Copy the exact name from the models page.