Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AnythingLinux/4579c52d357cb7e2e7d54c9ebd449e0c to your computer and use it in GitHub Desktop.

Select an option

Save AnythingLinux/4579c52d357cb7e2e7d54c9ebd449e0c to your computer and use it in GitHub Desktop.
Setup Openrouter API to run free model using Claude Code CLI to run free model
To set up Claude Code CLI to run completely free models via OpenRouter, you must route the CLI's API requests through OpenRouter's endpoint and pass your OpenRouter API key as the auth token. This approach requires no third-party proxy or Docker containers.
✅ Prerequisites
- Any Linux terminal
- OpenRouter API Key: Get one at openrouter.ai/keys(opens in new tab).
- Claude Code v1.0.30+: Update via npm update -g @anthropic-ai/claude-code or brew upgrade claude-code.
- Node.js 26+.
1. Set Environment Variables (Persistent)
Add these to your shell config (~/.zshrc, ~/.bashrc, ~/.config/fish/config.fish):
# OpenRouter Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="https://openrouter.ai/api/v1"
# Your OpenRouter Key (Bearer token format)
export ANTHROPIC_AUTH_TOKEN="sk-or-v1-YOUR_OPENROUTER_KEY_HERE"
# Optional: Helps OpenRouter identify your app for rankings/rate limits
export ANTHROPIC_DEFAULT_HEADERS='{"HTTP-Referer": "https://github.com/anthropics/claude-code", "X-Title": "Claude Code"}'
Reload shell: source ~/.zshrc (or restart terminal).
2. Run with Model Flag
claude --model "nvidia/nemotron-3-ultra-550b-a55b:free"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment