# Codex CLI with any model: the "codex router" setup in one config block

> Source: <https://dev.to/opper/codex-cli-with-any-model-the-codex-router-setup-in-one-config-block-3ol7>
> Published: 2026-08-25 09:18:02+00:00

OpenAI's Codex CLI is a genuinely good coding agent, but out of the box it runs OpenAI models on OpenAI billing. Sometimes you want Claude Opus for a gnarly refactor, Kimi K2.7 Code for cheap long sessions, or a model served from EU infrastructure because your client asks where tokens go.

What most people miss: Codex has custom providers built in. It speaks the Responses API to whatever `base_url`

you give it, so any gateway that implements the Responses API can act as the router behind Codex. No forks, no proxies, one config block.

Codex reads `~/.codex/config.toml`

. Add a provider and a profile:

```
[model_providers.opper]
name = "Opper"
base_url = "https://api.opper.ai/v3/compat"
env_key = "OPPER_API_KEY"
wire_api = "responses"

[profiles.opus]
model = "anthropic/claude-opus-4-7"
model_provider = "opper"

[profiles.kimi]
model = "moonshot/kimi-k3"
model_provider = "opper"
```

I'm using [Opper](https://opper.ai) here (disclosure: I work there), an EU-hosted gateway with 700+ models behind one API key that implements the Responses API. Export the key and launch with a profile:

```
export OPPER_API_KEY="your-key"
codex --profile opus
```

That's the whole router. Yes, that means Claude running inside OpenAI's own CLI, which never stops being funny.

If you don't want to touch config files, the Opper CLI writes exactly that block for you (with sentinel markers, so it never clobbers your existing config and can cleanly remove itself):

```
npm install -g @opperai/cli
opper launch codex
```

It detects Codex (installs it with `--install`

if missing), configures the provider, and starts it with preset profiles. `opper launch codex --model moonshot/kimi-k3`

picks a model at launch.

`openai/gpt-5.3-codex`

`anthropic/claude-opus-4-7`

/ `claude-sonnet-4-6`

`moonshot/kimi-k3`

`alibaba:global/kimi-k2.7-code`

`vertexai/gemini-3.7-flash-eu`

or Claude on European Vertex regions, if tokens staying in Europe is a requirement and not a preference.The full catalogue with per-model pricing, context windows and hosting regions is at [opper.ai/models](https://opper.ai/models). Every route is labeled with where it runs and what the retention posture is, which is the part my compliance-minded clients actually care about.

`wire_api = "responses"`

). Chat-completions-only gateways need `wire_api = "chat"`

, which Codex also supports, but Responses is the native path and what I tested here.If you hit something weird with a specific model, tell me in the comments, I run this setup daily.
