Run Claude Code on a Fully Local Model — in 5 Minutes
Point Anthropic's Claude Code at a model running on your own Mac. No cloud, no per-token bill, and your code never leaves the machine. It's two environment variables — here's the whole thing.
Claude Code is a great agent. But every keystroke, every file it reads, every tool call goes to the cloud — and gets billed per token. For a lot of work — refactors, codebase Q&A, editing files you'd rather not upload — you don't need a frontier model in a datacenter. You need a capable model on your desk.
Here's why the swap is worth it:
- Your code stays on the Mac. Nothing is uploaded — works on a plane, behind an air-gap, or on a repo you're not allowed to send anywhere.
- No meter running. Once the model is on disk, an all-day agent session costs exactly nothing.
- It actually works — not a hack. rapid-mlx speaks Claude Code's native wire (
/v1/messages) and ships guaranteed-parseable tool calling, so the agent's edits and tool calls land instead of flailing. More on that below.
The whole setup is about five minutes, most of which is a model download. You'll need an Apple Silicon Mac (M1 or newer).
Before you start
You need Claude Code itself. If you don't have the CLI yet:
npm install -g @anthropic-ai/claude-code
1 · Install rapid-mlx
rapid-mlx is a local, OpenAI- and Anthropic-compatible inference server for Apple Silicon. It's in Homebrew core:
brew install rapid-mlx
Prefer not to use Homebrew? curl -fsSL https://rapidmlx.com/install.sh | bash does the same — no sudo, self-contained.
2 · Serve a model that fits your Mac
Pick a model sized to your RAM and start the server. A solid default for coding is Qwen 3.6:
rapid-mlx serve qwen3.6-35b-4bit
First run downloads the weights (cached after that). The server comes up at http://localhost:8000 with both OpenAI and Anthropic routes.
| Your Mac | Model | Good for |
|---|---|---|
| 16 GB | qwen3.5-4b |
Fast edits, Q&A |
| 32 GB | gpt-oss-20b |
All-round + strong tools |
| 48 GB+ | qwen3.6-35b-4bit |
The coding sweet spot |
No tool flags needed. Since 0.10.14, serve auto-configures the tool-call parser from the model's profile and turns on grammar-constrained tool calling by default — so tool calls come back guaranteed-parseable, with nothing to configure. (On builds older than 0.10.14, add --tool-call-parser qwen3_coder_xml --enable-auto-tool-choice.)
3 · Point Claude Code at it
Claude Code honors the ANTHROPIC_BASE_URL environment variable. Set it to your local server and launch — that's the whole integration:
export ANTHROPIC_BASE_URL=http://localhost:8000 export ANTHROPIC_API_KEY=not-needed claude
The base URL is the root, not …/v1 — the Anthropic SDK appends /v1/messages itself. http://localhost:8000/v1 would POST to /v1/v1/messages and 404.
4 · Do something real
You're now running a fully local agent. Point it at a repo and give it a task:
# inside any project claude > add a --dry-run flag to scripts/deploy.py and update the README
It reads your files, plans, and edits — all on your machine. Pull the network cable; it keeps working.
Why it just works (and where it doesn't)
Two things make this a real integration rather than a duct-tape proxy:
- Native Anthropic wire. Claude Code speaks
/v1/messages, not OpenAI's format. rapid-mlx serves that as a first-class route, so it's an env-var flip — no shim, no translation layer to break. - Guaranteed-parseable tool calls. Tool-call output is constrained by a grammar at generation time, so the model can't emit a malformed call. That's the difference between an agent that edits your files and one that stalls on a broken tool block. (Verified on rapid-mlx 0.10.15: a bare
serveplus an Anthropic/v1/messagesrequest with a tool returns a propertool_useblock.)
Honest expectations. A 35B model on your Mac is not Claude Opus, and pretending otherwise helps no one. Where local shines: private and offline work, codebase Q&A, straightforward edits and refactors, and never watching a bill. Where the cloud still wins: the hardest multi-step reasoning and the largest context.
The good news — you don't have to choose. Flip the two environment variables off and Claude Code is back on the cloud model. Local for the 80%, cloud for the hard 20%.
Where to go next
- Full Claude Code guide — SDK snippet, tool schemas, and every gotcha.
- Integration matrix — 11 agents across the four Tier-1 families, tested.
- Install rapid-mlx — Homebrew or one curl. Apache 2.0.
- Browse models — pick one that fits your RAM.
Using Cursor, Codex CLI, or Aider instead? Same idea — each has a one-page guide in the docs.
pip install rapid-mlx,
then rapid-mlx serve <alias>. Browse every supported
model on the family docs or pick one by your
Mac's RAM at models.rapidmlx.com.