Driving Claude Code With Local Ollama Models (October 2026)

Which open-weight models hold up behind Claude Code, how Ollama's Anthropic-compatible endpoint connects them, and what each Ollama tag costs to run.

Updated November 1, 2026

Claude Code is built to talk Anthropic’s /v1/messages API. Ollama now serves a subset of that Anthropic Messages API itself, so Claude Code can reach a local model by pointing ANTHROPIC_BASE_URL at http://localhost:11434, or by running ollama launch claude; no separate translation bridge is required. The open-weight coding models that hold up in that setup are a short list. The most useful picks are Qwen3-Coder-30B-A3B-Instruct for a 24 GB card and Devstral Small 2 24B Instruct 2512 for a 16 GB card; Qwen3-Coder-Next is the largest single-card pick and KAT-Coder-V2.5-Dev is the strongest vendor-reported SWE-bench score outside the Qwen family. Anthropic states that it does not support routing Claude Code to non-Claude models.

How Claude Code reaches Ollama

Claude Code’s gateway protocol guide states that “a gateway must expose at least one of the following API formats to Claude Code clients,” with the Anthropic Messages row selected by ANTHROPIC_BASE_URL and served at /v1/messages, plus an optional /v1/messages/count_tokens. Ollama’s Anthropic compatibility page says “Ollama supports a subset of the Anthropic Messages API” and gives the environment variables for tools that expect the Anthropic API, Claude Code included: ANTHROPIC_AUTH_TOKEN=ollama (required but ignored) and ANTHROPIC_BASE_URL=http://localhost:11434. Ollama’s Claude Code guide adds ANTHROPIC_API_KEY="" and a model flag, for example claude --model qwen3.5, or the one-step ollama launch claude.

The “Other LLM gateways” page sets the support boundary: “Anthropic doesn’t endorse, maintain, or audit third-party gateway products, and doesn’t support routing Claude Code to non-Claude models through any gateway.” The user is on their own when a feature misbehaves, and “this configuration works today” is the most that can be claimed.

The subset matters. Ollama lists these Anthropic API features as not currently supported: the /v1/messages/count_tokens endpoint, tool_choice (“Forcing specific tool use or disabling tools”), metadata, prompt caching via cache_control blocks, the Batches API, citations, PDF document blocks, and server-sent error events during streaming. Extended thinking has basic support only, with budget_tokens accepted but not enforced.

The shortlist

Six open-weight coding models carry the necessary mix of long context, agentic tool training, and a licence that allows the configuration. The table lists each one’s Ollama default tag size, the total and active parameter counts from Hugging Face, and the SWE-bench Verified score on each model’s own card (vendor-reported, not independent).

Use caseModelOllama default tagHF params (total / active)LicenceSWE-bench Verified (vendor card)
24 GB consumer cardQwen3-Coder-30B-A3B-Instructqwen3-coder:30b (19 GB)30.5B / 3.3BApache 2.0not on card
16 GB cardDevstral Small 2 24B Instruct 2512devstral-small-2:24b (15 GB)24B denseApache 2.068.0
Alternative 24 GB tierKAT-Coder-V2.5-Dev(no Ollama tag)35B / 3B activeApache 2.069.40
Open-licence 24 GB tierGLM-4.7-Flashglm-4.7-flash (19 GB)30B / 3B activeMIT59.2
Frontier single-cardQwen3-Coder-Nextqwen3-coder-next (52 GB)80B / 3B activeApache 2.0not on card
Frontier multi-cardQwen3-Coder-480B-A35Bqwen3-coder:480b (290 GB)480B / 35B activeApache 2.0not on card

The Ollama library defaults are Q4_K_M builds: 19 GB for the 30B-A3B, 15 GB for Devstral Small 2 (devstral-small-2:latest and :24b share the 24b-instruct-2512-q4_K_M digest), 19 GB for GLM-4.7-Flash, 52 GB for Qwen3-Coder-Next, 290 GB for the 480B. The older devstral:24b tag (14 GB, 128K context) is the first-generation Devstral, not Small 2. Sizes are download sizes as listed by Ollama; a 15 GB model on a 16 GB card leaves little room for the KV cache, so long contexts there will spill to system memory. Ollama has not published a tag for KAT-Coder; that one needs Hugging Face safetensors converted to GGUF, or a separate server such as vLLM or SGLang behind its own Anthropic-format gateway.

Qwen3-Coder-Next is the largest single-card option in the list. Its card names “Claude Code, Qwen Code, Qoder, Kilo, Trae, Cline” among CLI/IDE platforms it integrates with, and publishes 80B total with 3B activated and 262,144 native tokens, but its benchmark results sit in images rather than a text table, so its SWE-bench column is marked “not on card” here rather than guessed at. Devstral Small 2 24B Instruct 2512’s card lists Claude Code among the scaffoldings it “can also be used with”. KAT-Coder-V2.5-Dev’s card names [email protected] as the agent used for its SWE-bench runs and says its metrics are “reproduced in-house”. None of these mentions implies Anthropic endorsement; the support caveat above holds for all of them.

