DEV Community

Felix for Opper AI

Posted on

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

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.

Option 1: the 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"
Enter fullscreen mode Exit fullscreen mode

I'm using Opper 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
Enter fullscreen mode Exit fullscreen mode

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

Option 2: one command

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
Enter fullscreen mode Exit fullscreen mode

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.

Which models actually make sense in Codex

  • openai/gpt-5.3-codex: the model Codex was built for, via API billing. Honest note: if you already have a ChatGPT plan, Codex is included there and that's the cheaper path for this one model. The router play is for everything else.
  • anthropic/claude-opus-4-7 / claude-sonnet-4-6: the most common reason people set this up at all.
  • moonshot/kimi-k3 and alibaba:global/kimi-k2.7-code: strong coding output per dollar for long agent sessions.
  • EU variants like 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. 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.

The fine print

  • Codex talks to custom providers over the Responses API (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.
  • Billing on the gateway side is pay-as-you-go at provider token rates, and only successful responses are billed, so a failed request that retries elsewhere doesn't double-charge.

If you hit something weird with a specific model, tell me in the comments, I run this setup daily.

Top comments (0)