Which agent talks to which local server

The three agents speak two different APIs. Claude Code sends Anthropic Messages requests (POST /v1/messages); OpenCode and Codex CLI send OpenAI-style requests (Codex uses the Responses API). Ollama, LM Studio and oMLX each serve both styles on your Mac, so any agent can reach any of the three servers:

AgentAPI it callsQuickest setupManual setup
Claude CodeAnthropic Messagesollama launch claudeANTHROPIC_BASE_URL → Ollama :11434, LM Studio :1234 or oMLX :8000
OpenCodeOpenAI-compatibleollama launch opencodenone on the same Mac: OpenCode finds Ollama and LM Studio itself
Codex CLIOpenAI Responsesollama launch codex or omlx launch codexcodex --oss --local-provider ollama (or lmstudio)

The servers’ own pages: Ollama’s Anthropic compatibility and integrations, LM Studio’s Claude Code guide (its /v1/messages endpoint arrived in 0.4.1), and the oMLX README, which lists /v1/chat/completions, /v1/messages and /v1/models on port 8000. All three install from the Mac LLM apps page.

Step 1: serve the model with a 64K context

Most failures with a local agent are a context window that is too small, not a model that is too weak. The agent’s system prompt and tool definitions alone fill a large part of a small window before your code arrives, and once the conversation outgrows the window the server truncates the prompt or refuses it, depending on the runtime. Ollama’s documentation says agents and coding tools “should be set to at least 64000 tokens”, and its OpenCode and Codex pages ask for 64K as well. LM Studio’s Claude Code guide asks for more than about 25K, a floor rather than a target.

Ollama picks a default from GPU memory: 4K below 24 GiB, 32K from 24 to 48 GiB, and 256K from 48 GiB. On most 16–32 GB Macs that is below 64K, so set it yourself:

# Ollama: for the whole server (or move the context slider in the Ollama app's settings)
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
ollama ps                      # the CONTEXT column shows what each loaded model got

# LM Studio: per model, when you load it
lms load <model_key> --context-length 65536
lms server start --port 1234

# oMLX: serves on port 8000 and reports each model's real context window to Claude Code (so it compacts in time)

A longer context needs more memory, which the table below works out per model. An 8-bit KV cache halves that extra memory (Ollama: OLLAMA_KV_CACHE_TYPE=q8_0, for GGUF models on its llama.cpp engine only — its MLX engine never reads it; llama.cpp: -ctk q8_0 -ctv q8_0). Go no lower for agent work: llama.cpp’s function-calling notes warn that extreme KV quantizations such as q4_0 “can substantially degrade the model’s tool calling performance”.

Claude Code with a local model

Ollama can install the settings and start Claude Code in one step; ollama launch claude --model <tag> --yes does the same without prompts. By hand, Claude Code needs three environment variables pointed at the local server. The values below are the ones in Ollama’s and LM Studio’s guides; the token is a placeholder the server ignores unless you turned authentication on:

# Ollama (port 11434)
ollama launch claude
# or by hand:
export ANTHROPIC_BASE_URL=http://localhost:11434
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
claude --model qwen3.6:35b-a3b

# LM Studio (port 1234)
lms server start --port 1234
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model openai/gpt-oss-20b

# oMLX (port 8000)
export ANTHROPIC_BASE_URL=http://localhost:8000
export ANTHROPIC_AUTH_TOKEN=omlx   # or your oMLX API key; without a token a saved claude.ai login stays active
claude --model <a model id from http://localhost:8000/v1/models>

Four settings from Claude Code’s environment-variable reference matter with a local server:

What does not carry over: Ollama’s Anthropic layer does not support prompt caching (cache_control), tool_choice or the token-counting endpoint, and accepts but does not enforce a thinking budget. Claude Code’s permission prompts work exactly as with Anthropic’s API, since they run in the client. If a session still reaches the cloud, settings files can override shell variables: run /status to see which apply.

OpenCode with a local model

OpenCode needs the least setup. Its provider documentation says it probes Ollama at http://127.0.0.1:11434 and LM Studio at http://127.0.0.1:1234/v1, and lists the models it finds under /models with no account or config file. Ollama’s launcher writes an inline config for the model you pick and leaves your opencode.json alone:

curl -fsSL https://opencode.ai/install | bash
ollama launch opencode          # or: ollama launch opencode --config (configure, don't start)
# or start Ollama / LM Studio yourself, run opencode, then pick the model with /models
opencode

