Use Claude Code with free models through Ficelle
Point Claude Code at Ficelle with two environment variables: Sonnet requests route to free coding models. Setup, model mapping and limits.
Status
Supported and tested. Ficelle serves the Anthropic Messages API that Claude Code speaks. A Ficelle smoke test on 8 September 2026 ran Claude Code 2.1.259 against a simulated provider: a multi-turn streaming session with a real Bash tool call.
Read this first. Anthropic states in its gateway documentation that it does not support Claude Code when a gateway routes it to models that are not Claude. Ficelle routes to free models from other developers, so this setup sits outside what Anthropic supports, and some Claude Code features can behave differently than on Claude.
Set up Claude Code
-
Set the two environment variables
Claude Code reads its gateway from
ANTHROPIC_BASE_URL. Use the root of the Ficelle listener, without /v1: Claude Code adds/v1/messagesitself. Anthropic recommendsANTHROPIC_AUTH_TOKENfor the credential; on the default local listener Ficelle accepts any value.shell export ANTHROPIC_BASE_URL="http://127.0.0.1:8646" export ANTHROPIC_AUTH_TOKEN="ficelle-local" claude -
Sign out of claude.ai if you were signed in
Anthropic's gateway guide advises running
/logoutin Claude Code when a claude.ai login is saved, then starting it again with the variables set. -
Confirm the gateway is active
Run
/statusin Claude Code. It should show an "Anthropic base URL" line with the Ficelle address. If the line is missing, the variables did not reach the Claude Code process. -
Know which profile answers
Ficelle maps Claude model names to its own routing profiles by default: Haiku to
ficelle/auto-fast, Sonnet and Claude Code's generic route toficelle/auto-coding, Opus and Fable toficelle/auto-orchestrator. Change it withanthropic_model_mappingin~/.ficelle/config.json; the engine recipe documents the format.
Check it works
This checks Ficelle's Chat Completions endpoint with ficelle/auto-fast.
A successful response confirms that route works, but does not verify the profile or
protocol Claude Code uses. If the client still fails, check its error and the limits below
as well as its configuration.
curl -s http://127.0.0.1:8646/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"ficelle/auto-fast","messages":[{"role":"user","content":"Reply exactly: ficelle-ok"}],"temperature":0}'
Limits to know
- Responses name the Ficelle profile that answered, and the
X-Ficelle-Modelheader names the real model. Ficelle never presents a free model as Claude. cache_controland thinking blocks are accepted, ignored, and listed in theX-Ficelle-Dropped-Paramsresponse header.- Ficelle does not serve
/v1/messages/count_tokens. Anthropic documents that Claude Code then falls back to a character-based estimate, so the figures in/contextare approximate. ficelle/auto-codingonly routes to certified coding models and can answer503 no_certified_coding_modelwhen none is available on your install, while other profiles still work.ANTHROPIC_API_KEYworks too, but an interactive session asks you to approve it once.
Troubleshooting
- On a listener that is not local, Ficelle requires the token from
ficelle access-token api: put it inANTHROPIC_AUTH_TOKEN(sent asAuthorization: Bearer). - A base URL that ends in
/v1produces/v1/v1/messages: remove the suffix.
Questions
Can Claude Code use free models?
Yes, through a gateway that serves the Anthropic Messages API. Ficelle is one: set ANTHROPIC_BASE_URL to the local Ficelle address and Claude Code's requests route to free models from the providers you configure. Anthropic does not support Claude Code on models that are not Claude, so expect differences.
Does Ficelle pretend free models are Claude?
No. Each response names the Ficelle profile that answered and the X-Ficelle-Model header names the real model. The Claude model name in the request only selects a routing profile.
Which free model answers a Sonnet request?
By default a Sonnet request goes to ficelle/auto-coding, which picks among certified free coding models on your install. Haiku goes to ficelle/auto-fast and Opus to ficelle/auto-orchestrator. The anthropic_model_mapping setting changes this.
Why is the context usage in Claude Code approximate?
Ficelle does not serve the token-counting endpoint, so Claude Code estimates tokens from characters, as Anthropic documents for gateways without it.
Sources
Official pages and the Ficelle recipe this guide rests on, read on 11 November 2026: