❝ Nico

Notes

How do I use Claude Code with a local model on an Apple silicon Mac?

Two environment variables and a model pull. The exact setup, the context length people get wrong, and what still reaches the network afterwards.

Four commands. Install Ollama 0.14 or later, which speaks the Anthropic Messages API; pull a model that can call tools; set ANTHROPIC_BASE_URL to http://localhost:11434 and ANTHROPIC_AUTH_TOKEN to ollama; run claude --model gpt-oss:20b. The part people get wrong is context length: run a model with at least 32K.

The setup

  1. Install or update Ollama. "Ollama v0.14.0 and later are now compatible with the Anthropic Messages API", which is the whole reason this works without a proxy in between.
  2. Pull a model that can call tools. ollama pull gpt-oss:20b or ollama pull qwen3-coder — both named in Ollama's own instructions for this. A model that cannot call tools will talk to you fluently and never edit a file.
  3. Point Claude Code at it.
    export ANTHROPIC_AUTH_TOKEN=ollama
    export ANTHROPIC_BASE_URL=http://localhost:11434
  4. Name the model when you start. claude --model gpt-oss:20b.
  5. Raise the context length. Ollama's recommendation is "at least 32K tokens context length". A coding agent spends context on file contents and tool results before it spends any on you, and an 8K window is why a local setup appears to forget the file it just read.

What you are trading

Hosted modelLocal model
Where the file contents goOver the network, inside the promptNowhere
Token costYour subscription or API spendNone
Works with the network unpluggedNoYes
Limited byRate limits and planYour unified memory
Tool callingReliableDepends entirely on the model

Memory is the real constraint and the one worth checking before you start. Each model's page on ollama.com lists its download size; budget for that plus whatever the rest of the Mac is already holding. A model that does not fit swaps, and a swapping agent is unusable rather than slow.

Ollama's cloud models are not this

The same instructions mention glm-4.7:cloud and minimax-m2.1:cloud, which run on Ollama's machines rather than yours. They are a reasonable way to get a bigger model and the exact opposite of the reason most people do this. If the point is that the file contents stay on the Mac, the model has to be one you pulled.

Local model is not the same as offline

The prompts stop at localhost, but Claude Code itself still makes a few requests of its own. Its documentation names them: usage metrics, which "never include your code, prompts, or file paths"; error reports with secrets and paths redacted; and a WebFetch check that sends the requested hostname — "not the full URL, path, or page contents" — to api.anthropic.com. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC turns off the non-essential ones in a single setting, and the WebFetch check has its own switch, skipWebFetchPreflight.

Nico runs all three — the Claude Code and Codex already on your Mac, and Ollama — because which one a job deserves is not a decision you make once. Unplug the network and the local ones keep working.

← All notes