Skip to main content
Route every model call Codex CLI makes through the Orq.ai AI Gateway by editing ~/.codex/config.toml. Requests appear in Traces automatically.

Prerequisites

Setup

1

Export the API key

export ORQ_API_KEY="<your-orq-api-key>"
This sets the variable for the current shell session. To persist it across sessions, add the line to ~/.zshrc or ~/.bashrc.
2

Create or edit ~/.codex/config.toml

Create ~/.codex/config.toml if it does not exist. Add or merge the following keys. The top-level model and model_provider lines set the default; the [model_providers.orq] block registers the custom provider:
model = "openai/gpt-5.4"
model_provider = "orq"

[model_providers.orq]
name = "Orq AI Gateway"
base_url = "https://api.orq.ai/v3/router"
env_key = "ORQ_API_KEY"
wire_api = "responses"
requires_openai_auth = false
Replace openai/gpt-5.4 with the provider-prefixed model to use by default (e.g. anthropic/claude-sonnet-4-6). If a model key already exists in the file, replace it.
Do not name the provider openai. That identifier is reserved and hardcoded to api.openai.com. Setting base_url has no effect on it.
3

Run Codex

codex
Running codex without flags routes all calls through the AI Gateway using the model configured in ~/.codex/config.toml.Pass --model to override the model for a single invocation:
codex --model anthropic/claude-sonnet-4-6

Configuration reference

FieldValueDescription
modelprovider/model-idDefault model. Must use provider-prefixed format.
model_providerorqSelects the custom provider defined below.
base_urlhttps://api.orq.ai/v3/routerAI Gateway router endpoint.
env_keyORQ_API_KEYEnvironment variable that holds the API key.
wire_apiresponsesWire protocol. Codex uses the Responses API.
requires_openai_authfalseDisables the OpenAI auth header. Required for Orq-routed calls.

Troubleshooting

Confirm ORQ_API_KEY is exported in the shell running Codex. Run echo $ORQ_API_KEY to verify the value is set.
The model must be enabled in AI GatewaySupported Models before Codex can route to it. Check that the model ID in config.toml uses the provider-prefixed format (e.g. openai/gpt-5.4, not gpt-4o).
Confirm base_url is https://api.orq.ai/v3/router and model_provider is set to the custom provider name (e.g. orq), not openai.

Verification

Send a prompt in Codex. The response appears in the terminal and the trace appears in Orq.ai Traces with the model identifier (e.g. openai/gpt-5.4).