There are three ways to run Claude Code against something other than Anthropic's API, and I have now used all of them: point the environment variables at Ollama for local models, point them at OpenRouter for free cloud models, or put a proxy underneath Claude Code that can route to any backend and translate everything in flight. This post is about the third option, and my position up front: the proxy is the right choice only when you want multiple backends at once. If you just want one cheap backend, the env-var approaches are simpler and I have covered both.
What makes the proxy interesting is not "free" — it is routing. Once a translation layer sits between Claude Code and the model market, the tool's own model tiers become your cost-control switchboard. That is the feature the tutorials undersell, so it is the one I will spend the most time on.

What the Proxy Actually Does
Claude Code speaks Anthropic's Messages API. NVIDIA NIM speaks OpenAI-flavored JSON. OpenRouter has its own dialect. Ollama is close to OpenAI with quirks. The proxy — the specific project I run is Alishahryar1's free-claude-code — is a small local server that exposes Anthropic-compatible routes (/v1/messages and friends), accepts Claude Code's requests, translates them for whichever backend you configured, and translates the response back, streaming chunks, tool-use blocks, and usage metadata included. Claude Code never knows it left home.
The project supports six provider backends out of the box — NVIDIA NIM, OpenRouter, DeepSeek direct, Ollama, LM Studio, and llama.cpp — with more model backends (Groq, Cerebras, Z.ai, Kimi, Google AI Studio, Mistral) reachable through its configuration, plus a local admin UI at localhost:8082/admin so you are not hand-editing env files all day.
Two design points explain why this beats the bare env-var approach when you go multi-backend:
Error normalization. When a backend throws a rate-limit response in its own format, or returns a malformed tool-call block, or silently truncates a stream, raw Claude Code either chokes or spirals into confused retries. The proxy catches provider-specific failures and reshapes them into Anthropic-style errors Claude Code knows how to handle. This single layer is most of the difference between "works in a demo" and "survives an agentic session with forty tool calls."
Per-tier routing. You can map Claude Code's Opus, Sonnet, and Haiku traffic to different providers. That turns the model switcher you already use into a cost router: heavyweight tier to the strongest open-weight model, default tier to a cheap fast model, background tier to something nearly free. No orchestration code, no workflow change — the routing rides on a distinction Claude Code already makes internally.
The Three Backends, Honestly
I evaluate these from the machine I actually own — a MacBook Pro, M3 Pro, 18GB of unified memory — and from the position of someone who pays for a Max plan and burns it on client work. This stack is for everything that does not deserve paid tokens.
NVIDIA NIM: strongest free ceiling, slowest cadence
NVIDIA's build.nvidia.com gives NVIDIA Developer Program members free API access to a large hosted catalog — no credit card — with the free tier rate-limited at 40 requests per minute. The catalog includes serious open-weight models, including Z.ai's GLM coding models and NVIDIA's own Nemotron line. Quality per dollar is unbeatable because the dollar is zero.
The cost is cadence. Response latency on the bigger hosted models is noticeably above OpenRouter's, and in an agentic loop the seconds between tool calls compound into real minutes. My split: NIM for the sessions where output quality matters more than tempo, and note that 40 requests per minute is actually a friendlier agentic budget than OpenRouter's free-tier 20.
OpenRouter: the commodity market
One key, one endpoint, most of the model market behind it. The economics are the draw: DeepSeek V4 Flash currently lists around $0.08 per million input tokens and $0.16 per million output on OpenRouter, with DeepSeek V4 Pro at $0.435/$0.87. Anthropic's own Opus pricing is $5/$25 per million. That is not a discount; it is a different order of magnitude. Five dollars of OpenRouter credit funds weeks of side-project iteration, and the deposit also unlocks the higher daily cap on the genuinely free models — mechanics I covered in detail in my OpenRouter free-models setup.
For throwaway builds and boilerplate, cheap-and-fast wins over free-and-slow, which is why OpenRouter is my default backend in the proxy.
Ollama: private, local, and hardware-honest
Ollama is the only option where your code never leaves the machine, which makes it the only option for NDA-bound experiments. Everything else about it is a hardware negotiation. On 18GB of unified memory, my ceiling is roughly 20B-parameter models, the sweet spot is 7B-14B coders, and multi-file agentic work is where local models fall apart first — I mapped that boundary properly in my two-week local Ollama trial. Through the proxy, Ollama becomes one more routing target rather than a separate setup, which is the main thing the proxy adds here: local for the private tier, cloud for the rest, one config.
Setup in Four Steps
Assuming Claude Code is already installed:
# 1. clone and enter
git clone https://github.com/Alishahryar1/free-claude-code.git
cd free-claude-code
# 2. create your config
cp .env.example .env
Fill in .env with a provider and key — an OpenRouter starting point looks like:
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your-key
OPENROUTER_MODEL=deepseek/deepseek-v4-flash
PORT=8082
Then run the proxy (the repo uses uv, the fast Python package manager), and point Claude Code at it:
export ANTHROPIC_BASE_URL=http://localhost:8082
export ANTHROPIC_AUTH_TOKEN=proxy
claude
Run /status inside the session and confirm the endpoint is your localhost proxy before trusting anything. The failure mode worth respecting is the silent one: if cached Anthropic credentials or an old OAuth token win the precedence fight, your "free" session bills your Anthropic account without a single error message. /logout once, blank ANTHROPIC_API_KEY, verify with /status. I treat that check as a hard gate, not a nicety.
Switching backends afterward is editing PROVIDER and restarting the proxy — Claude Code itself does not need to restart.
The Orchestration Pattern That Makes This Worth It
Here is where the proxy earns its complexity over the single-backend setups. My working pattern on cost-sensitive days: the planning and integration work runs on my paid Anthropic subscription, and the execution work — test files, boilerplate, mechanical refactors, doc updates — runs through the proxy on a cheap model. Sometimes that is two sessions side by side; increasingly it is per-tier routing doing the same thing inside one session, with the expensive tier reserved for the calls where judgment actually lives.
The economics of this split are the entire point. An agentic workday is mostly execution tokens, not judgment tokens. Moving the execution majority to a backend that costs cents per million tokens while keeping judgment on Opus changes the shape of the bill without changing the shape of the work. It is the same tier-matching principle from my AI agent cost optimization guide, implemented in one config file.
Where It Cracks
The honest list, from use rather than from the README:
- Cheap models degrade with session length. Deep into a long session, budget models start losing earlier decisions and hallucinating their own function signatures. The fix is mechanical — restart with fresh context, reload the relevant files — but you have to notice it happening, and the symptom (confident self-contradiction) is easy to miss mid-flow. Context hygiene matters more on cheap backends, not less; my token management habits apply doubly here.
- The hard 20 percent stays hard. Concurrency reasoning, security-sensitive changes, refactors that touch many files: the quality gap versus frontier Claude is real and shows up exactly where mistakes are most expensive. Route accordingly.
- Privacy is a routing decision now. Through OpenRouter or NIM, your prompts and code transit another company's infrastructure. For client work, that is a conversation with the client, not a default. Local Ollama or Anthropic-direct for anything sensitive — there is no middle ground worth defending.
- Model IDs and prices move monthly. The specific numbers in this post were checked in August 2026; check the catalogs before pinning anything in
.env, and expect to revisit the config every few weeks.
The proxy has not replaced my Max plan and was never going to — client work stays on the reliable, accountable path. What it replaced is the quiet self-censorship around experiments. When iteration costs cents, you run the third and fourth attempt you would otherwise have skipped, and some of those attempts are where the good ideas were hiding.
Routing is a skill you learn once and reuse across every agent tool you ever adopt, which is why it sits early in the curriculum at my AI School, next to context hygiene and tier-matching. Learn it there in sequence, or piece it together from posts like this one — both routes work, one takes considerably longer.