Run Claude Code with a Local Model on a Mac

Claude Code, with the model running on your own Mac. Rapid-MLX speaks the Anthropic Messages API Claude Code uses, so it's a base URL, not a bridge.

Claude Code is a great agent, but every file it reads and every tool call goes to the cloud and is billed per token. For a lot of everyday work (refactors, questions about a codebase, edits to code you'd rather not upload) a capable model on your own Mac does the job.

The whole thing

  1. Install Rapid-MLX and serve a model.
  2. rapid-mlx agents claude-code --setup, or export two environment variables.
  3. claude in your project.

1 · Install Rapid-MLX and Claude Code

curl -fsSL https://rapidmlx.com/install.sh | bash
npm install -g @anthropic-ai/claude-code

Rapid-MLX is also in Homebrew core: brew install rapid-mlx.

2 · Serve a model

rapid-mlx serve qwen3.5-4b-4bit

That's the engine's pick for a 16 GB Mac and the model we verified with. On a bigger Mac, rapid-mlx recipe prints a stronger pick: qwen3.8-27b-4bit from 32 GB, or qwen3.6-35b-4bit from 48 GB when speed matters. Best local LLMs by Mac shows how fast each runs on your exact chip. The server listens on http://localhost:8000 with both OpenAI and Anthropic routes; keep it running.

3 · Point Claude Code at it

The setup command writes the connection into Claude Code's own settings file, after showing you the change:

rapid-mlx agents claude-code --setup

It adds an env block to ~/.claude/settings.json with ANTHROPIC_BASE_URL, a placeholder key, the served model and its context window, and backs up the existing file first.

Prefer not to touch the settings file? Two environment variables do the same for one shell:

export ANTHROPIC_BASE_URL=http://localhost:8000
export ANTHROPIC_API_KEY=not-needed

The base URL is the server root, not …/v1. The Anthropic client adds /v1/messages itself, so http://localhost:8000/v1 would request /v1/v1/messages and fail.

4 · Run it

Start claude in a project as usual, or give it one task from the shell:

# inside your project folder
claude -p "Add a function add(a, b) to hello.py that returns a + b. Edit the file." \
  --allowedTools Read Edit Write

From our run:

I've added the `add(a, b)` function to `hello.py` that returns `a + b`.

Verified on 2026-10-06 with rapid-mlx 0.15.6, Claude Code 2.1.291 and qwen3.5-4b-4bit on a Mac mini (M2 Pro, 32 GB). Both routes, agents claude-code --setup and the two environment variables alone, edited the file through Claude Code's own tools in about a minute. Most of that minute is the model reading Claude Code's large system prompt and tool list.

Claude Code may print a notice that auto mode's classifier requests can't use a new billing path through a custom base URL. It's informational: nothing breaks.

What to expect

A model on your Mac isn't Claude Opus. Local shines for private work, codebase questions, and straightforward edits and refactors. The hardest multi-step reasoning and the longest contexts are still the cloud's strength. You don't have to choose: unset the two variables (or remove the env block) and Claude Code is back on Anthropic's models.

Frequently asked questions

Can Claude Code use a local model?

Yes. Claude Code reads ANTHROPIC_BASE_URL. Point it at a Rapid-MLX server (http://localhost:8000), which serves the Anthropic Messages API, and Claude Code runs on the model on your Mac. rapid-mlx agents claude-code --setup writes this into Claude Code's settings for you. Rapid-MLX itself sends anonymous usage counts by default, never prompts or code; rapid-mlx telemetry off turns that off (details).

Why doesn't ANTHROPIC_BASE_URL end in /v1?

The Anthropic client appends /v1/messages to the base URL itself. Use the server root, http://localhost:8000.

Which local model is best for Claude Code on a Mac?

Use the largest model rapid-mlx recipe suggests for your memory: qwen3.8-27b-4bit from 32 GB, qwen3.6-35b-4bit from 48 GB for speed. Tool calling quality matters more than raw speed for an agent.

Where to go next


Run this yourself. Rapid-MLX is an open-source, OpenAI- and Anthropic-compatible inference server for Apple Silicon. One command installs it, then rapid-mlx serve <alias> serves any model on localhost:8000/v1.
curl -fsSL https://rapidmlx.com/install.sh | bash

New models and speedups, in your inbox

A short note whenever Rapid-MLX gets faster or adds models worth running on your Mac. No spam — unsubscribe anytime.