Pi Coding Agent: Install, Configure Models, and Use It Safely

Pi is a minimal terminal coding harness you can reshape with extensions, skills, and custom models. Install it, configure a provider, and verify it safely.

September 7, 2026 · 4 min read
default tools
4
default tools
runtime modes
4
runtime modes
built-in providers
15+
built-in providers
license
MIT
license

What Is the Pi Coding Agent?

Pi is a minimal, open-source terminal coding harness. Its design is less about shipping every agent feature and more about giving you a small core that you can reshape. The current project is maintained by Earendil, and the canonical package is @earendil-works/pi-coding-agent.

The official Pi site describes four ways to run it: an interactive terminal UI, print or JSON output for scripts, an RPC process, and an embeddable SDK. Sessions are stored as trees, so you can branch from an earlier point without copying a flat transcript.

The useful mental model is harness, not sealed assistant. If you want a preassembled agent with a fixed permission system and workflow, compare the broader options in our AI coding agent guide. Choose Pi when controlling the harness itself is part of the job.

Old package name warning

Pi moved to Earendil in May 2026, so many tutorials now show a stale package namespace. The current official command uses @earendil-works/pi-coding-agent. Prefer the command published on pi.dev instead of copying an older post.

What Pi Includes—and What It Leaves to You

Pi gives the model four tools by default: read, write, edit, and bash. Project instructions come from AGENTS.md; skills, extensions, prompt templates, and themes provide the customization layer. The small default tool set makes the execution loop easy to reason about, but it does not make the loop harmless.

Included in the core

Terminal UI, four file-and-shell tools, tree-structured sessions, compaction, project instructions, model switching, print/JSON mode, RPC, and an SDK.

Added when you need it

Sub-agents, MCP, permission gates, plan mode, background shell execution, task lists, custom tools, and alternate interfaces arrive through extensions or packages.

Pi's design boundary
CapabilityDefault behaviorHow to change it
Model access15+ built-in providersAdd OpenAI-, Anthropic-, or Google-compatible providers in models.json
Project contextLoads AGENTS.mdAdd SYSTEM.md, skills, prompt templates, or dynamic-context extensions
PermissionsNo permission popupsInstall or build a confirmation or path-protection extension
Sub-agentsNot built inSpawn Pi processes or install a sub-agent package
MCPNot built inUse CLI tools with skills or add an MCP extension
PlanningNo fixed plan modeWrite plans to files or add a workflow extension

Install Pi with the Current Package

The official installer is the shortest path. Package-manager installs use --ignore-scriptsbecause Pi does not need dependency lifecycle scripts for a normal global installation. This guide was verified with the Pi 0.85.1 npm package on September 7, 2026; that package requires Node.js 22.19 or newer.

Install Pi on macOS or Linux

curl -fsSL https://pi.dev/install.sh | sh

# Or choose one package manager:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
pnpm add -g --ignore-scripts @earendil-works/pi-coding-agent
bun add -g --ignore-scripts @earendil-works/pi-coding-agent

Start pi inside a repository, then use /login for a built-in provider. Use/model or Ctrl+L to select a model. Pi's model picker only exposes models for which it can resolve authentication, which matters when you add a custom provider next.

Configure a Custom Model Provider

Pi reads custom providers from ~/.pi/agent/models.json. According to the official custom-model documentation, a provider needs a base URL, a supported API format, and one or more model definitions. Authentication can come from /login, the CLI, or an environment-backedapiKey value.

The dollar sign is significant

In models.json, "$MORPH_API_KEY" reads the environment variable."MORPH_API_KEY" without the dollar sign is treated as the literal API key. Keeping the secret out of the JSON file also keeps it out of source control and copied configuration snippets.

Run Pi on Morph

Morph's public chat models expose an OpenAI-compatible Chat Completions endpoint and support tool calls, which is the interface Pi needs for its read, write, edit, and bash loop. The example below is generated from this repository's pricing and model constants, so the model ID, context window, and displayed costs stay tied to the product source of truth.

Custom configuration, not a built-in integration

Morph is configured here as an independent custom OpenAI-compatible provider. It is not a built-in Pi provider, partnership, or endorsement. Pi's documented custom-provider interface is the integration boundary.

~/.pi/agent/models.json

{
  "providers": {
    "morph": {
      "baseUrl": "https://api.morphllm.com/v1",
      "api": "openai-completions",
      "apiKey": "$MORPH_API_KEY",
      "authHeader": true,
      "models": [
        {
          "id": "morph-glm53-744b",
          "name": "Morph GLM-5.3 744B",
          "reasoning": true,
          "input": [
            "text"
          ],
          "contextWindow": 1048576,
          "maxTokens": 16384,
          "cost": {
            "input": 1,
            "output": 3.41,
            "cacheRead": 0.2,
            "cacheWrite": 0
          }
        }
      ]
    }
  }
}

