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

Replace <your-orq-api-key> with an 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:
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

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:

Configuration Reference

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.
With approvals_reviewer = "auto_review" in ~/.codex/config.toml, Codex sends its internal model name codex-auto-review for automatic approval reviews. The AI Gateway resolves this name to openai/gpt-5.3-codex, so that model must be enabled in AI GatewaySupported Models. To keep approval prompts interactive instead, set approvals_reviewer = "user" (the default).

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).