Launch Claude Code CLI with free OpenRouter models — no Anthropic subscription required.
A tiny shell wrapper that:
- Fetches all free models from OpenRouter live
- Lets you pick one with a fuzzy selector (fzf)
- Sends you straight into Claude Code
- Never touches your normal
claudecommand
claudeop → pick a free model, launch Claude Code
claude → your normal Anthropic subscription (unchanged)
Think of it like two remote controls for the same TV:
| Command | What It Does | Who Pays |
|---|---|---|
claude |
Claude Code via your Anthropic account | Your Anthropic subscription |
claudeop |
Claude Code via OpenRouter's free models | Free (OpenRouter) |
Both share the same Claude Code settings, plugins, MCP servers, and project config. The only difference is which model answers your prompts.
Before you start, you need these three things installed on your computer. Don't worry — they're all free.
Claude Code is Anthropic's coding assistant that runs in your terminal.
Install:
# macOS — paste this in Terminal and press Enter
curl -fsSL https://storage.googleapis.com/claude-code/claude-code-installer.sh | shCheck it worked:
claude --version
# Should print something like: 2.1.175If you already have Claude Code installed, skip this step.
OpenRouter is a service that gives you access to AI models (including Claude) — some for free.
- Go to openrouter.ai and create a free account
- Once logged in, go to Settings → API Keys
- Click "Create Key"
- Copy the key (it starts with
sk-or-v1-...) - Save it somewhere — you'll need it in Step 3
Homebrew installs other tools for you. You likely already have it.
Check:
brew --version
# If it prints a version number, you have it — skip the installInstall (if needed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"These are tiny tools that claudeop needs. Install them with one command:
brew install jq fzfOpen your shell profile:
nano ~/.zshrcScroll to the bottom and add this line (replace sk-or-v1-YOUR_KEY_HERE with your actual key):
export OPENROUTER_API_KEY="sk-or-v1-YOUR_KEY_HERE"Save and exit:
- Press
Ctrl + O, thenEnterto save - Press
Ctrl + Xto exit
Then reload your shell:
source ~/.zshrcVerify:
echo $OPENROUTER_API_KEY
# Should print your key starting with sk-or-v1-Open your shell profile again:
nano ~/.zshrcScroll to the bottom and paste this entire block:
# ── Claudeop: Launch Claude Code with free OpenRouter models ──────────
# claudeop → pick a free model, launch Claude Code
# claudeop -m <id> → skip picker, use specific model
# claude → Anthropic subscription (unchanged)
# Fetch :free models from OpenRouter on every launch
_claudeop_models() {
curl -s "https://openrouter.ai/api/v1/models" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
| jq -r '[.data[] | select(.id | test(":free"))] | sort_by(.id) | .[].id' 2>/dev/null
}
claudeop() {
if [[ -z "$OPENROUTER_API_KEY" ]]; then
echo "❌ OPENROUTER_API_KEY not set"
return 1
fi
local model=""
local skip_picker=0
local args=("$@")
while [[ $# -gt 0 ]]; do
case "$1" in
-m) model="$2"; skip_picker=1; shift 2 ;;
--model) model="$2"; skip_picker=1; shift 2 ;;
*) shift ;;
esac
done
if [[ $skip_picker -eq 0 ]]; then
local models="$( _claudeop_models )"
if [[ -z "$models" ]]; then
echo "❌ No models found on OpenRouter"; return 1
fi
model=$(echo "$models" | fzf --prompt="OpenRouter model → " --height=~40% --reverse --no-info)
if [[ -z "$model" ]]; then
echo "Cancelled"; return 0
fi
fi
echo "🟢 OpenRouter → [$model]"
ANTHROPIC_API_KEY="" \
ANTHROPIC_BASE_URL="https://openrouter.ai/api" \
ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" \
ANTHROPIC_DEFAULT_OPUS_MODEL="$model" \
ANTHROPIC_DEFAULT_SONNET_MODEL="$model" \
ANTHROPIC_DEFAULT_HAIKU_MODEL="$model" \
CLAUDE_CODE_SUBAGENT_MODEL="$model" \
claude "${args[@]}"
}Save and exit (Ctrl + O, Enter, Ctrl + X), then reload:
source ~/.zshrcclaudeopYou should see a fuzzy picker listing free models. Use arrow keys to pick one, press Enter, and Claude Code launches with that model.
Look for the banner:
🟢 OpenRouter → [nex-agi/nex-n2-pro:free]
You're in! Type your prompt and go.
claudeopA list of free models appears. Arrow keys to browse, type to filter, Enter to select.
claudeop -m "google/gemma-3-27b-it:free"claudeExactly as before. Untouched.
claudeop
│
├─ Fetches free models from OpenRouter's API
├─ Shows them in fzf (a fuzzy selector)
├─ You pick one
└─ Launches `claude` with these env vars (only for that session):
ANTHROPIC_BASE_URL = https://openrouter.ai/api
ANTHROPIC_AUTH_TOKEN = your OpenRouter key
ANTHROPIC_API_KEY = "" (blanked to prevent conflict)
ANTHROPIC_DEFAULT_OPUS_MODEL = the model you picked
ANTHROPIC_DEFAULT_SONNET_MODEL = the model you picked
ANTHROPIC_DEFAULT_HAIKU_MODEL = the model you picked
CLAUDE_CODE_SUBAGENT_MODEL = the model you picked
Your shell environment is never modified. The env vars only exist inside that single Claude Code process. When it exits, they're gone.
Your API key isn't in your shell. Go back to Step 2 and make sure you added the export line to ~/.zshrc and ran source ~/.zshrc.
- Check your internet connection
- Your API key might be invalid — try re-creating one at openrouter.ai/settings/keys
- The
:freefilter might be too strict — temporarily test by running:If it prints a number > 0, your key works.curl -s https://openrouter.ai/api/v1/models \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ | jq '.data | length'
Free models come and go on OpenRouter. Try again later — new free models appear regularly.
If you previously logged into Claude Code with your Anthropic account:
- Run
/logoutinside Claude Code - Quit Claude Code
- Try
claudeopagain
Free models have limitations. Some don't support tool use, long contexts, or Claude Code's advanced features. Try a different free model from the picker.
Remove the claudeop block from your ~/.zshrc:
nano ~/.zshrc
# Delete everything between and including:
# "# ── Claudeop: Launch Claude Code with free OpenRouter models ──────────"
# and the closing "}"Then optionally remove the API key line:
# Delete this line too if you don't use OpenRouter elsewhere:
export OPENROUTER_API_KEY="sk-or-v1-..."Reload:
source ~/.zshrcYour normal claude command is unaffected.
MIT
