Agents & Editors
Codex CLI
Connecting OpenAI's Codex CLI to a Codex Proxy with the OpenAI Responses format.
Codex CLI is OpenAI's coding agent for the terminal. It sends OpenAI Responses requests only, so it connects to Multi-Router through a Codex Proxy, which serves /v1/responses for OpenAI models and forwards each request to OpenAI unchanged.
Creating the router
- In Routers, choose New router, then Codex Proxy, and name it.
- Choose the OpenAI credential: Organization, with one of the organization's enabled OpenAI keys, or Developer, so that each developer's own OpenAI API key is passed through.
- Create the router. Its id, such as
rt_XXXXXXXX, is on the router's page, under Forwarding with the Codex CLI settings. - In API Keys, create a key with the
inferencescope for each developer. It can be limited to this router.
Settings
Codex CLI reads custom providers from ~/.codex/config.toml. A project's own .codex/config.toml cannot set a provider. Add a provider with the Responses format and the router header. The Multi-Router API key travels in its own header, X-MR-Api-Token, read from an environment variable:
| Setting | Value |
|---|---|
MR_API_TOKEN | The Multi-Router API key with the Bearer prefix. |
OPENAI_API_KEY | With the Developer credential, the developer's own OpenAI API key. With the Organization credential, any non-empty value; the organization's OpenAI key replaces it. |
base_url | Replaces OPENAI_BASE_URL for this provider. |
Codex CLI tries a WebSocket connection first. The Codex Proxy refuses it, and Codex CLI continues over HTTP. A ChatGPT plan sign-in does not go through a Codex Proxy.
Models
A Codex Proxy serves OpenAI models only, named as OpenAI names them, such as gpt-5, in model or with -m. A model from another provider is refused with 400 is not an OpenAI model, and a model unknown to the Multi-Router catalog is refused before it reaches OpenAI.
Checking the setup
The request then appears in Traffic with the Codex Proxy in the Router column and the model, tokens and cost in the request detail. A reply with the requested model or router was not found means the router id is wrong, or the API key is not allowed to use that router. See Traffic and Troubleshooting.