Skip to content

Best Ollama Models for Coding in 2026 (Autocomplete and Agents)

The best local coding models for Ollama in 2026, by job and GPU size: autocomplete, code chat and coding agents, with VRAM needs and commands.

Category
AI & LLMs
Covers
ai, coding, llm
On this page

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.

ModelBest forVRAMContextLicenceCommand
Qwen2.5-Coder 1.5BTab autocomplete (fill-in-the-middle) on any machine~2 GB32KApache 2.0
Qwen2.5-Coder 7BAutocomplete and small edits on an 8 GB GPU~6 GB32KApache 2.0
Qwen3.5 9BGeneral coding chat on 12 GB~10.5 GB256KApache 2.0
gpt-oss 20BCoding agent with tool use on 16 GB~16 GB128KApache 2.0
Devstral Small 2 24BAgentic coding: explores repos and edits many files~17 GB384KApache 2.0
Qwen3-Coder 30BFast MoE coder (3B active) for 24 GB~21.5 GB256KApache 2.0
GLM-4.7-FlashStrong 30B-class agent model, MIT licence~21.5 GB198KMIT
Qwen3.8 27BBest all-round local model for coding on 24 GB~20.5 GB256KApache 2.0
Qwen3-Coder-NextBest open coder for one 80 GB GPU or a 64 GB+ Mac~58 GB256KApache 2.0
Devstral 2 123BMistral's large coding model for multi-GPU servers~83 GB256KModified MIT

Live data from the TecAdmin AI models directory, updated daily (last checked 14 Nov 2026). VRAM is for the default 4-bit build with an 8K context.

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:11434
aider --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.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top