Skip to content

Pi

Lean by design. Multi-model by default.

Pi keeps its system prompt under 1,000 tokens — an order of magnitude lighter than most commercial agents. Swap model providers without rewriting agent logic. Run fully local with Ollama. Embed in any TypeScript service via createAgentSession().

Pi CLIMITbadlogic/pi-mono

Three modes

Getting started

01

Install Pi

Terminal window
npm install -g @earendil/pi-agent
# macOS alternative
brew install earendil-works/tap/pi
02

Configure your models

Create ~/.pi/models.json to point Pi at one or more providers. Pi will use the first entry as default.

{
"default": "anthropic-messages/claude-sonnet-4-5",
"providers": {
"anthropic-messages": {
"apiKey": "sk-ant-..."
},
"openai-completions": {
"apiKey": "sk-..."
},
"ollama": {
"baseUrl": "http://localhost:11434"
}
}
}
03

Run Pi — or embed it

Interactive terminal session:

Terminal window
pi
# Switch model mid-session
/model openai-completions/gpt-4o
# Fork the current context into a branch
/fork
# View session tree
/tree

Programmatic via SDK:

import { createAgentSession } from '@earendil/pi-sdk';
const session = await createAgentSession({
model: 'anthropic-messages/claude-sonnet-4-5',
systemPrompt: 'You are a financial analysis agent.',
tools: ['read', 'write', 'bash'],
});
for await (const event of session.run('Analyse Q1 revenue data')) {
if (event.type === 'text') process.stdout.write(event.text);
}

Built-in tools

ToolAvailabilityNotes
readBuilt-inRead files and directory trees
writeBuilt-inCreate and overwrite files
editBuilt-inSurgical in-place edits
bashBuilt-inExecute shell commands; no sandbox by default
Skills (Lazy)Add-onCustom skill definitions loaded on demand — not in the base system prompt
Community pluginsAdd-onnpm packages that extend Pi’s toolset (web search, Slack, databases)

Model providers

Provider keyModelsData egress
anthropic-messagesClaude Sonnet, Haiku, OpusAnthropic API
openai-completionsGPT-4o, o3-mini, o1OpenAI API
google-generative-aiGemini 2.5 Pro / FlashGoogle API
mistralMistral Large, CodestralMistral API
azure · bedrockAzure OpenAI, AWS Bedrock hosted modelsYour cloud region
ollama · lm-studio · vllmLlama 3, Mistral, Phi-3, Qwen, any GGUFNone — fully local

When to use Pi

01

Context efficiency is critical — every token counts

Pi’s system prompt stays under 1,000 tokens. Claude Code and Codex typically consume 8,000–10,000 tokens of context on every turn just for instructions. In a high-volume pipeline running thousands of agent calls per day, that overhead compounds fast. Pi leaves virtually all of the context window for actual task data.

02

Multi-model routing — different tasks, different models, same agent logic

Pi’s provider layer decouples the agent from the underlying model. Route expensive reasoning tasks to Claude Opus, fast retrieval to Gemini Flash, cost-sensitive batch work to Mistral, and sensitive data processing to a local Ollama instance — all within the same session or pipeline, without rewriting agent logic per provider.

03

Data sovereignty — no tokens leave your infrastructure

Pair Pi with Ollama or LM Studio on a local or on-premise machine. Zero data egress. No API keys. No third-party logging. This is the right setup for maritime ISM Code records, crew PII, confidential contracts, or any data with jurisdictional residency requirements.

04

Embedding agents in your own products via SDK

Use createAgentSession() from @earendil/pi-sdk to embed a full agent session into any TypeScript service — a Next.js API route, an Express microservice, or a background worker. Stream events, intercept tool calls, fork sessions for parallel explorations, and dispose sessions cleanly when done. MIT license means zero friction in commercial products.