How to Use Aider with Ollama as a Local Copilot
Last updated 2026-07-20
Wire Aider to Ollama for a 100% local, git-native coding agent — install steps, the ollama_chat/ prefix, context tuning, and the models actually worth running.
By Mohamed Meguedmi · 9 min read
Key Takeaways
- Aider + Ollama is the strongest fully local, git-native coding agent you can run today — no API keys, no data leaving the machine, and every edit lands as a real commit.
- Always use the
ollama_chat/model prefix, notollama/. The chat endpoint fixes broken diffs and lost context that plague the legacy completion path. - The default Ollama context window is only 2048 tokens. Raise it to at least 8192 (ideally 16k–32k) or Aider silently truncates your files and produces garbage edits.
- For 24 GB VRAM, Qwen2.5-Coder 32B Q4_K_M is the verdict pick. On 12–16 GB, drop to Qwen2.5-Coder 14B; on 8 GB, run the 7B.
- Expect real capability, not parity with cloud Sonnet/GPT. Local models excel at scoped, single-file edits and refactors — not sprawling multi-file architecture.
Why Aider + Ollama Beats Every Other Local Copilot
Most "local copilot" setups are IDE plugins that phone home for the heavy lifting. Aider is different: it is a terminal-native pair programmer that reads your repo map, proposes edits as unified diffs, applies them, and commits the result with a sensible message — all driven by whatever model you point it at. Point it at Ollama and the entire loop runs on your own silicon: zero marginal cost, zero telemetry, and full offline capability.
The verdict up front: if you want a genuinely private coding agent and you have at least 12 GB of VRAM, this is the setup to run. It is not a toy. Aider's own edit-format machinery (the diff-based apply layer) is what makes small local models usable — it constrains the model to a format that is easy to validate and roll back, so a 14B model that would flail in free-form chat becomes reliable inside Aider. For a broader view of which models fit which hardware, our model catalog and benchmarks track this continuously.
Hardware You Actually Need
Model choice is dictated by VRAM, and VRAM is the single variable that determines whether this feels like a copilot or a frustration. The table below maps realistic tiers to models and throughput. Numbers are for 4-bit (Q4_K_M) quantization with an 8k–16k context window, measured on consumer GPUs.
| VRAM | Recommended model | Quant | Approx. tok/s | Usable context |
|---|---|---|---|---|
| 8 GB | Qwen2.5-Coder 7B | Q4_K_M | 35–55 | 8k |
| 12 GB | Qwen2.5-Coder 14B | Q4_K_M | 25–40 | 16k |
| 16 GB | Qwen2.5-Coder 14B | Q5_K_M / Q6_K | 20–35 | 16k–32k |
| 24 GB | Qwen2.5-Coder 32B | Q4_K_M | 15–28 | 16k–32k |
| 48 GB+ | Qwen2.5-Coder 32B | Q8_0 / fp16 | 10–22 | 32k+ |
Apple Silicon behaves similarly, gated by unified memory rather than discrete VRAM: an M-series machine with 32 GB comfortably runs the 14B and can stretch to the 32B at Q4. CPU-only inference technically works but drops below 5 tok/s on 14B models — tolerable for a one-off edit, painful for interactive work.
Install Aider and Pull a Model
Aider ships as a Python package; the recommended installer isolates it from your project's environment. Ollama is a single binary that exposes an OpenAI-compatible API on port 11434.
- Install Ollama. On macOS or Linux:
curl -fsSL https://ollama.com/install.sh | sh. Windows users grab the native installer from ollama.com. - Pull a coder model.
ollama pull qwen2.5-coder:14b(swap the tag for7bor32bper the table above). Verify it loads withollama run qwen2.5-coder:14b "say hi". - Install Aider. The maintainers recommend the standalone installer to avoid dependency clashes:
curl -LsSf https://aider.chat/install.sh | sh. Alternatively,python -m pip install aider-install && aider-install, orpipx install aider-chat. - Point Aider at Ollama. Set the API base and launch inside your git repo (see the next section for the exact syntax).
That is the whole install. No accounts, no keys, no billing.
The Critical Config: ollama_chat/ and OLLAMA_API_BASE
This is where 90% of failed setups go wrong. Aider can talk to Ollama through two different code paths, and only one of them behaves. Per the official Aider docs, use ollama_chat/, not ollama/:
export OLLAMA_API_BASE=http://127.0.0.1:11434
aider --model ollama_chat/qwen2.5-coder:14b
The legacy ollama/ prefix routes through the completion endpoint, which mangles the diff format Aider relies on and frequently drops conversation context mid-session. The ollama_chat/ prefix uses the chat endpoint and is the maintainer-recommended default. If your edits are coming back malformed, this prefix is the first thing to check.
On Windows or WSL2, if Ollama runs on the host and Aider runs inside a Linux guest, replace 127.0.0.1 with the host IP (for example http://172.x.x.1:11434) and confirm Ollama is bound to 0.0.0.0 via OLLAMA_HOST.
Fix the Silent Context-Window Trap
Ollama defaults every model to a 2048-token context window regardless of what the model actually supports. Aider needs far more — the repo map, the files you add, the conversation, and the reply all share that budget. At 2048 tokens Aider silently truncates, and the model "forgets" the file it is supposed to edit, producing edits that reference lines that no longer exist in its view.
Set the context window explicitly. The cleanest approach is a small YAML settings file. Create .aider.model.settings.yml in your home directory or project root:
- name: ollama_chat/qwen2.5-coder:14b
extra_params:
num_ctx: 16384
Then launch Aider as normal. You can confirm the effective window in-session with /tokens. Bump num_ctx as high as your VRAM tolerates — every extra 8k of context costs additional memory and slightly reduces throughput, so 16k is a sane starting point and 32k is comfortable on 24 GB cards. Do not blindly set 128k; you will spill to system RAM and throughput collapses.
Which Model to Actually Run
The coder-tuned Qwen family is the current default recommendation for Aider-on-Ollama, and it is not close. The table maps models to Aider's polyglot edit benchmark tier and practical use. Treat cloud frontier scores (~70%+) as the ceiling you are trading away for privacy and cost.
| Model | Params | Best for | Aider edit reliability | Notes |
|---|---|---|---|---|
| Qwen2.5-Coder 32B | 32B | Multi-file refactors, 24 GB cards | Strong | Verdict pick at 24 GB |
| Qwen2.5-Coder 14B | 14B | Everyday single-file edits | Good | Best value on 12–16 GB |
| Qwen2.5-Coder 7B | 7B | Small edits, 8 GB cards | Fair | Use diff edit format |
| DeepSeek-Coder-V2 16B | 16B (MoE) | Fast inference, breadth | Good | MoE keeps active params low |
The Qwen2.5-Coder 32B model card documents its 128k native context and code-specific training mix, which is what makes it hold up inside Aider's structured edit loop. For a data-backed comparison across the whole local-coder field, our recommendations hub ranks these by task. If you are unsure whether a given card can hold a model plus a usable context, the cost calculator estimates memory and total-cost-of-ownership versus a cloud API.
Rule of thumb: on tight VRAM, prefer a smaller model with a larger context window over a bigger model choked to 2k. Aider's reliability is more sensitive to truncation than to raw model size.
Everyday Workflow and Tuning
Launch Aider inside a git repo. Add the files you want it to touch with /add path/to/file.py — this is important, because local models degrade fast when the context is stuffed with irrelevant files. Keep the working set tight. Describe the change in plain English; Aider proposes a diff, applies it, and commits. Use /undo to roll back the last commit if the edit is wrong, and /diff to review before you trust it.
Two settings meaningfully improve local results. First, pick the right edit format: the 32B and 14B handle Aider's default diff format well, but if a smaller model produces broken diffs, force --edit-format whole, which asks for the entire file back — slower but far more robust. Second, lower temperature for determinism; coder models do their best editing near 0. Aider already defaults conservatively here, but you can pin it in the same YAML settings file.
Because everything is local, you can automate around it freely. The BestLLMfor public API (CC BY 4.0) and our open-source MCP server expose the same model-and-benchmark data used across this site, so you can script model selection — for example, choosing the largest Qwen variant that fits a machine's detected VRAM — without scraping pages. Details live on our about page.
Troubleshooting the Three Common Failures
1. Edits apply to the wrong lines or the model "forgets" the file. Almost always the 2048-token default context. Set num_ctx and confirm with /tokens.
2. Malformed diffs / "SEARCH block not found". You are on ollama/ instead of ollama_chat/, or the model is too small for diff format — switch the prefix, then fall back to --edit-format whole.
3. Aider can't reach Ollama. Check OLLAMA_API_BASE, confirm the server is up with curl http://127.0.0.1:11434/api/tags, and on WSL2 use the host IP with OLLAMA_HOST=0.0.0.0.
Verdict
Aider + Ollama is the most capable fully offline coding agent available in mid-2026. It will not replace a frontier cloud model on sprawling architectural work, but for private, cost-free, single-to-few-file editing it is genuinely productive — provided you use ollama_chat/ and fix the context window. Match the model to your VRAM and it delivers.
| Scenario | Recommendation |
|---|---|
| 24 GB VRAM, want the best | Qwen2.5-Coder 32B Q4_K_M, ollama_chat/, num_ctx 32k |
| 12–16 GB, best value | Qwen2.5-Coder 14B, num_ctx 16k, diff format |
| 8 GB, budget | Qwen2.5-Coder 7B, --edit-format whole |
| Privacy is non-negotiable | Any of the above — nothing leaves the machine |
| Need frontier multi-file reasoning | Stay on a cloud API; local isn't there yet |
Frequently Asked Questions
Why use ollama_chat/ instead of ollama/ in Aider?
The ollama_chat/ prefix routes requests through Ollama's chat endpoint, which preserves conversation context and produces clean diffs. The legacy ollama/ prefix uses the completion endpoint and frequently mangles Aider's edit format. The Aider maintainers explicitly recommend ollama_chat/.
Why do my Aider edits reference lines that don't exist?
Ollama defaults every model to a 2048-token context window, so Aider silently truncates your files. Set num_ctx to at least 8192 (16k recommended) in a .aider.model.settings.yml file and verify with the /tokens command in-session.
What is the best Ollama model for Aider?
Qwen2.5-Coder is the current default recommendation. Run the 32B (Q4_K_M) on 24 GB of VRAM, the 14B on 12–16 GB, and the 7B on 8 GB. The coder-tuned Qwen models hold Aider's structured diff format better than general-purpose models of the same size.
Is Aider with Ollama really free and private?
Yes. Ollama runs the model entirely on your own hardware, so there are no API charges and no code or prompts are transmitted off the machine. The only cost is electricity and the up-front hardware.
Can it match Claude or GPT for coding?
Not for large, multi-file architectural work — frontier cloud models still lead there. But for scoped single-file edits, refactors, and bug fixes, a well-configured Qwen2.5-Coder 14B or 32B inside Aider is reliably useful and completely private.
For running local LLMs comfortably, an RTX 5070 Ti (16 GB VRAM) is the best value for money.
Amazon Check RTX 5070 Ti price →As an Amazon Associate, BestLLMfor earns from qualifying purchases, at no extra cost to you. It does not influence our independent rankings.