Claude Code + OpenRouter Config Generator (Free)

You can run Claude Code with OpenRouter models instead of a Claude subscription โ€” this free tool writes the exact config for you, in your browser, in seconds. Pick your models, your OS, and whether you want the direct OpenRouter connection or the claude-code-router app for per-task routing.

๐Ÿ”’ 100% private โ€” runs in your browser โœ“ No sign-up โœ“ Your API key never leaves this page

Point Claude Code straight at OpenRouter’s Anthropic-compatible endpoint. No extra software. Best when you want one provider and one bill.

Any provider/model ID from OpenRouter.

Never share the generated file. Your key is only inserted into the text in your browser โ€” we don’t store or send it.

Operating system (changes the command syntax)
Advanced model slots (optional)

Check your setup

Troubleshooting

SymptomLikely causeFix
401 authentication errorWrong or missing key, or ANTHROPIC_API_KEY not blankedCheck ANTHROPIC_AUTH_TOKEN; set ANTHROPIC_API_KEY=""; a stale key is not cleared by /logout โ€” blank it explicitly
404 model not foundModel ID typo, or the model isn’t on OpenRouterUse provider/model format; verify the ID on openrouter.ai/models
Tool calls fail or loopNon-Claude models can be weaker at Claude Code’s tool useSwitch the main model to a Claude model (e.g. anthropic/claude-sonnet-5.5); keep cheap models for background tasks
Requests time outSlow gateway or local modelRaise API_TIMEOUT_MS; for local models also set API_FORCE_IDLE_TIMEOUT=0
400 errors via a gatewayGateway rejects beta fieldsSet CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
Context fills too fastGateway model’s window is smaller than assumedSet CLAUDE_CODE_AUTO_COMPACT_WINDOW to the model’s real context limit

How to use Claude Code with OpenRouter

The direct method takes five steps: install Claude Code, set four environment variables, pick your models, log out of Anthropic auth, and verify with /status. Every variable name and URL below was checked against OpenRouter's official Claude Code integration guide and Anthropic's environment variable reference on October 10, 2026.

  1. Install Claude Code (skip if you have it): curl -fsSL https://claude.ai/install.sh | bash on macOS/Linux, irm https://claude.ai/install.ps1 | iex on Windows, or npm install -g @anthropic-ai/claude-code.
  2. Set the four variables. ANTHROPIC_BASE_URL must be exactly https://openrouter.ai/api โ€” note: no /v1 on the end, which is different from OpenRouter's regular API. ANTHROPIC_AUTH_TOKEN holds your OpenRouter key. ANTHROPIC_API_KEY must be explicitly blank (""), otherwise Claude Code tries to authenticate against Anthropic directly.
  3. Pick models with ANTHROPIC_DEFAULT_SONNET_MODEL (your main coding model) and ANTHROPIC_DEFAULT_HAIKU_MODEL (the fast model for quick background tasks). Model IDs use provider/model format, e.g. deepseek/deepseek-chat. The tool above generates all of this for your OS.
  4. Run /logout inside Claude Code if you previously logged in with Anthropic โ€” a stale key is not cleared automatically.
  5. Start Claude Code with claude and run /status. You should see Auth token: ANTHROPIC_AUTH_TOKEN and Anthropic base URL: https://openrouter.ai/api.

Put the variables in your shell profile or in .claude/settings.local.json under the "env" key. Don't use a .env file โ€” OpenRouter's guide says Claude Code won't pick it up, and values in settings files are used literally (no $VARIABLE expansion), so write the key out in full there.

Diagram showing how a request flows: direct path from Claude Code to OpenRouter to the model, and the claude-code-router path from Claude Code through the local router gateway to providers like OpenRouter, DeepSeek or Ollama and then to the model

How requests flow: direct to OpenRouter, or through claude-code-router's local gateway. Diagram: Vibe Coder Journal.

What is claude-code-router?

claude-code-router is a free, open-source app (by musistudio, currently v3.1.3) that sits between your coding agent and your model providers, routing each request to the provider and model you choose. It supports Claude Code, Codex, OpenCode and others, and providers including OpenRouter, DeepSeek, Moonshot/Kimi, Mistral and any custom OpenAI- or Anthropic-compatible endpoint โ€” including local ones like Ollama.

Use it instead of the direct method when you want different models for different jobs (cheap model for background tasks, strong model for hard reasoning), automatic fallbacks when a provider fails, or providers that don't offer an Anthropic-compatible endpoint. You configure it through its web UI at http://127.0.0.1:3458 โ€” in v3 there is no live config.json; settings live in a local database.

