# 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 with no card, then Go ($2 a month, or free with one donated key). Exact commands, the manual setup, which models to try, and the limits.

- Date: October 16, 2026
- Category: guides
- HTML: https://anyrouter.dev/blog/claude-code-free-models

## The two lines

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

```bash
curl -fsSL https://anyrouter.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](https://anyrouter.dev/claude-code) page, and the signed-in version, with your own key filled in, is at [/welcome#claude-code](https://anyrouter.dev/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:

```bash
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](https://anyrouter.dev/dashboard/keys) (every key starts with `sk-ar-`), then:

```bash
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](https://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.

| Model | Id | Context |
| --- | --- | --- |
| [LongCat-2.5](https://anyrouter.dev/model/meituan/longcat-2.5) | `meituan/longcat-2.5` | 1M |
| [Beam 1.0](https://anyrouter.dev/model/reflection/beam-1.0) | `reflection/beam-1.0` | 1M |
| [Glyph Cluster](https://anyrouter.dev/model/stealth/glyph-cluster) | `stealth/glyph-cluster` | 256K |
| [Dots3-Note Preview](https://anyrouter.dev/model/dots-studio/dots-3-note-preview) | `dots-studio/dots-3-note-preview` | 512K |
| [Nemotron 3.5 Lightning 30B A3B](https://anyrouter.dev/model/nvidia/nemotron-3.5-lightning-30b-a3b) | `nvidia/nemotron-3.5-lightning-30b-a3b` | 1M |
| [Qwen3-8B](https://anyrouter.dev/model/qwen/qwen3-8b) | `qwen/qwen3-8b` | 128K |
| [North Mini Code](https://anyrouter.dev/model/cohere/north-mini-code) | `cohere/north-mini-code` | 256K |
| [Nemotron 3 Ultra 550B](https://anyrouter.dev/model/nvidia/nemotron-3-ultra-550b-a55b) | `nvidia/nemotron-3-ultra-550b-a55b` | 1M |
| [GPT-OSS 20B](https://anyrouter.dev/model/openai/gpt-oss-20b) | `openai/gpt-oss-20b` | 131K |
| [Qwen 2.5 Coder 32B](https://anyrouter.dev/model/qwen/qwen2.5-coder-32b-instruct) | `qwen/qwen2.5-coder-32b-instruct` | 131K |

Pass any id to `--model` to pin it. The full, current list is at [/free](https://anyrouter.dev/free). To see only models that speak the Messages API Claude Code uses, filter the [model list](https://anyrouter.dev/models?endpoint=messages).

## 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](https://anyrouter.dev/dashboard/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](/blog/anyrouter-vs-openrouter) for a sourced comparison and the migration steps.

Free models in Claude Code: two lines, 5 requests free with no card, then Go.

[Open the setup page](https://anyrouter.dev/claude-code)
