Route 1: point Claude Code at OpenRouter directly
OpenRouter exposes an Anthropic-compatible Messages endpoint alongside its OpenAI-style API. Claude Code only needs the base URL and a key, so the setup is the same two variables you would use for any gateway — check OpenRouter's docs for the current base path if the one below has moved:
export ANTHROPIC_BASE_URL=https://openrouter.ai/api
export ANTHROPIC_AUTH_TOKEN=sk-or-... # your OpenRouter key
claude --model anthropic/claude-sonnet-5 # OpenRouter's model id format
Model ids follow OpenRouter's vendor/model naming, which is also what you put in the per-tier variables (ANTHROPIC_DEFAULT_SONNET_MODEL and friends). Run /status to confirm the endpoint and /model to switch. Billing is OpenRouter's: the model's list price plus OpenRouter's platform fee on credits, so this route costs slightly *more* than Anthropic direct — its point is convenience and one account, not price.
Route 2: claude-code-router for non-Claude models
claude-code-router is a local proxy that receives Claude Code's requests and forwards each one to a provider you choose by rule — default, background, think, long-context. Configure OpenRouter as a provider with your key, pick models per route, launch with ccr code. This is how people run open-weight or other vendors' models inside Claude Code.
// ~/.claude-code-router/config.json (excerpt)
{
"Providers": [{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-or-...",
"models": ["anthropic/claude-sonnet-5", "google/gemini-2.5-pro", "deepseek/deepseek-chat"]
}],
"Router": { "default": "openrouter,anthropic/claude-sonnet-5", "background": "openrouter,deepseek/deepseek-chat" }
}
What breaks: Claude Code's agent loop relies on Anthropic's tool-use format, and the router has to translate it for OpenAI-style models. Strong models cope; smaller ones drop tool calls, hallucinate file paths or ignore the permission protocol, and the session degrades into retries. Keep the *default* and *think* routes on a Claude model and use the others for background work, and it is a good setup.
What it costs, honestly
- OpenRouter direct: Anthropic list price + OpenRouter's fee. Convenient, never cheaper than Anthropic.
- claude-code-router + OpenRouter: whatever the routed models cost; savings come from sending background tasks to cheap models, not from Claude being cheaper.
- Claude gateway (this site): the same Claude models, billed at list rates against credits bought 87% below face value ($13 → $100 of usage), or a flat-rate unlimited plan from $1. Claude only — no other vendors.
If you only want Claude, skip OpenRouter
Most people searching for "OpenRouter in Claude Code" want one of two things: a cheaper Claude bill, or a way to pay without an Anthropic console account. OpenRouter solves the second and makes the first worse. A Claude gateway solves both — same two variables, no proxy, Claude only:
export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=your_gateway_key
claude
And the two compose: define this gateway as an Anthropic-type provider in claude-code-router and route the Claude tiers to it while sending background tasks elsewhere. The ecosystem guide covers the router in more depth.
| Plan | Duration | Price |
|---|---|---|
| Unlimited 1 Hour | 1 hour | $1 |
| Unlimited 24 Hours | 24 hours | $10 |
| Unlimited 1 Week | 1 week | $49 |
| Unlimited 15 Days | 15 days | $89 |
Frequently asked questions
Can Claude Code use OpenRouter?
Yes — directly through OpenRouter's Anthropic-compatible endpoint (Claude models), or through claude-code-router for any OpenRouter model. Set ANTHROPIC_BASE_URL and your OpenRouter key for the direct route.
Is OpenRouter cheaper for Claude Code?
No. OpenRouter charges Anthropic's list price plus its own fee. Savings only come from routing background tasks to cheaper non-Claude models, or from using a Claude gateway that sells the same models below list.
Which models work best in Claude Code through OpenRouter?
Claude models, unsurprisingly — the agent loop is built around Anthropic's tool format. Other strong models work with the router; small ones struggle with tool calls.
Run Claude Code on the gateway
Same models, two environment variables, credits at 7.69× face value — or a flat-rate unlimited plan.
Get an API key See unlimited plansAI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.