Install it with npm install -g @musistudio/claude-code-router (needs Node.js 22+), then run ccr ui. Add your providers in the UI, create a client API key, and point Claude Code at the local gateway (http://127.0.0.1:3456) โ€” Mode B of the tool above generates each of these steps with your choices filled in.

Comparison graphic: direct OpenRouter (4 env vars, OpenRouter only, one model per slot, no local models, /model picker, best for simple setups) versus claude-code-router v3 (npm install plus web UI, many providers, custom routing rules with fallbacks, Ollama and LM Studio support, client picker with CCR routing, best for mixing models)

Direct OpenRouter vs claude-code-router at a glance. Graphic: Vibe Coder Journal.

OpenRouter direct vs claude-code-router: which should you use?

Use the direct OpenRouter connection if you want the simplest setup with one provider and one bill; use claude-code-router if you want per-task model routing, fallbacks, or local models.

Direct OpenRouterclaude-code-router
Setup effortLow โ€” four env vars, no extra softwareMedium โ€” install app, add providers in web UI
Model switching/model picker in Claude CodeClient's own model picker; CCR honors recognized names
Routing rulesNo โ€” one model per slotYes โ€” custom rules, per-rule fallbacks, model chains
Local models (Ollama/LM Studio)NoYes, as custom providers
Extra softwareNoneNode.js 22+ and the CCR app
Best forSaving money with one providerMixing providers, fallbacks, local models

Best models to use with Claude Code via OpenRouter

For the main coding model, Claude models (e.g. anthropic/claude-sonnet-5.5) are the safest choice because Claude Code is optimized for Anthropic models; use cheap non-Claude models for background and bulk tasks. That honesty matters: OpenRouter's own guide warns Claude Code "may not work correctly with other providers," and Anthropic states it doesn't support routing Claude Code to non-Claude models through any gateway. In practice this shows up as weaker tool calling โ€” the exact thing that makes Claude Code useful.

A sensible split, which the tool's "Balanced" preset generates: a Claude model for main coding, a cheap model like qwen/qwen3.7-flash or openai/gpt-6-luna for the fast/background slot, and openrouter/auto as a fallback so requests still complete if your pick is unavailable. If your priority is purely saving money, the "Budget" preset routes everything to the cheapest capable models โ€” just expect to babysit tool calls more. Model prices in the tool are fetched live from OpenRouter's public models endpoint when available, with bundled prices dated October 10, 2026 as fallback.

Is claude-code-router the same as mcp-router?

No. claude-code-router routes LLM API requests between model providers; mcp-router (now archived) was a desktop app for managing MCP servers โ€” different tools, similar names. mcp-router, from the "MCP Router" GitHub organization, gave you a GUI to connect, toggle and organize Model Context Protocol servers across AI clients. Its developers ended support on September 18, 2026 โ€” the repo is archived, its site is offline, and its own notice says new adoption is not recommended. If you were looking for MCP server management, that project is effectively dead; if you want to route Claude Code to cheaper or different models, claude-code-router is the one you want.

Troubleshooting Claude Code with OpenRouter

Most failures are one of four things: a bad key, a blanked variable that isn't blank, a wrong model ID, or a non-Claude model fumbling tool calls.

SymptomLikely causeFix
401 authentication errorWrong key, or ANTHROPIC_API_KEY not blankedCheck ANTHROPIC_AUTH_TOKEN; set ANTHROPIC_API_KEY="" explicitly
404 model not foundTypo in the model ID, or model not on OpenRouterUse provider/model format; verify at openrouter.ai/models
Tool calls fail or loopNon-Claude model weaker at tool useMove the main slot to a Claude model; keep cheap models for background
TimeoutsSlow gateway or local modelRaise API_TIMEOUT_MS; for local models set API_FORCE_IDLE_TIMEOUT=0
400 errors via a gatewayGateway rejects beta fieldsSet CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
Context fills too fastGateway model's window is smaller than assumedSet CLAUDE_CODE_AUTO_COMPACT_WINDOW to the real limit

The tool's built-in checklist walks through the same verifications: key set, base URL exactly https://openrouter.ai/api, ANTHROPIC_API_KEY blanked, model ID valid, Claude Code restarted, and /status showing the right auth token and base URL.

Is it safe and allowed?

Yes, with normal API-key hygiene: the setup uses OpenRouter's documented Anthropic-compatible endpoint, and your key never leaves your machine when you use this page's generator. Treat the generated config like a password โ€” never paste it into chat logs, screenshots, or shared docs. On the provider side, you're subject to OpenRouter's terms and rate limits rather than Anthropic's subscription terms, and usage is billed per token. One thing to know: when you route through a third party, your prompts go to that provider (and onward to the model provider), not to Anthropic โ€” Anthropic neither endorses nor supports third-party gateways. The generator itself is 100% client-side: no inputs or keys are sent to vibecoderjournal.com, stored, or logged.

Frequently asked questions

Can I use GPT or Gemini in Claude Code? Yes โ€” via OpenRouter or claude-code-router with IDs like openai/gpt-6.1-sol or google/gemini-3.8-flash. Expect weaker tool calling than Claude models; keep a Claude model for the main slot if tool use matters.

Is OpenRouter cheaper than a Claude subscription? It can be. You pay per token instead of a flat fee, so light use with cheap models costs very little โ€” but heavy use of flagship models can exceed a subscription. The tool shows per-model prices so you can estimate.

Does prompt caching work? OpenRouter's Claude Code integration docs don't document prompt caching for this path, so don't count on it. (Anthropic documents DISABLE_PROMPT_CACHING for gateway setups, which tells you caching is a known variable here.)

How do I switch models mid-session? With the direct method, use Claude Code's /model picker โ€” set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 to list gateway models. With claude-code-router v3, switch in the client's own model picker; CCR routes recognized model names automatically. (The old /model provider,model command was v1-only.)

Can I use local models with Ollama? Yes, through claude-code-router: add Ollama as a custom provider with endpoint http://localhost:11434/v1 (Mode C generates this). Small local models may struggle with Claude Code's tool calls โ€” use them for simple tasks first.

Where is the claude-code-router config file? In v3 there isn't a live config.json. Configuration lives in config.sqlite under ~/.claude-code-router (macOS/Linux) or %APPDATA%\claude-code-router (Windows), edited through the web UI at http://127.0.0.1:3458. A legacy config.json is only read once, for migration.

Is my API key stored? No. The generator runs entirely in your browser. If you type a key, it's inserted into the generated text on your device only โ€” masked in the preview, full in what you copy or download. Nothing is sent to vibecoderjournal.com or stored anywhere. The page makes no network requests except an optional fetch of OpenRouter's public model list for prices.

Related tools and reading