Qwen4-35B-A3B landed on 4 December 2026 with Apache 2.0 weights, a 1M-token context window and native tool calling. Within a day Ollama had it in the library with one-line launchers for Claude Code and OpenCode. That makes it the easiest way yet to run a free, private coding agent on your own PC or Mac.
This guide shows how to wire Qwen4-35B-A3B into Claude Code, OpenCode and Codex CLI, using Ollama or llama.cpp. It covers the exact commands, the context length and sampling settings that agents need, the Ollama default that cuts speed to a crawl, and what to expect from the model on real coding work.
Everything here is checked against the Ollama library page for qwen4, the Qwen model card as quoted by Unsloth and Hugging Face, and hands-on tests published by ComputingForGeeks, as of 5 December 2026.
- Fastest route: update Ollama, then run
ollama launch claude --model qwen4(oropencodeinstead ofclaude). - Ollama version: the qwen4 manifest asks for 0.40.21 or newer. Older builds fail on pull.
- Download: the default
qwen4tag is about 36 GB (Q4_K_M with vision and the MTP drafter). - Agents need context: set
OLLAMA_CONTEXT_LENGTH=65536before starting the server. - Keep reasoning on. Use the default “high” effort for agent runs. “Off” gave wrong answers in tests.
- Hardware: a 24 GB GPU or a 32 GB Mac runs it comfortably. 16 GB works with MoE offload in llama.cpp.
New to the model? My Qwen4-35B-A3B guide covers specs, benchmarks, file sizes and API prices.
Why Qwen4-35B-A3B Suits Coding Agents
A coding agent reads files, runs commands, calls tools and loops many times per task. That puts three demands on a local model: it must call tools reliably, it must handle long context, and it must be fast enough that a 30-step task doesn’t take an hour.
Qwen4-35B-A3B ticks all three boxes for a model you can run at home:
- Mixture of experts. It has 35B core parameters but only about 3B are active per token (the Hugging Face launch blog says about 3.8B). That’s why it decodes so quickly.
- Hybrid attention. Its 40 layers are arranged as 10 blocks of three Gated DeltaNet layers plus one full attention layer. Only the 10 attention layers keep a growing KV cache, so long context costs far less memory than in a normal model.
- Tools, thinking and vision. The Ollama library page lists the model with “vision tools thinking” tags and a 1M context window.
- Built-in drafter. A small multi-token prediction (MTP) head ships with the model and can speed up decoding through speculative decoding.
It is not a frontier cloud model like Claude Opus. On hard, multi-file refactors a frontier model still wins. But for everyday edits, tests, scripts and explaining code, it is the strongest free agent model that fits a single consumer GPU right now.
What You Need
| Item | Minimum | Comfortable |
|---|---|---|
| GPU (NVIDIA or AMD) | 16 GB VRAM with llama.cpp MoE offload | 24 GB VRAM (RTX 3090, 4090, 5090) |
| Mac | 24 GB unified memory with a 3-bit or IQ4 build | 32 GB or more for Q4_K_M |
| System RAM | 32 GB | 64 GB |
| Disk | 40 GB free | 60 GB free (room for a second quant) |
| Ollama | 0.40.21 | Latest |
| Agent | Claude Code, OpenCode or Codex CLI, installed and on your PATH | |
A pure CPU setup is not practical. One test on four CPU cores managed under 8 tokens per second, which is too slow for an agent loop.
If you are on a 16 GB card, read my Qwen4-35B-A3B on a 16 GB GPU guide first. It has the exact offload flags.
Step 1: Install the Model in Ollama
- Update Ollama. The qwen4 manifest declares that it requires 0.40.21. On Windows and Mac, use the app’s update prompt or download the latest installer. On Linux, rerun the install script. See my guide to updating Ollama if you’re not sure.
- Linux only: the installer needs
zstd. On Ubuntu or Debian runsudo apt-get install -y zstdfirst. - Pull the model:
ollama pull qwen4. This fetches the default tag, about 36 GB. - Test it:
ollama run qwen4 "Write a Python function that reverses a linked list."
Tags on the Ollama library page as of 5 December:
| Tag | Size | Use it for |
|---|---|---|
qwen4 / qwen4:35b-a3b |
36-37 GB | Default. Same as Q4_K_M. |
qwen4:35b-a3b-q4_K_M |
37 GB | Explicit GGUF 4-bit (runs on llama.cpp engine everywhere) |
qwen4:35b-a3b-nvfp4 |
36 GB | MLX on Apple Silicon |
qwen4:35b-a3b-bf16 |
114 GB | Full precision, workstation only |
The download is bigger than the memory the model actually uses, because about 11 to 20 GB of it is an n-gram embedding table that is read sparsely. In ComputingForGeeks’ test on one RTX 4090, Ollama used about 21 to 22 GB of VRAM with the right settings.
Step 2: Raise the Context Length
This is the step most people miss. Agents send a big system prompt, tool definitions and file contents on every turn. If the context window is too small, the model forgets its instructions halfway through a task.
Ollama picks a default context based on your VRAM. Its docs describe 4k for cards under 24 GB and 32k for 24 to 48 GB. Ollama’s own agent guides ask for 64k tokens or more.
Set it before starting the server:
- Linux and Mac:
OLLAMA_CONTEXT_LENGTH=65536 ollama serve - Windows (PowerShell): quit Ollama from the tray, then run
$env:OLLAMA_CONTEXT_LENGTH="65536"; ollama serve, or set it permanently in System Environment Variables. - Desktop app: open Ollama Settings and move the context length slider to 64k.
More context needs more memory. If the model spills onto the CPU after this change, drop to 32k. My Ollama context length guide explains the trade-off.
Claude Code with Qwen4
Option A, one command:
ollama launch claude --model qwen4
The launcher starts Claude Code with the right environment variables pointed at your local Ollama server. Claude Code’s tools, permissions and slash commands all work as normal; only the model behind it changes.
Option B, manual setup (useful if Ollama runs on another machine):
- Set
ANTHROPIC_BASE_URL=http://localhost:11434(replace localhost with the server’s IP if remote). - Set
ANTHROPIC_AUTH_TOKEN=ollama. - Set
ANTHROPIC_API_KEYto an empty string. - Run
claude --model qwen4.
Ollama speaks the Anthropic Messages API, which is what makes this work. Your code never leaves your machine, and there is no usage bill.
Tips for Claude Code:
- Start in plan mode for anything bigger than a single file, and let the model write the plan before it edits.
- Keep a short
CLAUDE.mdwith build and test commands. Local models benefit even more than Claude from clear instructions. - Use
/compactearlier than you would with Claude, to keep the context under your limit.
For permission modes and settings, see my Claude Code settings guide.
OpenCode with Qwen4
OpenCode is an open-source terminal agent that works well with local models.
ollama launch opencode --model qwen4
OpenCode also finds a running Ollama server at 127.0.0.1:11434 on its own, so you can start it normally and pick qwen4 from its model list.
The Ollama page also lists launchers for Hermes and OpenClaw with the same pattern. If you’re choosing between the two main agents, my OpenCode vs Claude Code comparison covers the differences.
Codex CLI with Qwen4
The qwen4 library page does not list a Codex launcher, but Codex CLI supports Ollama through its open-source provider mode. Two ways to try:
codex --oss -m qwen4starts Codex against your local Ollama server.- Or add an Ollama provider and profile to
~/.codex/config.tomland select it with/model.
The config keys are covered in my Codex config.toml guide. Codex leans heavily on tool calls, so set the 64k context first.
The llama.cpp Route (Faster, More Control)
Ollama is the easy path. llama.cpp gives you more speed and lets you keep the big n-gram table out of RAM.
- Install a build from 3 December 2026 or later; Qwen4 support landed in build b12969. Older builds fail with “unknown pre-tokenizer type: qwen4”. See how to install llama.cpp.
- Start the server with the Unsloth build and the model card’s sampling values:
llama-server -hf unsloth/Qwen4-35B-A3B-GGUF:UD-Q4_K_XL --load-mode mmap --lazy-mode on -ot per_layer_token_embd=CPU --spec-type draft-mtp --spec-draft-n-max 2 -c 65536 --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0.0 --port 8080
What the key flags do:
--lazy-mode onand-ot per_layer_token_embd=CPUkeep the n-gram table on disk and read it as needed. In tests, RAM use dropped from 14.7 GiB to 1.3 GiB with no speed loss.--spec-type draft-mtpturns on the built-in drafter. ComputingForGeeks found 1 draft token fastest on a 4090 (177.7 tokens/s); Unsloth recommends 2.-c 65536sets a 64k context.
Then point your agent at the OpenAI-compatible endpoint http://localhost:8080/v1. OpenCode and Codex both accept a custom OpenAI-compatible base URL.
Reasoning and Sampling Settings
| Mode | Temperature | top_p | top_k | Other |
|---|---|---|---|---|
| Thinking on (agents) | 1.0 | 0.95 | 20 | min_p 0 |
| Thinking off (quick chat) | 0.7 | 0.80 | 20 | presence_penalty 1.5 |
Reasoning effort. The Ollama page lists four levels: xhigh, high (the default), low and off. For agents, stay on high. In ComputingForGeeks’ tests, “off” gave a wrong answer to a simple cron schedule question that “low” and above got right.
The model card also warns that shallow reasoning leads to more failed tool calls and retries, which wastes the time you saved.
In Ollama you can switch thinking per run with --think=false, or per request with the think field. My Ollama thinking mode guide has the details.
Small quants loop. Unsloth’s 1-bit and 2-bit builds sometimes repeat themselves. Add min_p 0.01 and a presence penalty of 1.5 if you see loops.
What to Expect on Real Coding Work
Speed. On a single RTX 4090, ComputingForGeeks measured:
- llama.cpp Q4_K_M: 158 tokens/s, or 178 with one MTP draft token.
- Ollama with tuned settings: 138 to 177 tokens/s.
- Ollama with shipped defaults: about 21 tokens/s (see the fix below).
Unsloth reports 224 tokens/s on an RTX 5090 and 118 on an M5 Max with MTP. That is roughly three times faster than the dense Qwen3.8-27B on the same hardware.
Quality. Treat it like a strong junior developer. It handles:
- Writing and fixing functions, tests and scripts.
- Explaining unfamiliar code and summarising repos.
- Small refactors inside one or two files.
- Reading screenshots of errors or UI, thanks to vision.
It struggles more with long multi-file changes where it must keep a big plan in its head. Break those into steps, review each diff, and commit often so you can roll back.
Common Problems and Fixes
| Problem | Cause | Fix |
|---|---|---|
| Pull fails or “requires newer version” | Ollama older than 0.40.21 | Update Ollama, then pull again |
| Only ~20 tokens/s in Ollama | Default 4-token drafting plus 32k context spills to CPU | Lower context, or set draft_num_predict to 2 in the request options |
| Agent forgets instructions | Context too small | Set OLLAMA_CONTEXT_LENGTH=65536 and restart Ollama |
| Model not listed in the agent | Agent can’t reach Ollama | Check ollama ps and the base URL (port 11434) |
| Tool calls look garbled | Old runtime or template | Update Ollama or llama.cpp; Qwen notes the tokenizer differs from older Jinja templates |
| “unknown pre-tokenizer type” in llama.cpp | Build older than 3 Dec | Update llama.cpp (Homebrew may lag; build from source) |
| Wrong or lazy answers | Thinking set to off | Use high or low reasoning effort |
| LM Studio can’t find it | No LM Studio build yet | Use Ollama or llama.cpp for now |
For the slow-speed issue in general, my Ollama slow fix guide walks through GPU checks.
FAQ
Can I use Qwen4 with Claude Code for free?
Yes. Run ollama launch claude --model qwen4. The model runs locally, so there are no API costs. You still need hardware that can hold the model.
Which Ollama version do I need for Qwen4?
The qwen4 manifest requires Ollama 0.40.21 or newer.
How much VRAM does Qwen4-35B-A3B need?
About 22 GB for Q4_K_M at 32k context on one GPU. A 16 GB card works with llama.cpp MoE offload, and 24 GB Macs can use the IQ4_XS build.
What context length should I use for coding agents?
At least 64k tokens. Set OLLAMA_CONTEXT_LENGTH=65536 before starting Ollama.
Should I turn thinking off to go faster?
Not for agents. Thinking off made more mistakes in tests. Use high (default) or low.
Does Qwen4 work in LM Studio?
Not yet as of 5 December 2026. There’s no official LM Studio build. Use Ollama or llama.cpp.
Is Qwen4-35B-A3B good enough to replace Claude?
For routine coding, many people will find it good enough. For complex, multi-file work, frontier cloud models are still clearly better.
Sources
- Ollama library: qwen4 (tags, sizes, launch commands, reasoning levels)
- ComputingForGeeks: Run Qwen4-35B-A3B Locally (RTX 4090 measurements, Ollama defaults issue)
- Enjoy: Qwen4-35B-A3B local guide (context length guidance, agent setup)
- Apidog: How to run Qwen4-35B-A3B locally (Unsloth commands and sampling)
- Sharkly: Qwen4-35B-A3B as a local coding agent (Claude Code environment variables)



