Skip to content

KnowOrganization/Free-Claude-Code-Setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code ✕ OpenRouter (free models)

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.


Actions

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.


Run it

macOS / Linux

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 remove

Windows (Windows PowerShell or PowerShell 7 — not CMD, not Git Bash)

powershell -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 remove

After setup, open a new terminal and run claude in any project. Verify with /status — it should show Anthropic base URL: https://openrouter.ai/api.


How sign-in works (no manual key copying)

setup runs OpenRouter's OAuth (PKCE) flow:

  1. Opens your browser to the OpenRouter authorize page.
  2. You log in / approve.
  3. The script catches the redirect on a temporary localhost port 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).


The model picker

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.


Switching to a paid Claude subscription

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.


Troubleshooting

  • model-not-found / auth-conflict on startup — cached Anthropic login. Start Claude Code, run /logout, relaunch. (The script already sets ANTHROPIC_API_KEY="" to handle the shell-var version.)
  • claude not 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 Bypass form above.

Refs: OpenRouter's Claude Code integration + OAuth PKCE docs (openrouter.ai/docs), Anthropic's Claude Code docs (docs.claude.com).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors