Skip to content
All posts

Run Claude Code on free models in two lines

Install the anyr CLI, then run anyr claude. Claude Code works on AnyRouter's free models: a 5-request trial, then Go ($2 a month, or free with one donated key). Exact commands, the manual setup, which models to try, and the limits.

The two lines

Install the anyr CLI, then launch Claude Code through it on the free router:

terminal
curl -fsSL https://anyr.dev/cli.sh | bash
anyr claude --model anyrouter/free

The 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; the Free plan is a 5-request trial, then Go.

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:

terminal
anyr claude --model anyrouter/free \
  --haiku anyrouter/free --sonnet anyrouter/free \
  --opus anyrouter/free --fable anyrouter/free

anyr 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:

terminal
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="sk-ar-your-key"
claude --model anyrouter/free

Leave /v1 off the base URL: Claude Code adds /v1/messages itself. Full reference: anyrouter.dev/docs/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.

ModelIdContext
Hy4 flashtencent/hy4-flashtencent/hy4-flash1M
LongCat-2.5meituan/longcat-2.51M
Beam 1.0reflection/beam-1.01M
Glyph Clusterstealth/glyph-clusterstealth/glyph-cluster256K
Solar Mini 4upstage/solar-mini4upstage/solar-mini4524K
DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flash1M
GLM-5.3z-ai/glm-5.31M
GLM-5.3-Flashz-ai/glm-5.3-flash1M
Dots3-Note Previewdots-studio/dots-3-note-previewdots-studio/dots-3-note-preview512K
Nemotron 3.5 Lightning 30B A3Bnvidia/nemotron-3.5-lightning-30b-a3b1M
Qwen3-8Bqwen/qwen3-8bqwen/qwen3-8b128K
Nemotron 3 Ultra 550Bnvidia/nemotron-3-ultra-550b-a55bnvidia/nemotron-3-ultra-550b-a55b1M
GPT-OSS 20Bopenai/gpt-oss-20bopenai/gpt-oss-20b131K
Qwen 2.5 Coder 32Bqwen/qwen2.5-coder-32b-instruct131K

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 402 until you add credits or a plan.
  • Rate: no daily cap. Free models share 2,400 requests per minute per API key on Go and higher.
  • 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/free falls 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=3000000 raises Claude Code's timeout. The anyr launcher 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, 5 requests free, then Go or a donated key.

Open the setup page

FAQ

Can I run Claude Code on free models?

Yes. Install the anyr CLI with the setup script, then run anyr claude --model anyrouter/free. Free models bill $0 per token. A Free account gets a 5-request trial; after that free models need Go ($2 a month, or free when you donate one working provider key).

Are the free models as good as Claude?

No. They are other labs' models, and quality varies by model. Expect them to handle everyday edits and questions better than large multi-file refactors. Try two or three on your own repository.

Do free models have a daily limit on AnyRouter?

There is no daily cap. Free models share a limit of 2,400 requests per minute per API key. If a model is busy, anyrouter/free falls back to another free model.

Related posts