Coding is the most popular reason to run a model locally: your code never leaves the machine, there are no per-token bills, and autocomplete keeps working offline. But “coding model” covers three different jobs, and the best model for each is different.
Three Ways Models Help You Code
- Autocomplete (tab completion). The editor sends the code around your cursor and the model fills in the middle. Speed matters more than smarts, so small models (1.5B–7B) win. The model must support fill-in-the-middle (FIM).
- Chat about code. You paste an error or a function and ask questions. Any good general model works; bigger is better.
- Coding agents. Tools like Aider, Cline, Continue (agent mode), OpenHands and OpenCode let the model read files, run commands and edit across a repository. This needs reliable tool calling and a long context, usually 32K tokens or more.
Best Ollama Models for Coding
The table is generated from the TecAdmin AI models directory and updates as models change. VRAM is for the default 4-bit build with an 8K context; agents need more context, so add headroom.
Our Picks by Hardware
Laptop or 8 GB GPU
Use Qwen2.5-Coder 1.5B for autocomplete and Qwen2.5-Coder 7B or Qwen3.5 4B for chat. Small models are poor agents, so use a hosted model if you need agentic work on this hardware.
16 GB GPU
gpt-oss-20b handles tool calls well and is fast thanks to its 3.6B active parameters. Devstral Small 2 (24B) is trained specifically for coding agents and reads screenshots, but needs about 17 GB, so it belongs on a 24 GB card.
24 GB GPU or 32 GB Mac
This is the sweet spot for local coding. Qwen3.8 27B is the strongest all-round choice. Qwen3-Coder 30B and GLM-4.7-Flash are mixture-of-experts models with about 3B active parameters, so they generate several times faster. Compare the two coding specialists in Qwen3-Coder vs Devstral Small 2.
80 GB GPU or 64 GB+ Mac
Qwen3-Coder-Next (80B total, 3B active) is the best open coding model that fits on one machine: it was trained on executable tasks and reads 256K tokens.
Give Agents Enough Context
Coding agents send the system prompt, tool definitions and file contents with every request, which quickly exceeds a small context window and makes the model forget instructions. Raise the context length for the Ollama service:
sudo systemctl edit ollama
Add these lines under [Service], then save and restart:
[Service]
Environment="OLLAMA_CONTEXT_LENGTH=32768"
Environment="OLLAMA_FLASH_ATTENTION=1"
Environment="OLLAMA_KV_CACHE_TYPE=q8_0"
sudo systemctl restart ollama
A 32K context adds several gigabytes on top of the table above. Check the real usage with ollama ps, or estimate it first with the LLM VRAM calculator.
Connect an Editor or Agent
Most tools talk to Ollama through its OpenAI-compatible API at http://localhost:11434/v1, so any client that lets you set a base URL works. For example, Aider has a built-in Ollama provider:
export OLLAMA_API_BASE=http://127.0.0.1:11434aider --model ollama_chat/qwen3-coder:30b
In VS Code and JetBrains extensions such as Continue, choose Ollama as the provider and pick one model for chat and a small one (for example qwen2.5-coder:1.5b) for autocomplete.
When to Use a Hosted Model Instead
Local models have closed much of the gap, but the strongest coding agents still run on hosted models such as Claude and GPT. If you need long autonomous runs across a big codebase, compare the Claude Code, Codex CLI and Antigravity CLI agents, and see the model lineups on the Claude and GPT pages.
How did it make you feel?
