Run Claude Code's CLI + agent tooling on OpenRouter's free models. One script per OS, four actions. Same behavior on both.
Reality check: this is not real Claude. It's the Claude Code interface driving free third-party models (Qwen3-Coder, GPT-OSS, Nemotron, …). Free models are rate-limited (~20 req/min, ~200/day), slower, and tool-heavy agent loops can be flaky. Great for learning/prototyping; not production.
| Action | What it does |
|---|---|
setup |
Installs Claude Code, signs you in to OpenRouter, picks a free model (default) |
switch-model |
Change the active free model (reuses your saved key) |
status |
Show the current config (routing, model, masked key) |
remove |
Strip the OpenRouter config — revert to a paid Claude subscription |
Run with no action for an interactive menu.
bash claude-openrouter.sh # menu
bash claude-openrouter.sh setup
bash claude-openrouter.sh switch-model
bash claude-openrouter.sh status
bash claude-openrouter.sh removepowershell -ExecutionPolicy Bypass -File .\claude-openrouter.ps1 # menu
powershell -ExecutionPolicy Bypass -File .\claude-openrouter.ps1 setup
powershell -ExecutionPolicy Bypass -File .\claude-openrouter.ps1 switch-model
powershell -ExecutionPolicy Bypass -File .\claude-openrouter.ps1 status
powershell -ExecutionPolicy Bypass -File .\claude-openrouter.ps1 removeAfter setup, open a new terminal and run claude in any project. Verify with
/status — it should show Anthropic base URL: https://openrouter.ai/api.
setup runs OpenRouter's OAuth (PKCE) flow:
- Opens your browser to the OpenRouter authorize page.
- You log in / approve.
- The script catches the redirect on a temporary
localhostport and exchanges the code for a fresh API key automatically — nothing to paste.
It writes a real, user-controlled key into ~/.claude/settings.json
(%USERPROFILE%\.claude\settings.json on Windows). If you'd rather paste a key,
answer n at the sign-in prompt. Mac/Linux uses python3 for the local
callback server (falls back to manual paste if python3 is missing); Windows
uses a native listener (no admin needed).
Shows a friendly, aligned list (name + context window + slug) pulled live from OpenRouter, filtered to models that are both free and support tool calling. At the prompt you can:
- type a number, or
- type text to filter the list (e.g.
qwen,gpt,coder), or - paste a model id directly (anything with a
/, e.g.qwen/qwen3-coder:free).
openrouter/free (the auto-router) is the recommended default — it picks a free
model for you per request.
Run remove. It backs up settings.json, strips only the keys this script added
(your other settings stay), then tells you to run claude → /login. Backups are
left as timestamped .bak files next to settings.json.
model-not-found/ auth-conflict on startup — cached Anthropic login. Start Claude Code, run/logout, relaunch. (The script already setsANTHROPIC_API_KEY=""to handle the shell-var version.)claudenot found right after install — it's in~/.local/bin; open a fresh terminal.- 429 / rate-limited — free-tier limits. Wait,
switch-model, or add a little OpenRouter credit. - Browser didn't open during sign-in — the script prints the auth URL; paste it into any browser.
- Windows: script blocked — use the
-ExecutionPolicy Bypassform above.
Refs: OpenRouter's Claude Code integration + OAuth PKCE docs
(openrouter.ai/docs), Anthropic's Claude Code docs (docs.claude.com).