← All guides

How to use OpenRouter in Claude Code

OpenRouter is an aggregator: one API key, one endpoint, and access to hundreds of models across providers. That's appealing for a coding agent — but wiring it into Claude Code has a few catches. Here's how, and a cleaner path.

TL;DR: OpenRouter exposes an OpenAI-compatible API (and some Anthropic-style support) with one key for many models. To use it in Claude Code you point ANTHROPIC_BASE_URL at OpenRouter's compatible endpoint, set ANTHROPIC_AUTH_TOKEN to your OpenRouter key, and choose a model by its OpenRouter id. It gives you huge model choice behind one bill, but you're still on one global endpoint and model ids/tool-calling vary. An agent with a built-in model list gives the same 'many models' benefit without the plumbing.

What OpenRouter is, and why it fits agents

OpenRouter is a single gateway in front of many providers: Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, Grok and more, all reachable with one key and one endpoint, on one bill. For a coding agent that's attractive — you can try or switch models without signing up with each provider separately.

The config

What to set

  1. ANTHROPIC_BASE_URLPoint Claude Code at OpenRouter's compatible endpoint (via its Anthropic-style support or a small proxy if needed).
  2. ANTHROPIC_AUTH_TOKENYour OpenRouter API key — all usage is billed through OpenRouter.
  3. Model idChoose a model by its OpenRouter id (provider/model form). This is how you pick which underlying model runs.
Gotchas: OpenRouter is OpenAI-compatible first, so depending on Claude Code's build you may still need a translator; model ids use a provider/model form; and tool-calling support differs per underlying model, so verify on a real task.

The upside and the catch

OpenRouter through Claude Code

UpsideCatch
One key for many modelsStill one global endpoint in Claude Code — no per-task switching
Easy to try new modelsModel ids and tool-calling vary; some need testing
Single bill / usage viewA markup can apply vs going direct to a provider

The cleaner option: a built-in model list

OpenRouter's real value is "many models, low friction." You can get the same benefit inside an agent that already has a built-in model list — pick any provider/model in the UI and switch in a click. If you like OpenRouter's aggregation, you can still point that agent at OpenRouter; but you can also go direct to a provider when you'd rather skip the markup.

What that looks like with Wuwei

Many models, one UI

Claude, GLM, DeepSeek, Kimi, Qwen, OpenAI-compatible endpoints — and OpenRouter itself — all selectable in a list.

Direct or aggregated

Use OpenRouter for breadth, or go direct to a provider to avoid a markup — your choice per model.

Free, open source, local

MIT-licensed agent on your machine that reads your real files; you only pay the model usage you choose.

FAQ

Can Claude Code use OpenRouter?

Yes. Point ANTHROPIC_BASE_URL at OpenRouter's compatible endpoint, set ANTHROPIC_AUTH_TOKEN to your OpenRouter key, and choose a model by its OpenRouter id. Depending on the build you may need a small translator since OpenRouter is OpenAI-compatible first.

Is OpenRouter worth it for a coding agent?

If you value trying or switching many models behind one key and one bill, yes. The tradeoffs are a possible markup versus going direct, and per-model differences in ids and tool-calling that are worth testing.

Can I get 'many models' without OpenRouter's plumbing?

Yes — use an agent with a built-in model list. Wuwei is free and open source: pick any provider/model in the UI and switch in a click. You can still point it at OpenRouter, or go direct to a provider to skip the markup.

If you like OpenRouter's 'one key, many models' idea for coding, Wuwei gives you the same breadth as a built-in model list — use OpenRouter for reach or go direct to a provider — all free, open source, and running locally on your real files.

Windows · macOS · Linux — free, no login