multi-router.aidocs

Routing

Codex Proxy

The router that serves Codex CLI: OpenAI Responses requests forwarded to OpenAI with an organization key or each developer's own OpenAI key.

A Codex Proxy is a router that serves OpenAI's Codex CLI and other clients of the OpenAI Responses API. It receives POST /v1/responses requests, forwards the request body to OpenAI unchanged, and returns OpenAI's response unchanged, so every feature of the Responses API is available. It serves OpenAI models only, and records usage and cost for each person in Traffic. How Codex CLI is configured to use a Codex Proxy is described in Codex CLI.

Endpoints

A Codex Proxy serves one endpoint. A request selects the proxy with the X-MR-Router header, which names the proxy's id or an alias that points to it:

EndpointFormatForwards to
POST /v1/responsesOpenAI Responses, streamed or nothttps://api.openai.com/v1/responses

/v1/responses is served only through a Codex Proxy; without one, it returns 404 /v1/responses is only available through a Codex Proxy (X-MR-Router). A WebSocket upgrade on this endpoint is refused with 400, and Codex CLI then continues over HTTP. A Codex Proxy does not serve GET /v1/models.

Credentials

The proxy's provider key decides whose OpenAI account pays for requests:

ModeCreated withBehavior
Organizationrouting.provider_key_id: an enabled OpenAI key of the organizationMulti-Router removes the client's credential and the OpenAI-Organization and OpenAI-Project headers, and sends the organization's OpenAI key. Usage is billed to the organization's OpenAI account.
DeveloperNo provider_key_idThe client's own OpenAI API key in Authorization is forwarded unchanged, with its OpenAI scoping headers, and usage is billed to that person's OpenAI account.

In Developer mode, Authorization carries the OpenAI key, so the Multi-Router API key travels in the X-MR-Api-Token: Bearer <key> header. A Multi-Router API key found in a header that is forwarded to OpenAI returns 400. In Organization mode, the client's OpenAI key can be any value, because the organization's key replaces it. A ChatGPT plan sign-in does not go through a Codex Proxy.

Models

A Codex Proxy forwards requests for OpenAI models in the catalog, named as OpenAI names them, such as gpt-5. A model from another provider returns 400 is not an OpenAI model, a model the catalog does not list returns 400 before the request reaches OpenAI, and a router or alias in model returns 400, since /v1/responses has no router dispatch.

Creating a Codex Proxy

To create a Codex Proxy in the dashboard:

  1. On the Routers page, select New router, and under Proxies choose Codex Proxy.
  2. Enter a Name, and choose Organization with one of the organization's enabled OpenAI keys, or Developer so that each developer's own OpenAI API key is passed through.
  3. Create the proxy. Its Forwarding panel shows the credential, which can be changed, and the Codex CLI settings.

With the API, send POST /v1/routers with kind codex_proxy:

Create a Codex Proxy with an organization keybash
curl -X POST https://api.multi-router.ai/v1/routers \
  -H "Authorization: Bearer $MR_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "kind": "codex_proxy", "name": "Eng Codex", "routing": { "provider_key_id": "llpk_7Ns2Xc5PwK" } }'

Leave out routing for Developer mode. provider_key_id is the only routing field a Codex Proxy accepts; any other returns 400 invalid_field. PATCH /v1/routers/{id} with routing.provider_key_id changes the key, and null switches to Developer mode. The router view reports the mode in routing.credential_source.

Limits, settings and Traffic

LimitValue
Request body4 MiB
Time to OpenAI's response headers120 seconds

A Codex Proxy's settings are its credential, its request logging, and its name, description and tags. The API key's rate limit and budgets apply. Requests are sent to OpenAI once, without retries, and OpenAI's status and error body are returned to the client. Traffic records one row for each request, with the API type openai.responses, the model, the person and the cost.

Errors

Creating or changing a Codex Proxy returns 400 invalid_provider_key_id when the key is not an enabled OpenAI key in the organization. Requests return the following errors, in the OpenAI format:

StatusCause
404The X-MR-Router header names no Codex Proxy, or the API key cannot use it.
403The Codex Proxy is disabled.
400The model is not a catalog OpenAI model or names a router, the Multi-Router API key is in a forwarded header, or the request is a WebSocket upgrade.
413The request body is over 4 MiB.
429The API key's rate limit or a budget refused the request.
503The proxy's organization key is missing or disabled.
502OpenAI could not be reached or timed out.
Claude ProxyGemini Proxy
Was this helpful?