The two lines
Install the anyr CLI, then launch Claude Code through it on the free router:
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr claude --model anyrouter/freeThe first run opens a browser to sign you in, creates a key and saves it. Later runs go straight into Claude Code. If Claude Code is not installed yet, add --install and anyr installs it first. You need an AnyRouter account but no card.
anyrouter/free picks one of the free models that is healthy right now and falls back to the next if it fails. The same two lines are on the /claude-code page, and the signed-in version, with your own key filled in, is at /welcome#claude-code.
Keep background calls free too
Claude Code sends some calls to a small background model, and to subagents. anyr claude points those at Claude Haiku by default, and that model is only available through your own provider key (BYOK). On a Free account without one, those calls can fail with 404 model_unavailable even while your main model is free. Pin all the aliases to the free router to avoid that:
anyr claude --model anyrouter/free \
--haiku anyrouter/free --sonnet anyrouter/free \
--opus anyrouter/free --fable anyrouter/freeanyr claude --dry-run prints the command and environment it would use, with the key redacted, so you can check the aliases before you start.
Without the CLI
Claude Code reads two environment variables. Create a key in the dashboard (every key starts with sk-ar-), then:
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="sk-ar-your-key"
claude --model anyrouter/freeLeave /v1 off the base URL: Claude Code adds /v1/messages itself. Full reference: docs.anyrouter.dev/cli/claude-code.
Which free models to try
We have not ranked free models for coding, and any ranking would go stale in a week. What we can say is which ones anyrouter/free may route to and have at least 128K of context, since Claude Code's own prompt and tool list use a good part of a small window. This table is generated from the catalog when the page is built.
| Model | Id | Context |
|---|---|---|
| Glyph Cluster | stealth/glyph-cluster | 256K |
| Step 5 Preview | stepfun/step-5-preview | 1M |
| Dots3-Note Preview | dots-studio/dots-3-note-preview | 512K |
| Inkling Small | thinkingmachines/inkling-small | 1M |
| LFM 2.5 2.6B | liquid/lfm-2.5-2.6b | 128K |
| Nemotron 3.5 Lightning 30B A3B | nvidia/nemotron-3.5-lightning-30b-a3b | 131K |
| Laguna S 2.1 | poolside/laguna-s-2.1 | 262K |
| Inkling | thinkingmachines/inkling | 1M |
| Laguna XS 2.1 | poolside/laguna-xs-2.1 | 262K |
| DeepSeek-V4-Flash | deepseek/deepseek-v4-flash | 128K |
| Qwen3-8B | qwen/qwen3-8b | 128K |
| Nemotron-3 Super 120B | nvidia/nemotron-3-super-120b-a12b | 262K |
| Nemotron 3 Ultra 550B | nvidia/nemotron-3-ultra-550b-a55b | 1M |
| Gemma 4 31B | google/gemma-4-31b | 262K |
| GPT-OSS 20B | openai/gpt-oss-20b | 131K |
Pass any id to --model to pin it. The full, current list is at /free. To see only models that speak the Messages API Claude Code uses, filter the model list.
Limits, stated plainly
- Cost: free models bill $0 per token and do not touch your credit balance. Paid models return
402until you add credits or a plan. - Rate: no daily cap. Free models share 2,400 requests per minute per API key on every plan.
- Sign-in: a request with no key gets a
401. Signing up is free. - Quality: these are not Claude. Hard multi-file work is where a free model is most likely to stall or go wrong, so review diffs as you would for any agent.
- Availability: free capacity comes from upstream providers and changes.
anyrouter/freefalls back automatically, but a pinned model can be busy or gone. - Settings: if a privacy setting such as Zero Data Retention rules out every free model, you get
400 no_eligible_models. Pin a model that meets it. - Long runs: for slow models,
export API_TIMEOUT_MS=3000000raises Claude Code's timeout. Theanyrlauncher already sets it.
Check it worked
Run any prompt, then open your request logs. The call shows up a few seconds after the stream closes, with the model that answered, token counts and cost. Free calls show $0.
Coming from OpenRouter? The same two-line swap works for any OpenAI-compatible client. See AnyRouter vs OpenRouter for a sourced comparison and the migration steps.
Free models in Claude Code: two lines, no card.
Open the setup pageFAQ
Related posts
AnyRouter vs OpenRouter: a sourced comparison and migration guide
Fees, BYOK, free-model limits and plans for AnyRouter and OpenRouter, each OpenRouter figure linked to its source and dated. Plus the base URL and key swap to move over.
Claude Code on anyrouter.dev
Claude Code on anyrouter.dev. setup.sh then anyr claude. ANTHROPIC_BASE_URL=https://anyrouter.dev/api. Free has no monthly credits; Go is $2/mo ($2.63 charged) → $4.
BYOK: bring your own keys to every provider
Attach the OpenAI, Anthropic, Google, and 60+ other provider keys you already pay for, route them through one OpenAI-compatible URL at $0 markup, cap spend per key, and — if you donate idle quota to the shared pool — earn up to 8% back and unlock Go for free while a donated key stays active.
Route your first request in 2 minutes
Start free with your own keys, or top up and pay per token. Get $4/mo in credits and free models on Go — $2/mo, or free when you donate a provider key.
Start free