Pi Coding Agent: Extensible AI Terminal Agent for Developers

A free, open-source CLI AI coding agent. Supports 15+ AI providers, TypeScript extensions, and OAuth login with Anthropic or OpenAI subscriptions.

Pi is a free, open-source AI coding agent that runs AI models against your codebase.

It ships as a minimal harness with four built-in tools (read, write, edit, bash) and expands through TypeScript extensions, skills, prompt templates, and installable packages.

Pi coding agent is designed for developers who want full control over how their coding agent behaves.

It currently supports 15+ major AI providers, lets you switch models mid-session, branches session history like a Git tree, and exposes every layer of its internals for modification.

Features

  • Runs on Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, Hugging Face, Kimi For Coding, MiniMax, OpenRouter, Ollama, and more, authenticated via API keys or OAuth.
  • Accepts existing subscriptions from Anthropic Claude Pro/Max, OpenAI ChatGPT Plus/Pro (Codex), and GitHub Copilot.
  • Allows you to switch models mid-session with /model or Ctrl+L, and cycle a curated list with Ctrl+P.
  • Stores sessions as JSONL trees so every branch is preserved in a single file.
  • Loads project instructions at startup from AGENTS.md files found in the working directory, parent directories, and a global config path.
  • Compresses older messages automatically when approaching context limits, with compaction behavior customizable through extensions.
  • Includes TypeScript extension API for registering tools, commands, keyboard shortcuts, event handlers, and custom TUI components.
  • Supports on-demand skill packages following the Agent Skills standard, loaded manually with /skill:name or automatically based on task context.
  • Exports sessions to HTML with /export or to a shareable GitHub gist with /share.
  • Runs in four modes: interactive TUI, print/JSON for scripts, RPC over stdin/stdout for non-Node integrations, and an SDK for embedding in your own apps.
  • Packages bundle extensions, skills, prompts, and themes for distribution via npm or git.

Best For

  • Developers who prefer terminal-based coding workflows.
  • Users who want an open-source AI coding agent.
  • Developers who want custom tools, commands, or workflows.
  • Teams that use project instruction files across repositories.
  • Users who want model choice across several providers.
  • Developers who want to package and share agent customizations.
  • Advanced users who want SDK, RPC, or JSON event access.

Who Should Skip It

  • Users who want a polished web app.
  • Beginners who dislike terminal setup.
  • Teams that need built-in enterprise controls.
  • Developers who want native sub-agents by default.
  • Users who want built-in plan mode.
  • Users who want one provider and one fixed workflow.
  • Non-technical users who need a simple chat interface.

Pi vs Claude Code

PiClaude Code
Best fitExtensible, provider-agnostic terminal agentAnthropic-native terminal coding agent
Free accessFree install; pay for model API or use existing subscriptionFree install; requires Anthropic subscription or API key
Setup difficultynpm install or one-line curl; API key or OAuth loginnpm install; Anthropic account required
Provider support15+ providers and custom modelsAnthropic models only
CustomizationFull TypeScript extension API; packageable and shareableLimited user-side customization
Sub-agents / plan modeNot built in; buildable via extensions or packagesSupported natively
Session managementTree-structured JSONL with branching and exportLinear sessions with standard history
Main limitationMinimal defaults require extension work for advanced featuresSingle-provider lock-in

Choose Pi if you want an AI coding agent you can extend, script, or embed, or if you need multi-provider model access in a single CLI.

Choose Claude Code if you are already inside the Anthropic ecosystem and want a production-ready agent with native Anthropic features and no extension overhead.

Setup

Install Pi with the one-line shell installer:

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

Or install via npm:

npm install -g @earendil-works/pi-coding-agent

Authenticate with an API key:

export ANTHROPIC_API_KEY=sk-ant-...
pi

Or log in with an existing subscription:

pi
/login

Type /login inside the interactive session and select your provider. Pi then loads with the default four tools (read, write, edit, bash) and you can start coding immediately.

Related Resources

Alternatives

Pros

  • Open source core.
  • Free to install.
  • 15+ model providers in one agent.
  • Existing subscription support (Anthropic, OpenAI, Copilot).
  • Full TypeScript extension API.
  • Tree-structured session branching.
  • Packageable and shareable extensions.
  • SDK and RPC modes for programmatic use.

Cons

  • Setup is heavier than GUI-based tools.
  • Packages carry full system access risk.
  • No web or mobile interface.
  • Multi-provider power users only.
  • Windows requires extra terminal configuration.

FAQs

Q: Is Pi free to use?
A: Pi itself is free and open source. You pay only for the underlying model API calls, or nothing at all if you use an existing Anthropic, OpenAI, or GitHub Copilot subscription via OAuth login.

Q: Can I use Pi without sending data to external APIs?
A: Yes, if you configure a local model provider such as Ollama. Pi supports custom providers via models.json, so traffic stays local once a local model backend is set up.

Q: Does Pi support plan mode or sub-agents?
A: Not by default. Pi’s philosophy is to expose the primitives and let users build those features themselves via TypeScript extensions or install third-party packages that implement them.

Q: How does Pi handle long sessions and context limits?
A: Pi auto-compacts older messages when approaching the context limit. Full session history stays in the JSONL file, but compacted messages are summarized rather than preserved verbatim. You can revisit uncompacted history via the /tree branch navigator.

Q: Is it safe to install third-party Pi packages?
A: Third-party packages run with full system access, including the ability to execute arbitrary code and run system commands. Pi’s own documentation recommends reviewing source code before installing any third-party package.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest & top AI tools sent directly to your email.

Subscribe now to explore the latest & top AI tools and resources, all in one convenient newsletter. No spam, we promise!