Setting it up

Ollama’s Claude Code guide reduces the setup to three steps: install Claude Code, set the environment variables, and run it with a model name.

  • export ANTHROPIC_AUTH_TOKEN=ollama
  • export ANTHROPIC_API_KEY=""
  • export ANTHROPIC_BASE_URL=http://localhost:11434
  • then claude --model qwen3-coder:30b (or any pulled tag)

The same guide says to “Choose a model and set a 64k+ context window” for local models, and “For larger repositories, set the context length to 64k or higher.” Ollama’s compatibility page also shows ollama cp copying a local model to a name such as claude-3-5-sonnet for tools that expect a Claude model name.

The Qwen3-Coder blog documents two other paths, both aimed at Alibaba Cloud’s hosted DashScope service rather than a local Ollama process: a claude-code-proxy endpoint set through ANTHROPIC_BASE_URL with a DashScope API key (“Then you should be able to use Claude Code with Qwen3-Coder!”), and the open-source @musistudio/claude-code-router with a DashScope config package. Its Cline instructions use qwen3-coder-plus against DashScope’s OpenAI-compatible URL; pointing Cline at Ollama means using the local 11434 endpoint instead.

What holds up, and what doesn’t

Three patterns are stable across the recommended models.

Long context for repository-scale work. Qwen3-Coder-30B-A3B-Instruct publishes 262,144 native tokens on its card; Qwen3-Coder-Next publishes the same number; KAT-Coder-V2.5-Dev supports 262,144 natively and recommends RoPE scaling such as YaRN past that limit; Devstral Small 2 24B Instruct 2512 is 256K, and the Ollama tag for GLM-4.7-Flash is published at 198K. Ollama’s own guidance for Claude Code is a context window of 64k or more.

Tool-call training. Qwen3-Coder-30B-A3B-Instruct’s card describes agentic coding “supporting for most platform such as Qwen Code, CLINE”; Qwen3-Coder-Next lists six CLI/IDE integrations by name; Devstral Small 2’s card says it “is designed to excel at agentic coding tasks, making it a great choice for software engineering agents.”

Permissive licence. Apache 2.0 covers five of the six (both Qwen3-Coder sizes, Qwen3-Coder-Next, Devstral Small 2 24B Instruct 2512, KAT-Coder-V2.5-Dev) and MIT covers GLM-4.7-Flash. Neither licence prohibits commercial use.

Three things don’t necessarily hold up.

Force-tool selection. Ollama’s Anthropic compatibility page lists tool_choice as not supported, and its OpenAI-compatible /v1/chat/completions field list leaves tool_choice unchecked as well. Plain tool calls work; patterns that depend on forcing a specific tool do not.

Prompt caching and token counting. cache_control blocks and /v1/messages/count_tokens are on Ollama’s not-supported list, and Ollama notes that token counts are approximations based on the underlying model’s tokenizer. Claude Code features that lean on either behave differently than against Anthropic’s API.

Newer beta features. Claude Code’s gateway protocol guide pairs several features with anthropic-beta headers and body fields, and behaviour against a non-Anthropic backend is version-dependent. Ollama documents only a subset of the Messages API, so anything outside that subset should be assumed unavailable until tested.

Bottom line

For a 24 GB consumer card the working configuration today is qwen3-coder:30b served by Ollama, with Claude Code pointed at http://localhost:11434 through ANTHROPIC_BASE_URL and the context window raised to 64k or more. For a 16 GB card the same pattern works with devstral-small-2:24b (15 GB Q4_K_M, Apache 2.0, vendor-reported SWE-bench Verified 68.0), with little memory left for context. For a 64 GB+ card qwen3-coder-next (52 GB Q4_K_M, Apache 2.0, 80B total with 3B activated, 262,144 native tokens) is the largest single-card option on the list; KAT-Coder-V2.5-Dev at 35B/3B (Apache 2.0, vendor-reported SWE-bench Verified 69.40) is an alternative outside the Qwen family, though it has no Ollama tag. GLM-4.7-Flash adds an MIT option at the same MoE footprint, fits the 24 GB tier at 19 GB, and scores lower on its card’s SWE-bench number (59.2). Anthropic does not support any of this, and Ollama’s Anthropic endpoint lacks tool_choice, prompt caching and token counting. The economic case still depends on the local AI vs API cost crossover, and the broader coding-model landscape is on the VRAM tier guide.