A server on another Mac (a Mac Studio across the room, say) needs only its address, with /v1 on the end:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "ollama": { "settings": { "baseURL": "http://studio.local:11434/v1" } }
  }
}

The 64K context still has to be set on the server, as in Step 1: OpenCode’s page on Ollama’s site says it “requires a context length of 64k or higher”.

Codex CLI with a local model

Codex has a built-in switch for local models. Its command reference describes --oss as using “a local open source model provider”, with --local-provider choosing lmstudio or ollama for one run; without it Codex uses oss_provider from config.toml, and asks only when neither is set.

npm install -g @openai/codex

ollama launch codex                      # writes an Ollama profile and starts Codex
codex --oss --local-provider ollama -m gpt-oss:20b   # Ollama, a model you have pulled
codex --oss --local-provider lmstudio    # LM Studio
omlx launch codex                        # oMLX: needs Codex 0.148 or newer

The profile Ollama writes talks to http://localhost:11434/v1/ over the Responses API (wire_api = "responses"), and inside Codex /model switches between your installed tool-capable models. Ollama’s Codex page asks for a context window of at least 64K here too, and notes that in its profile, web-search requests go to Ollama’s service; -c 'web_search="disabled"' turns that off for a session.

Which models are agent-ready at 64K, on which Mac

The index’s agent-ready rule: a model is agent-ready at 64K on a Mac when its context window is at least 64K tokens and its RAM at 65,536 tokens with a 16-bit KV cache is no more than the Mac’s memory. That RAM is the index’s minimum, which already covers about the first 4K tokens of context, plus the cache for the rest. The cache comes from the model’s own config.json: two vectors (a key and a value) per KV head, per full-attention layer, per token. Sliding-window layers stop growing at their window, and the linear-attention and convolution layers of the newer hybrids keep a fixed-size state, which is why a 35B mixture-of-experts model can need less cache than a dense 27B. The methodology has the formula.

ModelMin RAMKV cache at 64KRAM at 64KSmallest MacDecode on that MacArchitecture
GPT-oss 20B13 GB1.6 GB15 GB (14 with 8-bit KV)16 GBestimated~41 tok/s Mac mini M6 16 GB24 layers, half of them sliding-window (128 tokens); 8 KV heads × 64 (config.json)
LFM2.5-24B-A2B17 GB1.3 GB19 GB (18 with 8-bit KV)24 GBcommunity114 tok/s Mac mini M5 Pro 24 GB40 layers: 10 attention, 30 convolution (no cache); 8 KV heads × 64 (config.json)
Recursive Flint20 GB1.9 GB22 GB (21 with 8-bit KV)24 GBcommunity92 tok/s Mac mini M5 Pro 24 GB49 layers: 14 full, 35 sliding-window (513 tokens); 4 KV heads × 128 (config.json)
North Mini Code 1.021 GB2.0 GB23 GB (22 with 8-bit KV)24 GBcommunity70 tok/s Mac mini M5 Pro 24 GB49 layers: 13 full, 36 sliding-window (4,096 tokens); 4 KV heads × 128 (config.json)
Qwen3.8-27B19 GB4.3 GB24 GB (22 with 8-bit KV)24 GB (tight)sourced17 tok/s Mac mini M5 Pro 24 GBdense; 64 layers: 16 full attention, 48 linear attention (fixed state); 4 KV heads × 256 (config.json)
Qwen 3.6-35B-A3B24 GB1.3 GB26 GB (25 with 8-bit KV)32 GBcommunity59 tok/s Mac mini M6 32 GB40 layers: 10 full, 30 linear attention; 2 KV heads × 256 (config.json)
Qwen3-Coder-Next48 GB1.6 GB50 GB (49 with 8-bit KV)64 GBestimated~49 tok/s Mac mini M5 Pro 64 GB48 layers: 12 full, 36 linear attention; 2 KV heads × 256 (config.json)
GPT-oss 120B62 GB2.4 GB65 GB (64 with 8-bit KV)96–128 GB (64 GB with an 8-bit cache)community92 tok/s Mac Studio M5 Max 128 GB36 layers, half sliding-window (128 tokens); 8 KV heads × 64 (config.json)
Qwen3.8-Flash-Next120 GB1.6 GB122 GB (121 with 8-bit KV)128 GBcommunity47 tok/s Mac Studio M5 Max 128 GB48 layers: 12 full, 36 linear attention; 2 KV heads × 256 (config.json)

