Pi coding agent with a local model: setup for Ollama, LM Studio or llama.cpp
Pi is a minimal, extensible open-source (MIT) coding agent for the terminal, with four core tools (read, write, edit, bash) and a very short system prompt. It has a built-in llama.cpp router integration and connects to Ollama, LM Studio and other OpenAI-compatible servers through ~/.pi/agent/models.json, which suits people who want a small prompt on a tight context budget.
At a glance
- Type
- cli
- Licence
- MIT
- Latest release
- 1.3.0 (2026-10-15)
- Status
- Maintained
- Local backends
- openai-compatible, anthropic-compatible, ollama, lmstudio, llamacpp
- Needs native tool calling
- Not verified
- MCP support
- Yes
- Recommended minimum context
- Not stated in its docs
- Start-up prompt
- ~600 tokens (single third-party measurement)
- GitHub stars
- 116.3k (2026-10-19)
How to set it up with a local model
Pick your backend. Each command has its own Copy button. Where a step uses an example model, swap in the one you run; the table below lists the ones that fit your machine.
Install it (macOS / Linux):
curl -fsSL https://pi.dev/install.sh | shStart Ollama with a 64k context window (or set the context slider in the Ollama app's settings).
OLLAMA_CONTEXT_LENGTH=64000 ollama serveIn a second terminal, pull a tool-capable coding model (replace qwen3-coder:30b with any model you prefer).
ollama pull qwen3-coder:30bQuickest path: let Ollama install Pi if needed, configure it and start a session.
ollama launch piOr add Ollama to Pi's models file yourself (the dummy key makes the model available; Ollama ignores it).
~/.pi/agent/models.json{ "$schema": "https://pi.dev/schemas/models.schema.json", "providers": { "ollama": { "baseUrl": "http://localhost:11434/v1", "api": "openai-completions", "apiKey": "ollama", "models": [ { "id": "qwen3-coder:30b" } ] } } }Make it the default provider and model.
~/.pi/agent/settings.json{ "defaultProvider": "ollama", "defaultModel": "qwen3-coder:30b" }
Other ways to install
npm (Node.js 22.19+)
npm install -g --ignore-scripts @earendil-works/pi-coding-agentCheck that it works
Open /model inside Pi; your local model should be listed. For llama.cpp, check the router is reachable.
curl http://127.0.0.1:8080/healthWhich local models fit, by machine
Checked by this site's engine at the context Pi coding agent needs, with 32 GB of system RAM for MoE offload. A Mac counts three quarters of unified memory as usable.
| Machine | Model | Quant | Context | Fit | Ollama |
|---|---|---|---|---|---|
| 12 GB GPU | Qwen 3.5 9B | Q4_K_M | 32,768 | Comfortable (7.4 GB of 12 GB) | qwen3.5:9b |
| Qwen 3.6 35B-A3B | Q4_K_M | 32,768 | With CPU offload (MoE) (22.7 GB of 12 GB) | qwen3.6:35b-a3b | |
| 16 GB GPU | Qwen 3.5 9B | Q4_K_M | 32,768 | Comfortable (7.4 GB of 16 GB) | qwen3.5:9b |
| Qwen 3.6 35B-A3B | Q4_K_M | 32,768 | With CPU offload (MoE) (22.7 GB of 16 GB) | qwen3.6:35b-a3b | |
| 24 GB GPU | Qwen3.8 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 24 GB) | qwen3.8:27b |
| Qwen 3.6 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 24 GB) | qwen3.6:27b | |
| Devstral Small 2 24B | Q4_K_M | 32,768 | Comfortable (20.7 GB of 24 GB) | devstral-small-2:24b | |
| Qwen 3.6 35B-A3B | Q4_K_M | 65,536 | Tight (23.3 GB of 24 GB) | qwen3.6:35b-a3b | |
| 32 GB GPU | Qwen3.8 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 32 GB) | qwen3.8:27b |
| Qwen 3.6 27B | Q4_K_M | 32,768 | Comfortable (19.9 GB of 32 GB) | qwen3.6:27b | |
| Devstral Small 2 24B | Q4_K_M | 32,768 | Comfortable (20.7 GB of 32 GB) | devstral-small-2:24b | |
| Qwen 3.6 35B-A3B | Q4_K_M | 65,536 | Comfortable (23.3 GB of 32 GB) | qwen3.6:35b-a3b | |
| Qwen3-Coder 30B-A3B (MoE) | Q4_K_M | 65,536 | Comfortable (25.7 GB of 32 GB) | qwen3-coder:30b | |
| Mac, 64 GB | Qwen 3.6 35B-A3B | Q8_0 | 131,072 | Comfortable (40.7 GB of 48 GB) | — |
Your exact machine: filter the matrix or check any model in the analyzer.
Common problems with local models
- A models.json entry stays out of /model until Pi can resolve credentials for it, so keep a dummy apiKey for keyless local servers.
- With --no-models-autoload, a llama.cpp model must be loaded through /llama before it appears in /model.
- Pi's llama.cpp guide sets -c 32768; omitting -c uses the model's native context, which may need far more memory.
- Pi does not set Ollama's context window; set it on the server with OLLAMA_CONTEXT_LENGTH or the app slider.
Other coding agents
How they rank for local models: the best agent harness for local LLMs.
Sources (7), checked 2026-10-20
- github.com/earendil-works/pi/blob/main/packages/coding-agent/README.md
- github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md
- github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/llama-cpp.md
- github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/configuration.md
- docs.ollama.com/integrations/pi
- docs.ollama.com/context-length
- lmstudio.ai/docs/cli/local-models/load