The model has a 1M-token context window, but this client configuration deliberately caps each response at 16,384 tokens. Pi treats maxTokens as a real provider output ceiling, not display metadata. Raise it only when a task needs longer individual responses and you have set an appropriate spend boundary.

Export the key, confirm that Pi can see the provider, and select the model:

Select the Morph provider

export MORPH_API_KEY="your-morph-api-key"

pi --list-models morph
pi --provider morph --model morph-glm53-744b
Tested Morph model configuration
ModelContextInput / output per 1MUse it when
morph-glm53-744b1M$1 / $3.41The tested tool-capable text model used in this guide

Pi is free to install under the MIT license, but requests to a hosted model are billed by that provider. Check the live Morph model catalog before adding another model; identifiers, context windows, and rates can change faster than this guide.

Fast Apply is not the agent model

Do not configure morph-v3-fast as Pi's general reasoning model. Fast Apply merges a proposed edit into original code; it is not a chat model that drives an agent loop. A native Pi Fast Apply workflow would need an extension that calls it at the edit layer. The configuration above uses a tool-capable chat model instead. See how Fast Apply works.

Verify the Setup Before Allowing Edits

First confirm that pi --list-models morph prints the configured model. Then run a read-only prompt in non-interactive JSON mode. This checks authentication, model resolution, tool calling, and repository access without asking Pi to change a file.

We ran this exact configuration against Pi 0.85.1 with both reasoning off and medium. In each run, Pi requested the built-in read tool, consumed its result, and completed the answer. No additionalcompat overrides were required for that tested package-and-endpoint pair.

Read-only smoke test

pi --provider morph --model morph-glm53-744b   --thinking off   --tools read   --no-context-files   --no-extensions   --no-skills   --no-prompt-templates   --no-session   --mode json   -p "Use the read tool exactly once to read package.json, then answer with only the packageManager field."

Confirm the JSON event stream contains tool_execution_start andtool_execution_end for read, followed by agent_end. A prose answer alone does not prove that the tool loop worked. This test allows only the read tool and stores no session. It proves the basic API path, not that unattended work is safe. A disposable branch helps review and recover tracked changes, but it does not isolate credentials, untracked files, network access, or external systems. Use a container, VM, or restricted user as the security boundary, then inspect the diff and run the repository's checks before keeping an editing task.

Security and Troubleshooting

Pi has no built-in sandbox or permission popups. Its tools and extensions run with the same operating-system permissions as the Pi process. For unfamiliar repositories or prompts, use a container, a restricted user, or a permission extension. Treat an AGENTS.md file as executable guidance: read it before granting the agent access to credentials or production tooling. Pi's official security guidance explains this trust model.

Common Pi provider failures
SymptomLikely causeCheck
Morph model is absent from /modelPi cannot resolve authenticationExport MORPH_API_KEY and keep the leading $ in models.json
401 UnauthorizedMissing or invalid keyCheck the environment in the same shell that launches Pi
404 or route not foundWrong base URLUse https://api.morphllm.com/v1, including /v1
Model not foundStale or mistyped model IDCheck the authenticated /v1/models catalog before editing models.json
429 Too Many RequestsCapacity or rate limitHonor Retry-After and retry with exponential backoff
Model answers but never uses toolsA non-tool model or wrong API formatUse a public Morph chat model with api set to openai-completions
Pi can modify more than expectedDefault harness has no permission UIStop the session and add isolation or a permission extension

Pi reloads models.json when you open /model, so you can correct configuration during a session. For the public model catalog and API behavior, use the Morph model documentation rather than copying rates or identifiers from a third-party post.

FAQ

What is the Pi coding agent?

Pi is an open-source terminal coding harness from Earendil. It gives the model read, write, edit, and bash tools, then lets you add workflows through extensions, skills, prompt templates, themes, and packages.

How do I install Pi?

Use the standalone installer at pi.dev or install the current @earendil-works/pi-coding-agent package globally with npm, pnpm, or Bun. The Pi 0.85.1 npm package requires Node.js 22.19 or newer.

Does Pi support custom model providers?

Yes. Add a provider and its models to ~/.pi/agent/models.json. Pi supports OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, and Google Generative AI compatible APIs.

Can Pi use Morph models?

Yes. Pi can call Morph through its OpenAI-compatible API. Configure https://api.morphllm.com/v1 as the base URL, use openai-completions, and reference MORPH_API_KEY as an environment variable.

Does Pi include MCP and sub-agents?

Not as built-in defaults. Pi deliberately keeps MCP, sub-agents, plan mode, permission gates, and background shell execution out of its core. You can add those behaviors with extensions or packages.

Is Pi safe to run on a repository?

Pi has no built-in sandbox or permission popups, and its tools and extensions run with the launching user’s permissions. Use a container, VM, or restricted user for isolation. A disposable branch helps review and recover tracked files, but it is not a security boundary.

Use a tool-capable Morph model in Pi

Create one API key, add the OpenAI-compatible provider block, and verify the model with a read-only task before editing your repository.