Min RAM, the KV cache and RAM at 64K are estimated: arithmetic on each model’s published architecture (GB = 109 bytes), not a reading of any Mac’s memory. RAM at 64K is rounded up to a whole gigabyte, as on the leaderboard’s RAM @64K column. Min RAM is the index’s figure on 18 November 2026; the decode column is filled from the index on every build, at a short prompt.

Provenance key
sourced
Published figure — vendor or press review
estimated
community
Linked individual run — blog, forum or submission

Three things the table does not show. First, the “tight” row leaves under about 1 GB spare, and macOS lets the GPU use only part of unified memory by default (methodology, Step 1), so on a 24 GB Mac Qwen3.8-27B needs an 8-bit cache, a shorter context or a higher iogpu.wired_limit_mb; North Mini Code 1.0 leaves about 1.4 GB. Second, the runtime’s own buffers grow with context too. Third, GLM-4.7-Flash is left out on purpose: it uses multi-head latent attention, whose cache is about 3.5 GB at 64K if the runtime keeps the compressed latent (47 layers × 576 values) and about 63 GB if it expands it to full keys and values, so check your runtime’s memory report before relying on it.

Per Mac, the Best LLM by Mac pages rank every model that fits, and the leaderboard filters by RAM.

A Mac that holds the 32 GB-tier agents at 64K

The cheapest configuration Amazon itself stocks with more than 32 GB is the Mac Studio M5 Max with 36 GB (32-core GPU, 460 GB/s), which holds Qwen 3.6-35B-A3B at 64K. The 48–128 GB Mac Studio and MacBook Pro configurations that hold Qwen3-Coder-Next or GPT-oss 120B are build-to-order from Apple: AppleInsider’s price guide showed no Amazon listing for them on 18 November 2026.

Mac Studio M5 Max (36 GB) on Amazon → Mac mini M5 Pro (24 GB) on Amazon →

Disclosure: As an Amazon Associate, LLMCheck earns from qualifying purchases. This doesn’t affect the index’s figures or rankings.

Speed: decode, and the wait before the first token

Two speeds decide how an agent feels. Decode is how fast the reply streams; the index’s figures are plain decode at a short prompt, and decode slows as the context fills because every new token also reads the cache. Prefill is how fast the server reads the prompt before it can answer, and an agent sends a long prompt every turn. The index does not estimate prefill: it depends on compute, which the bandwidth model does not describe.

Two published sources show how much prefill matters. In Artificial Analysis’s AA-AgentPerf-Local (29 September 2026), which replays recorded agent sessions whose context grows to about 56K tokens, 73–93% of prompt tokens were served from the KV cache, and prefill still took 22–41% of the completion time for Qwen3.8-27B; on its one Mac, a MacBook Pro M5 Pro with 64 GB, the agent paused for up to 39 seconds before replying when a tool returned a large file. Every featured configuration in that benchmark used speculative decoding. And in Apple’s 15 October MLX tests, an M5 Ultra reached the first token of an 8,192-token prompt on Qwen 3.8 27B in 4.1 seconds against 18.2 on an M3 Ultra: the M5 generation’s Neural Accelerators speed prefill far more than decode.

In practice: prefer a mixture-of-experts model with few active parameters for an interactive agent (Qwen 3.6-35B-A3B decodes at community79 tok/s on a Mac mini M5 Pro, against sourced17 tok/s for the dense Qwen3.8-27B), keep the server running so its prompt cache stays warm, and on an M5-generation Mac use a runtime built on current MLX. oMLX keeps evicted cache blocks on the SSD and restores them when a later prompt starts with the same prefix, which is the pattern an agent produces. Ollama’s tok/s can be higher than the index’s figure because it turns on speculative decoding for some models; the Ollama MLX guide shows how to tell.

Tool-calling reliability: what the evidence says

No current, Mac-specific leaderboard measures how reliably local models call tools, and LLMCheck runs no tests of its own. What the published evidence supports:

The practical test is cheap: give the agent a small task in a scratch repository (read a file, change a function, run the tests) and watch whether it calls tools or prints them as text. A model that prints a JSON tool call instead of making it usually has a template the server does not recognise.