Ollama Coding Models: Run Qwen2.5-Coder Locally with a Coding Agent
Ollama runs AI models on your own computer, so code never leaves your machine. As of 25 October 2026, the Ollama library lists qwen2.5-coder in 0.5b, 1.5b, 3b, 7b (about 4.7 GB, the default), 14b (about 9 GB) and 32b (about 20 GB), and deepseek-coder-v2:16b. Run ollama run qwen2.5-coder to chat. To use it inside a coding agent, Ollama documents ollama launch opencode --model qwen2.5-coder (and similar for Claude Code). Small local models are weaker than cloud models, so use them for simple tasks.
Suppose Varun in Kochi works on a client project that must stay offline, and Lena in Munich has a laptop with 16 GB RAM. Both pull qwen2.5-coder:7b, ask it to explain and test small functions, and keep cloud agents for big refactors.
Related pages
See also Codex vs Claude Code, and What Is an MCP Server.
What you will learn in this guide
- Why run locally
- Pick a model size
- Pull and chat
- Call it from Python
- Connect a coding agent
1. Why: privacy, offline, no per-token bill
Local models keep code on your machine, work without internet after download, and do not need a paid plan. The trade-off is speed and quality on small hardware.
2. What: model sizes
| Model tag | Download size and fit |
|---|---|
| qwen2.5-coder:1.5b | Very small; old laptops, autocomplete-type tasks |
| qwen2.5-coder:7b (default) | About 4.7 GB; good start on 16 GB RAM |
| qwen2.5-coder:14b | About 9 GB; needs more RAM or a GPU |
| qwen2.5-coder:32b | About 20 GB; strong GPU or lots of RAM |
| deepseek-coder-v2:16b | Alternative coding model |
Figure 1. Local coding model in five steps: install Ollama, pick a size, pull and chat, call from code, launch an agent.
3. How: set it up
- Install Ollama from ollama.com (Windows, macOS or Linux).
- Choose a size: start with 7b on 16 GB RAM; 1.5b or 3b on 8 GB.
- Run ollama run qwen2.5-coder and ask a question.
- Call it from Python using the local API at localhost:11434.
- Optionally run ollama launch opencode --model qwen2.5-coder.
4. Source
- ollama.com/library/qwen2.5-coder tags and sizes (checked 25 Oct 2026).
- Ollama docs for ollama launch with coding tools.
- Sizes are downloads; RAM needed is higher.
5. Worked example 1: pull and chat (start here)
In a terminal:
ollama run qwen2.5-coder "Write a Python function is_palindrome(s) with 2 tests."
Expected output (yours will be similar, not the same):
def is_palindrome(s: str) -> bool:
s = "".join(c.lower() for c in s if c.isalnum())
return s == s[::-1]
...
The first run downloads about 4.7 GB.
6. Worked example 2: call it from Python
pip install requests, then save as ask.py:
import requests
r = requests.post("http://localhost:11434/api/generate", json={
"model": "qwen2.5-coder",
"prompt": "Explain what a Python list comprehension is in 2 lines.",
"stream": False,
})
print(r.json()["response"])
Expected output (yours will be similar, not the same):
A list comprehension builds a new list in one line,
for example [x*2 for x in nums].
7. Worked example 3: connect a coding agent
With OpenCode installed:
ollama launch opencode --model qwen2.5-coder
Expected output (yours will be similar, not the same):
OpenCode opens in your terminal using the local qwen2.5-coder model.
Ollama docs also show launching Claude Code against a local model; check the docs for setup notes.
Names, amounts and companies in the examples are made up for practice.
8. Common mistakes
| Mistake | Risk | Fix |
|---|---|---|
| Pulling 32b on an 8 GB laptop | Very slow or crashes | Start with 7b or smaller |
| Expecting cloud-level quality | Disappointment | Use for small tasks |
| Exposing port 11434 to the internet | Anyone can use it | Keep it local |
| Low disk space | Download fails | Free 10+ GB |
| Not testing generated code | Bugs | Run tests |
9. Try at home
Try at home
- Install Ollama.
- Run qwen2.5-coder once.
- Call it from Python.
Recap
In short
- Ollama runs models locally.
- qwen2.5-coder 7b (~4.7 GB) is a good start.
- ollama run to chat; localhost:11434 for code.
- ollama launch connects coding agents.
- Small models suit small tasks.
Local is private; pick a size your machine can carry.
Frequently asked questions
Is Ollama free?
Yes, Ollama and these open models are free to download and run locally.
Do I need a GPU?
No, but it is much faster with one. CPU works for small models.
Which is better, Qwen or DeepSeek?
Try both on your own tasks; results vary by language and project.
Is my code sent online?
Not when using local models. Cloud models in Ollama are different; check which you picked.
Related: Run an LLM Locally with Ollama on Windows and Mac (Beginners)