Best Local LLMs for OpenCode
Open-source terminal coding agent (Ollama / OpenAI-compatible)
OpenCode is a terminal AI coding agent that reads, writes, and runs code through an agentic loop, fully offline via Ollama. Because every action is a tool call, a model that describes edits instead of firing the read/write/bash tools is useless here regardless of raw coding skill. A third-party hands-on comparison separates the models cleanly, and the right context-window setting matters as much as the model.
- Best pick
- Qwen3.5 27B InstructWinner of a third-party OpenCode comparison: complete working projects, lowest structured-task error rate, precise tool format.
- What OpenCode needs
- Rock-solid tool-call emission, with the context window raised well above Ollama's 4K default (16K minimum, 64K recommended).
OpenCode local LLM tier list
11 models| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3.5 27B Instruct | 27B | 24GB | Winner of a third-party OpenCode comparison: complete working projects, lowest structured-task error rate, precise tool format. | |
| Gemma 4 26B-A4B | 26B | 24GB | Close runner-up: clean tool calls and compiling output from an efficient MoE. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3 30B | 30B | 32GB | Qwen3-Coder-class MoE; fast, clean first-attempt code with reliable tool calls. | |
| Qwen3.6 35B-A3B | 35B | 32GB | Newest Qwen3.6 coder MoE, with strong agentic coding and tool-calling lineage. | |
| Qwen2.5 Coder 14B | 14B | 16GB | Proven coder with solid native tool-calling; dependable daily driver. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3.5 35B-A3B Instruct | 35B | 32GB | Capable but unpredictable on structured output (slug/edit hallucination); add a validation step. | |
| Qwen2.5 Coder 7B | 7B | 8GB | Smallest model that still calls tools reliably enough for light edits at 16K+ ctx. | |
| Mistral Small 22B | 22B | 32GB | Decent native tool calling; workable but weaker agentic coding than Qwen peers. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3 14B | 14B | 16GB | Failure mode OpenCode hates: hallucinates results instead of using tools. | |
| DeepSeek-R1 Distill Qwen 14B | 14B | 16GB | Verbose reasoning traces disrupt the tool-call loop. | |
| Phi-4 14B | 14B | 24GB | Weak, unreliable tool calling for agentic editing. |
Tiers weigh tool-calling reliability, context window, and coding quality for OpenCode specifically. A model can rank higher for one tool than another. RAM figures are for Q4 quantization. Sources are listed below.
Local setup notes
Install OpenCode, run Ollama, and select your local model. Critically, raise num_ctx. Ollama defaults every model to a 4K window, which silently breaks agentic tool use; set 16K at minimum and 64K for serious work.
Get told when a better model fits your MacBook Air M5 16 GB
Get one email when a new open-weight model is a better fit for this machine.
For: MacBook Air M5 16 GB
You'll also get the weekly ModelFit email. By signing up you agree to our Privacy Policy. Unsubscribe from either email anytime, in one click.
Frequently asked questions
Which local model is best for OpenCode?
Why do some local models fail in OpenCode?
What context window does OpenCode need with Ollama?
Sources
Other AI coding tools
- Claude CodeAnthropic's terminal coding agent, driven by a local modelCLI agent
- OpenClawSelf-hosted agentic assistant with first-class Ollama supportSelf-hosted agent
- AiderTerminal AI pair-programmer with its own edit-format leaderboardTerminal pair-programmer
- ClineAutonomous coding agent for VS Code (formerly Claude Dev)IDE extension
- Roo CodeAutonomous VS Code agent with modes (a Cline fork)IDE extension
- Continue.devOpen-source chat, edit & autocomplete for VS Code / JetBrainsIDE extension
- GooseBlock's open-source autonomous developer agent (MCP-driven)CLI agent
- Open Claude CodeOpen-source Claude Code CLI reimplementation, with an undocumented endpoint override for local modelsCLI agent
- CodexOpenAI's coding agent, driven by a local model via its built-in Ollama providerCLI agent