Run Codex CLI on OAIRoute

Codex CLI accepts custom model providers in ~/.codex/config.toml. Add one block and it routes through the gateway while keeping its own agent loop, sandbox and approvals.

OpenAI

Configuration

~/.codex/config.toml
model_provider = "oairoute"
model          = "gpt-5.6"

[model_providers.oairoute]
name     = "oairoute"
base_url = "https://api.oairoute.com/v1"
wire_api = "responses"
experimental_bearer_token = "YOUR_OAIROUTE_KEY"
Create the file if it does not exist, then run codex.

Full step-by-step guide

Why route it through OAIRoute

GPT-6 at list-price fractions

GPT-6-Astra is $0.50 in / $2.50 out per million tokens here versus $10 / $50 on OpenAI list. GPT-6.1 Sol sits at $0.10 / $0.50.

Responses or Chat Completions, your call

Set wire_api to "responses" for the native shape, or "chat" when a model is happier with Chat Completions.

One provider, every vendor

The provider block does not care which vendor serves the model, so testing a Claude or DeepSeek model against a Codex task is a one-line change.

Setup

  1. 1

    Create a key

    Register at api.oairoute.com and create a key on the token page.

  2. 2

    Add the provider block

    Write the TOML below into ~/.codex/config.toml, then export your key as an environment variable.

  3. 3

    Verify

    Run `codex "explain this project structure"` and watch it call the gateway.

Models worth trying

Model IDNameUse it forUSD per 1M in / out
gpt-6-astraGPT-6-AstraOpenAI flagship, 1.1M context. Strongest tool loop.$0.50 / $2.50
gpt-6.1-solGPT-6.1 SolCheaper sibling, still 1.1M context.$0.10 / $0.50
gemini-4-argonGemini 4 ArgonUseful second opinion on long-context tasks.$0.30 / $1.50

Prices are per million tokens, input / output, at the rates published in the model catalogue.

Questions

Should wire_api be responses or chat?

Use "responses" with GPT-6 models. Switch to "chat" if a specific model returns errors on tool calls — the Responses shape is not implemented by every upstream.

base_url needs /v1?

Yes. Codex wants the full endpoint: https://api.oairoute.com/v1. A trailing slash will also break it.

Why 401?

The environment variable did not reach the process, or env_key does not match its name. Reopen the terminal and check with `echo $OAIROUTE_API_KEY`.

Other guides