Pi

An open-source, multi-provider coding agent with a powerful extension system.

What is Pi?

Pi is an open-source AI coding agent built on a modular architecture. Unlike single-provider agents, Pi connects to any AI provider — Anthropic, OpenAI, Google, Groq, Mistral, Ollama, or any OpenAI-compatible endpoint. It features a rich extension system, built-in skills, and a session tree that lets you fork and navigate conversation branches.

Pi is a separate project from OpenCode. While both support multiple providers, Pi has its own extension system, skill framework, and session management with conversation tree navigation.

Key Features

Multi-Provider

Use any AI provider: Anthropic (Claude), OpenAI (GPT), Google (Gemini), Groq, Mistral, Ollama, or any OpenAI-compatible API. Switch models mid-session.

Extension System

Extend Pi with custom tools, commands, and UI elements via the extension API. Extensions can register tools, add commands, and show dialogs on your phone.

Session Tree & Forking

Navigate your conversation as a tree. Fork from any point to explore different approaches without losing context. Export sessions to HTML.

Built-in Skills

Pi includes skills for git workflows, code review, documentation, investigation, and more — loaded on demand to keep context focused.

Smart Context Management

Auto-compaction keeps sessions within context limits. Configurable reserve tokens, retry policies, and thinking budgets per model.

Setup

1. Install Pi

bash
npm i -g @mariozechner/pi-coding-agent

2. Configure a Provider

Pi needs at least one AI provider API key. Set the environment variable for your preferred provider:

bash
# Anthropic (Claude)
export ANTHROPIC_API_KEY=sk-ant-...

# OpenAI (GPT)
export OPENAI_API_KEY=sk-...

# Google (Gemini)
export GOOGLE_GENERATIVE_AI_API_KEY=...

# Groq
export GROQ_API_KEY=gsk_...

# Or any OpenAI-compatible endpoint
export OPENAI_API_BASE=http://localhost:11434/v1
export OPENAI_API_KEY=ollama

3. Start Broski

bash
broski

Select Pi as your backend in the Broski app settings.

Supported Providers

ProviderModelsAPI Key Variable
AnthropicClaude 4 Sonnet, Claude 4 Opus, Claude 3.5 SonnetANTHROPIC_API_KEY
OpenAIGPT-4o, GPT-4o mini, o1, o3OPENAI_API_KEY
GoogleGemini 2.5 Pro, Gemini 2.5 FlashGOOGLE_GENERATIVE_AI_API_KEY
GroqLlama, MixtralGROQ_API_KEY
MistralMistral Large, CodestralMISTRAL_API_KEY
OllamaAny local modelOPENAI_API_BASE + OPENAI_API_KEY
You can switch models mid-session from the model picker in the Broski app. Pi dynamically discovers available models from your configured providers.

Thinking Levels

Pi supports configurable thinking levels for models that support extended thinking (Claude, o1/o3, Gemini). Toggle thinking from the chat overflow menu in Broski.

LevelDescriptionBest For
OffNo extended thinkingFast responses, simple tasks
LowBrief reasoningStandard coding tasks
HighDeep reasoningComplex architecture, debugging

Extensions

Pi's extension system lets you add custom tools, commands, and UI interactions. Extensions are loaded from your project or global configuration.

bash
# Extensions are configured in Pi settings
# View available extensions in Broski:
# Chat menu → Skills/Commands

Session Management

Pi sessions are stored locally and support tree-based navigation:

  • Fork: Branch from any message to explore alternatives
  • Navigate: Move between branches in the session sidebar
  • Compact: Auto or manual context compaction to stay within limits
  • Export: Export sessions to HTML for sharing or archiving

Pi vs Other Backends

FeaturePiClaude CodeOpenCodeCodex
ProvidersMulti (any)Anthropic only75+ providersOpenAI only
Open SourceYesNoYesYes
ExtensionsYes (plugin API)PluginsPluginsApps
Session TreeYes (fork/navigate)NoNoNo
HTML ExportYesNoNoNo
MCP SupportNoYesFullYes
SandboxNoNoNoYes (built-in)
Thinking LevelsConfigurablePresetsVariantsReasoning effort

Troubleshooting

"Pi not found"
bash
# Install Pi globally
npm i -g @mariozechner/pi-coding-agent

# Verify installation
which pi
pi --version
No models available

Pi needs at least one provider API key configured. Check your environment variables:

bash
echo $ANTHROPIC_API_KEY
echo $OPENAI_API_KEY
echo $GOOGLE_GENERATIVE_AI_API_KEY
Context too long

Use the compact command from the chat menu, or enable auto-compaction in Pi settings. You can also fork the session to start fresh with a summary.

Run broski doctor --profile agents to verify Pi is correctly detected and configured.