Guide

How to use Claude Code for free

Claude Code is a coding agent from Anthropic. It needs an Anthropic Messages API. This guide shows how to connect Claude Code to free models through FreeLLMAPI. You set two environment variables. You do not need an Anthropic key.

What you get and what you do not get

Claude Code sends each request to an API in Anthropic's format. FreeLLMAPI speaks that format on /v1/messages. It translates each request and sends it to a free model, for example Gemini, GPT-OSS, Qwen or GLM.

  • You get: the Claude Code interface, its tools, file edits and agent loop, on free models.
  • You do not get: Anthropic's Claude models. No provider gives the Claude models free through an API. Read Is there a free Claude API? for the details.
  • Cost: $0 for inference. The free tiers have rate limits. FreeLLMAPI moves to the next provider when one limit stops a request.

Step 1: Install FreeLLMAPI

FreeLLMAPI is open source. It runs on your computer in Docker. Your provider keys stay on your computer.

macOS or Linux

curl -fsSL https://freellmapi.co/install.sh | bash

Open the dashboard at http://localhost:3001. Add at least two free provider keys on the Keys page. Google AI Studio and Groq each give a free key in about one minute. Copy your unified key from the same page.

Step 2: Connect Claude Code

The fastest method is the setup command. It reads your live catalog, makes a backup of ~/.claude/settings.json and adds the gateway settings.

One command

npx freellmapi setup-claude --url http://localhost:3001 --api-key <unified-key>

To set it up manually, set two environment variables and start Claude Code:

Manual setup (macOS or Linux)

export ANTHROPIC_BASE_URL=http://localhost:3001
export ANTHROPIC_AUTH_TOKEN=<unified-key>
claude

Manual setup (Windows PowerShell)

$env:ANTHROPIC_BASE_URL="http://localhost:3001"
$env:ANTHROPIC_AUTH_TOKEN="<unified-key>"
claude
Important: use ANTHROPIC_AUTH_TOKEN. Do not use ANTHROPIC_API_KEY. If ANTHROPIC_API_KEY is set, Claude Code sees a conflicting credential and does not start.

To make sure that the requests go to the gateway, run npx freellmapi doctor. Each response also has an X-Routed-Via header. This header shows the provider and model that answered.

Step 3: Choose models for agent work

Claude Code sends long prompts. A typical request has a large system prompt, tool definitions and file contents. Use models with tool calling and a large context window. Small free tiers with low tokens per minute fail on these requests.

On the Keys, Anthropic tab, map each Claude family (opus, sonnet, haiku) to auto or to a model. With auto, the router selects a free model for each request. The table shows free models with tool calling and at least 128K context, from today's catalog.

Free models for Claude Code: tool calling and 128K+ context
ModelFree onContextFree limits (best offer)ToolsVision
GLM 5.3UnoRouter1M1 req/min
1 req/min per model
YesNo
GLM 5.3 FlashNVIDIA NIM, UnoRouter1M40 req/min
40 RPM
YesYes
Gemini 3.8 FlashGoogle AI Studio1MRecurring provider quotaYesYes
Qwen3.8 Flash NextAMD Radeon Cloud262KRecurring daily account allowanceYesNo
Qwen3.8 FlashElectronHub1M$0.25/week shared recurring creditYesYes
Gemini 3.7 FlashGoogle AI Studio1M10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
GPT-5.6 LunaElectronHub1M$0.25/week shared recurring creditYesYes
Dots3 Note PreviewKilo Gateway, OpenRouter512K20 req/min
50 req/day
50 req/day account-wide (1,000 after a $10 purchase)
YesYes
DeepSeek V4 FlashAMD Radeon Cloud, BazaarLink, ElectronHub1M10 req/min
50 req/day
Shared rate limit
YesNo
Qwen3.8 27BElectronHub, Groq, OVH AI Endpoints262K30 req/min
250 req/day
70,000 tokens/min
~6M
YesYes
Gemini 3.6 FlashGoogle AI Studio1M10 req/min
20 req/day
250,000 tokens/min
~3M
YesYes
Qwen 3.8 27BCloudflare Workers AI262KShared 10k neurons/dayYesYes

Showing 12 of 109 matching free models. See all models.

Live data from the FreeLLMAPI catalog (version 2026.11.19, checked 19 November 2026). Free limits change often. The catalog is checked every day.

Rate limits and how failover helps

One Claude Code task can send 20 to 100 requests. A single free tier stops you fast. For example, a free Gemini Flash key allows few requests per day. FreeLLMAPI keeps a count of each key's quota. When a provider sends a 429 error, the router tries the next provider in the pool. Your Claude Code session continues.

  • Add keys from four or more providers. More keys give more requests per day.
  • Map haiku to a fast small model. Claude Code uses it for short background tasks.
  • Keep the context small. Use /clear between tasks to send fewer tokens.

Troubleshooting

ProblemCauseFix
Claude Code asks you to log inThe environment variables are not set in this shellSet ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, then start claude again
"Conflicting credential" or no startANTHROPIC_API_KEY is setRemove it with unset ANTHROPIC_API_KEY
Error 429 on every requestAll your provider keys are at their limitAdd keys from more providers on the Keys page
Tool calls fail or the agent stopsThe model does not support tool calling wellMap the family to a model from the table above
Requests are slowLarge prompts on a slow free modelPin a fast model, for example a Groq or Cerebras model
Use every one of these through one key. FreeLLMAPI is an open-source, self-hosted router that puts all these free tiers behind a single OpenAI-compatible endpoint and fails over when one is rate-limited. Browse the catalog or go live.

Frequently asked questions

Is Claude Code free to use?

The Claude Code program is free to install. It needs a model API to work. With FreeLLMAPI, it uses free provider tiers, so inference costs $0.

Do I get the real Claude models for free?

No. Anthropic does not give a free Claude API. Claude Code runs on other free models, for example Gemini, GPT-OSS, Qwen or GLM, through the Anthropic-format endpoint.

Why use ANTHROPIC_AUTH_TOKEN and not ANTHROPIC_API_KEY?

Claude Code sends ANTHROPIC_AUTH_TOKEN as a Bearer token to your gateway. If ANTHROPIC_API_KEY is set, Claude Code treats it as a first-party credential and refuses to start.

Which free model is best for Claude Code?

Use a model with tool calling and a context window of 128K tokens or more. The table on this page shows the strongest free models that meet both rules today.

Does this work on Windows?

Yes. Set the two variables in PowerShell with $env:ANTHROPIC_BASE_URL and $env:ANTHROPIC_AUTH_TOKEN, then start claude.

Sources

All guides · Browse all free models

Keep reading

All posts →
Guide

Best free LLM APIs 2026

Ten genuinely free LLM APIs worth using — ranked, with real limits.

Guide

Unlimited free AI tokens?

No free AI API is unlimited. The closest real thing: 10.1 billion free tokens a month behind one key.

Guide

How to get a free LLM API key

Get a working key in minutes — no credit card required.