Claude Code is Anthropic’s agentic coding CLI - a terminal pair-programmer that reads your repo, edits files, runs commands, and follows permission prompts. By default it talks to Anthropic’s API in the Anthropic Messages format. Ollama now serves a subset of that same format locally: its Anthropic compatibility page says “Ollama supports a subset of the Anthropic Messages API” and documents pointing ANTHROPIC_BASE_URL at http://localhost:11434, and its Claude Code integration guide adds a one-line launcher. Anthropic’s side is less welcoming: its gateway docs say the company “doesn’t support routing Claude Code to non-Claude models through any gateway,” so treat this as an off-label setup that can break with any Claude Code release. This guide covers which Ollama models have the strongest card-level evidence for Claude Code-style agentic work, how to wire them, and which Anthropic features do not carry over.
TL;DR
- Anthropic’s LLM gateway documentation is explicit: “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.” Treat any local-model backend as an unsupported configuration.
- No translation proxy is needed. Ollama’s Anthropic compatibility API serves
/v1/messageswith streaming, tools, and thinking blocks, and the Claude Code integration guide documentsollama launch claudeor a manual setup withANTHROPIC_AUTH_TOKEN=ollama,ANTHROPIC_API_KEY="", andANTHROPIC_BASE_URL=http://localhost:11434. - For local models, the same guide says to “set a 64k+ context window.”
- The models with the strongest evidence on their own cards are Qwen3-Coder-Next (80B total / 3B active, 256K context, lists “Claude Code, Qwen Code, Qoder, Kilo, Trae, Cline, etc.” among its integration platforms), Devstral Small 2 (24B, 256K context, lists Claude Code among its scaffolding options), and GLM-4.6 (200K context, “better real-world performance in applications such as” Claude Code, Cline, Roo Code and Kilo Code). Qwen3-Coder-30B-A3B-Instruct (30.5B total / 3.3B active, 256K context) is the smaller Qwen option.
- On the Ollama tag side, qwen3-coder ships the 30B at 19 GB and the 480B at 290 GB, qwen3-coder-next ships the 80B-A3B at 52 GB, and devstral-small-2 ships the 24B at 15 GB (sizes as listed by Ollama, as of 2026-10-11). These are decimal gigabytes: the registry manifest for
qwen3-coder:30btotals 18,556,700,222 bytes, which is 18.6 GB or 17.3 GiB. GLM-4.6 was retired from Ollama on 2026-06-16, so it needs a separate install path. - What does not carry over: Ollama’s Anthropic API lists
/v1/messages/count_tokens,tool_choice, prompt caching (cache_control), the Batches API, citations, and PDF document blocks as “not currently supported,” and extended thinking has only “Basic support; budget_tokens accepted but not enforced.”
What Claude Code actually requires
Claude Code is not just a thin client. The Anthropic gateway compatibility guide documents the request shape and the breakage modes in detail. Three pieces matter most when you swap the backend.
The Anthropic Messages format. With ANTHROPIC_BASE_URL set, Claude Code sends Anthropic-format requests to /v1/messages (and optionally /v1/messages/count_tokens) at that base URL, and the guide says it “treats the gateway as the Claude API and can’t tell which upstream you forward to.” Ollama’s Anthropic compatibility page lists /v1/messages with messages, streaming, system prompts, tools, tool results, and thinking blocks as supported, so Ollama can sit directly behind ANTHROPIC_BASE_URL. Ollama also exposes an OpenAI-compatible /v1/chat/completions endpoint for other tools; Claude Code does not use it.
Streaming. Claude Code reads each response event by event as it arrives. The compatibility guide is explicit: “If your gateway buffers a response until it is complete, Claude Code stalls,” and “Claude Code expects each response’s full event sequence, in order, through the final message_delta and message_stop events.” Ollama’s Anthropic API lists the matching streaming events: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop, ping, and error.
Beta headers and adaptive reasoning. The compatibility guide pairs anthropic-beta headers with body fields - for context management, for beta tool schema fields like strict and defer_loading, and for output_config (effort, structured outputs, task budget). Adaptive reasoning is the exception: Claude Code sends thinking: {"type": "adaptive"} with no beta header, including to model names it does not recognize. It warns that a gateway which “forwards an Anthropic-format body to an upstream with a different schema, produces hard 400 errors,” and that when the upstream rejects the thinking field, a mid-conversation system message, or a cache_control marker on such a message, “Claude Code retries the request and disables the rejected capability for the rest of the conversation.” The guide’s per-feature “symptom” column is the place to look up what a given failure looks like. If a beta feature misbehaves against a local backend, the guide documents CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 to turn pre-release capabilities off.
What the model needs to provide
Once Claude Code is talking to Ollama, the model itself still has to handle the workload. Three capabilities matter.
Function calling. Claude Code relies on tools to read files, run shell commands, and make edits. Ollama’s Anthropic API lists “Tools (function calling)” and tool_use / tool_result blocks as supported; its integration guide lists tool calling “with compatible models,” and for cloud models advises: “Choose a cloud model that supports tools.” Ollama’s “Not supported” table lists tool_choice (“Forcing specific tool use or disabling tools”), although the same page also lists tool_choice among accepted request fields, so forcing a specific tool is not something to rely on. Ollama’s tool support dates from its 2024 tool-support post, which noted that “Ollama’s OpenAI compatible endpoint also now supports tools, making it possible to switch to using Llama 3.1 and other models.”
Long context. Coding agents read many files and accumulate long tool-call histories. Ollama’s Claude Code guide says: “Local models Choose a model and set a 64k+ context window. For larger repositories, set the context length to 64k or higher.” The Qwen3-Coder-30B-A3B-Instruct card lists native context at 262,144 tokens (256K), “extendable up to 1M tokens using Yarn, optimized for repository-scale understanding.” The Qwen3-Coder-Next card lists the same 262,144 native context. The Devstral Small 2 card lists “A 256k context window” and uses --max-model-len 262144 in its vLLM example. The GLM-4.6 card says the window “has been expanded from 128K to 200K tokens.” Claude Code itself, per the compatibility guide, “assumes 200K” of context for a model ID it does not recognize unless told otherwise. A longer context window costs memory for the KV cache on top of the weights, so the context you set has to fit your hardware.
Instruction following. Coding CLIs depend on the model honoring the scaffold’s instructions and the tool-use format. The Devstral card describes the model as “fine-tuned to follow instructions, making it ideal for chat, agentic and instruction based tasks for SWE use cases.” The Qwen3-Coder-30B-A3B-Instruct card notes that the model “supports only non-thinking mode and does not generate <think></think> blocks in its output,” and the Qwen3-Coder-Next card carries the same note.
The four models with the strongest Claude-Code evidence on their cards
Sorting by what each model’s own card says, not by general capability leaderboards, four checkpoints stand out. Card statements are the vendors’ own claims, not independent test results.
Qwen3-Coder-Next (80B total / 3B active, 256K context). The Qwen3-Coder-Next model card is the strongest single source on this list: it names “Claude Code, Qwen Code, Qoder, Kilo, Trae, Cline, etc.” as CLI/IDE platforms it integrates with, and gives a vLLM tool-call recipe (--enable-auto-tool-choice --tool-call-parser qwen3_coder). It is a mixture-of-experts model with 512 experts and 10 activated, in a hybrid Gated DeltaNet and Gated Attention layout, Apache-2.0 licensed. The Ollama qwen3-coder-next library page ships the 80B-A3B tag at 52 GB (51,741,611,333 bytes in the registry manifest, about 48.2 GiB), roughly twice the 24 GiB (25.8 GB) of a single 24 GB consumer GPU before any KV cache.
Devstral Small 2 (24B, 256K context). The Devstral Small 2 card names Mistral Vibe and lists Cline, Kilo Code, Claude Code, OpenHands, and SWE Agent as scaffolds it can be used with, and recommends vLLM with --tool-call-parser mistral --enable-auto-tool-choice. Mistral’s Hugging Face card reports 68.0% on SWE-bench Verified (vendor-reported; the Ollama library page shows 65.8% for the same model). The card says the model “is light enough to run on a single RTX 4090 or a Mac with 32GB RAM,” which makes it the lowest-memory option in this set. Ollama lists devstral-small-2:24b at 15 GB (15,177,373,679 bytes, about 14.1 GiB).
GLM-4.6 (200K context). The GLM-4.6 card says the model “demonstrates better real-world performance in applications such as” Claude Code, Cline, Roo Code and Kilo Code, “including improvements in generating visually polished front-end pages.” It also states the model “supports tool use during inference” and “exhibits stronger performance in tool using and search-based agents.” Catch: the Ollama library page says “glm-4.6 was retired on June 16, 2026” and “No models have been pushed,” so it can no longer be pulled from the Ollama library. The Hugging Face weights remain available for other runtimes such as vLLM.
Qwen3-Coder-30B-A3B-Instruct (30.5B total / 3.3B active, 256K context). The Qwen3-Coder-30B-A3B-Instruct card says “Qwen3-Coder excels in tool calling capabilities” and shows an OpenAI-client example calling a square_the_number tool. It names Qwen Code and CLINE as platforms, not Claude Code. The Ollama qwen3-coder library page ships qwen3-coder:30b at 19 GB, and Ollama’s own Anthropic compatibility example uses qwen3-coder as its model. This is the smallest Qwen checkpoint in this guide positioned for agentic coding.
The same family has a 480B flagship, listed on the Ollama qwen3-coder library page at 290 GB. For local coding on consumer hardware the 30B-A3B and Qwen3-Coder-Next 80B-A3B are the realistic options; the 480B is server-class.
How to wire it
Ollama’s Claude Code integration guide documents two local paths.
1. The launcher. ollama launch claude starts Claude Code against Ollama and lets you choose a model; for scripts, ollama launch claude --model <model> --yes “skips selectors, pulls the model when needed, and requires --model.”
2. Manual setup. Install Claude Code, then set the environment variables the guide lists and pick a model:
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3-coder:30b
Pull the model first (ollama pull qwen3-coder:30b fetches the 19 GB tag) and raise Ollama’s context length to at least 64K, per the guide. The guide adds that “Claude settings can override shell variables,” so check any base URL already set in Claude Code’s settings and run /status to confirm the connection.
Gateway-side settings from Anthropic’s compatibility guide still apply: with a custom base URL, fine-grained tool streaming is off unless CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING=1 is set, and model discovery from /v1/models requires CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 and keeps only entries whose id contains claude or anthropic, so local models are selected with --model rather than from the picker.
What does not carry over
Three categories of difference are documented.
Unsupported Anthropic API features. Ollama’s Anthropic compatibility page lists as “not currently supported”: /v1/messages/count_tokens, tool_choice, metadata, prompt caching (cache_control blocks), the Batches API, citations, PDF document blocks, and server-sent error events. Extended thinking has “Basic support; budget_tokens accepted but not enforced,” and token counts “are approximations based on the underlying model’s tokenizer.” Anthropic-side prompt-cache savings therefore do not apply.
Beta features. Claude Code sends beta headers and body fields such as adaptive thinking, context management, strict and defer_loading tool fields, and output_config to any ANTHROPIC_BASE_URL endpoint. Per Anthropic’s compatibility guide, an upstream that rejects thinking or cache_control triggers a retry with that capability disabled; other rejected fields surface as 400 errors, which CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 is documented to avoid.
Streaming stalls. The compatibility guide says “Claude Code aborts a streaming response once no bytes reach it for longer than its streaming idle timeout,” and notes that during a long thinking pause, SSE ping events “can be the only bytes on the stream.” Ollama lists ping among its streaming events. On slow local hardware, long prompt-processing pauses are the case to watch.
What This Means
Running Claude Code against a local Ollama model is a documented configuration on Ollama’s side and an unsupported one on Anthropic’s. Two of the model cards above (Qwen3-Coder-Next, GLM-4.6) name Claude Code in their integration claims and Devstral Small 2 lists it as a scaffold. Practical rules:
- If you have the memory for it, start with Qwen3-Coder-Next at 52 GB on Ollama (the card that names Claude Code most directly), or Devstral Small 2 at 15 GB on Ollama if your hardware is closer to a single RTX 4090 or a 32 GB Mac.
- Qwen3-Coder-30B-A3B-Instruct at 19 GB is the smaller Qwen option. Its card names Qwen Code and CLINE rather than Claude Code, so test it on your own repository before relying on it.
- GLM-4.6 is no longer on the Ollama library: the library page shows the model retired 2026-06-16.
- Expect changes on both sides. The compatibility guide warns that “Claude Code gains capabilities over releases, and they arrive as new
anthropic-betavalues, new request body fields, and occasionally newanthropic-*orx-claude-code-*headers,” and Ollama’s compatibility list covers a subset of the Anthropic API.
The Bottom Line
Claude Code was built for Claude, and Anthropic’s own gateway docs say pointing it at a non-Claude model is unsupported. Within that constraint, Ollama’s Anthropic-compatible endpoint removes the need for a translation proxy: set ANTHROPIC_BASE_URL=http://localhost:11434 or run ollama launch claude, give the model at least 64K of context, and start from the checkpoints whose own cards point at Claude Code-style agentic use - Qwen3-Coder-Next, Devstral Small 2, and GLM-4.6 (off the Ollama library since June 2026) - with Qwen3-Coder-30B-A3B-Instruct when 80B does not fit. Prompt caching, token counting, tool_choice, and enforced thinking budgets do not carry over, so treat the whole stack as off-label and re-check it after Claude Code or Ollama updates.