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.

  1. Install it (macOS / Linux):

    curl -fsSL https://pi.dev/install.sh | sh
  2. Start Ollama with a 64k context window (or set the context slider in the Ollama app's settings).

    OLLAMA_CONTEXT_LENGTH=64000 ollama serve
  3. In a second terminal, pull a tool-capable coding model (replace qwen3-coder:30b with any model you prefer).

    ollama pull qwen3-coder:30b
  4. Quickest path: let Ollama install Pi if needed, configure it and start a session.

    ollama launch pi
  5. Or 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"
            }
          ]
        }
      }
    }
  6. 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-agent

Check 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/health

Which 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.

MachineModelQuantContextFitOllama
12 GB GPUQwen 3.5 9BQ4_K_M32,768Comfortable (7.4 GB of 12 GB)qwen3.5:9b
Qwen 3.6 35B-A3BQ4_K_M32,768With CPU offload (MoE) (22.7 GB of 12 GB)qwen3.6:35b-a3b
16 GB GPUQwen 3.5 9BQ4_K_M32,768Comfortable (7.4 GB of 16 GB)qwen3.5:9b
Qwen 3.6 35B-A3BQ4_K_M32,768With CPU offload (MoE) (22.7 GB of 16 GB)qwen3.6:35b-a3b
24 GB GPUQwen3.8 27BQ4_K_M32,768Comfortable (19.9 GB of 24 GB)qwen3.8:27b
Qwen 3.6 27BQ4_K_M32,768Comfortable (19.9 GB of 24 GB)qwen3.6:27b
Devstral Small 2 24BQ4_K_M32,768Comfortable (20.7 GB of 24 GB)devstral-small-2:24b
Qwen 3.6 35B-A3BQ4_K_M65,536Tight (23.3 GB of 24 GB)qwen3.6:35b-a3b
32 GB GPUQwen3.8 27BQ4_K_M32,768Comfortable (19.9 GB of 32 GB)qwen3.8:27b
Qwen 3.6 27BQ4_K_M32,768Comfortable (19.9 GB of 32 GB)qwen3.6:27b
Devstral Small 2 24BQ4_K_M32,768Comfortable (20.7 GB of 32 GB)devstral-small-2:24b
Qwen 3.6 35B-A3BQ4_K_M65,536Comfortable (23.3 GB of 32 GB)qwen3.6:35b-a3b
Qwen3-Coder 30B-A3B (MoE)Q4_K_M65,536Comfortable (25.7 GB of 32 GB)qwen3-coder:30b
Mac, 64 GBQwen 3.6 35B-A3BQ8_0131,072Comfortable (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