Skip to main content
Claude Code talks to api.anthropic.com by default, but it ships with built-in gateway support: point ANTHROPIC_BASE_URL at Opper and the same harness runs on any of 700+ models — Anthropic, OpenAI, Google, Kimi, DeepSeek, and more — with one API key, one bill at provider rates, configurable fallbacks, and per-session cost tracking. Unlike proxy tools such as claude-code-router, there is nothing to run on your machine: no local server, no router config file to maintain. Claude Code speaks its native protocol directly to Opper’s Anthropic-compatible endpoint, and the routing happens server-side in the gateway.

Prerequisites

  • Node.js ≥ 20.12 (npx works without a global install)
  • Claude Code installed
  • An Opper account — free to create; the login step below opens sign-up if you don’t have one

Quick start

launch claude sets ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN for the session and starts Claude Code — no config files, nothing else to run. Install globally with npm i -g @opperai/cli if you prefer opper on your PATH; verify your login anytime with opper whoami.
If you were previously signed in to Claude Code with an Anthropic account, run /logout inside Claude Code once so cached credentials don’t conflict with the gateway, then confirm with /status that the Opper base URL is active.

Switch the model

Pass any model from the catalog with --model, using full model IDs:
Anything after the agent name is forwarded to Claude Code verbatim:

Manual configuration (without the CLI)

Claude Code’s own environment variables work directly against Opper’s Anthropic-compatible endpoint. Get an API key (opper config get default prints the key for your default credential), then:
The ANTHROPIC_DEFAULT_* variables map Claude Code’s model aliases, and any full ID from the catalog works in each slot — so /model sonnet can resolve to a non-Anthropic model entirely:
ANTHROPIC_SMALL_FAST_MODEL is deprecated in Claude Code; use ANTHROPIC_DEFAULT_HAIKU_MODEL for the background model.
To route a single project through Opper while others keep using your Anthropic subscription, put the same keys in that project’s .claude/settings.local.json instead of your shell profile:

Show gateway models in the /model picker

Claude Code can populate its /model picker from the gateway’s model list:
Discovered models appear in the picker labeled “From gateway”; any catalog ID also works directly via --model or the env vars above. Alternatively, pin a single custom entry with ANTHROPIC_CUSTOM_MODEL_OPTION (plus _NAME and _DESCRIPTION).

Claude Agent SDK and CI

The same environment variables route the Claude Agent SDK through Opper. In CI — GitHub Actions, for example — set the base URL in the workflow and keep the key in a secret:

Keep inference in the EU

Opper’s gateway is hosted exclusively in the EU — the only thing that leaves is the model call itself, and you control where that goes. Pick an EU-hosted model from the catalog (marked in the list, e.g. mistral/mistral-large-2512) and your coding sessions never leave the EU. See Keep data in the EU for how routing restrictions are enforced at the gateway. On a network that only allows egress to the gateway, also set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 — it turns off Claude Code’s nonessential background traffic to Anthropic and third-party services (version checks, telemetry, error reports), which would otherwise show up as blocked connections in egress monitoring.

Coming from OpenRouter or claude-code-router?

  • From OpenRouter — same mechanism, different base URL: set ANTHROPIC_BASE_URL=https://api.opper.ai/v3/compat and pass your Opper key as ANTHROPIC_AUTH_TOKEN. You gain EU-hosted routing, inference at provider rates, and per-call tracing when you turn it on (Control Plane).
  • From claude-code-router — the open-source proxy runs locally and needs its own config file and process. With Opper the router runs server-side: the two env vars above are the entire setup, and they work anywhere Claude Code runs, including CI.

What changes compared to Anthropic direct

  • Billing. Routed sessions are billed as API usage through Opper at provider rates. A Claude Pro or Max subscription does not apply while a gateway credential is active.
  • Model IDs. The opus / sonnet / haiku aliases resolve through the ANTHROPIC_DEFAULT_* mapping; for everything else use full IDs from the catalog.
  • Feature parity. Some Anthropic-endpoint conveniences (prompt caching among them) depend on the route serving your request. Anthropic documents the gateway mechanism but does not officially support non-Claude models in Claude Code, so expect polish to vary by model — frontier models and strong open-weight tool-callers work well in practice.
  • Prompt caching on non-Claude models. Claude Code starts the system prompt with an attribution block that carries its version and a fingerprint of the prompt. Providers that cache by prompt prefix, such as the open-weight models, read that block first, so conversations can’t share the cached system prompt. Before Claude Code v2.1.181 the block also changed on every request, so those versions got almost no cache hits on these models. Set CLAUDE_CODE_ATTRIBUTION_HEADER=0 to leave the block out (see Claude Code’s environment variables).
  • Reliability. Set a dynamic route (dynamic/<name>) as the model in --model or an ANTHROPIC_DEFAULT_* variable to get a fallback chain (Control Plane): if the primary model fails or a provider has an outage, the call falls through to the next model in the route.

Troubleshooting

  • “Model not found” — use the full model ID exactly as listed in the catalog; aliases only resolve through the ANTHROPIC_DEFAULT_* mapping.
  • Auth errors — run opper whoami; re-run opper login if the session expired. If Claude Code was previously signed in to an Anthropic account, /logout once and check /status shows the Opper base URL.
  • Context length errors — context windows differ per model; check the catalog and pick a model sized for your session.
  • Checking spend — every routed session is metered with per-call cost, latency, and token accounting under Logs in your Opper dashboard.
Last modified on October 23, 2026