Ruv Pi: The Self-Extensible Coding Agent CLI with Multi-Provider
Ruv Pi is a self-extensible coding agent CLI from Earendil Works that provides a unified multi-provider LLM API, enabling developers to build, run, and extend AI-powered coding agents with support for Claude, OpenAI, Gemini, and more.
- ⭐ 68376
- Updated 2026-06-10
Introduction #
The landscape of AI coding tools has become remarkably fragmented. Developers juggle between Claude Code, Cursor, Copilot, Codex, and a growing zoo of CLI tools — each with its own configuration, pricing, and capabilities. Managing multiple model providers, each with different APIs, rate limits, and token costs, has become a significant operational burden for teams building intelligent applications.
Ruv Pi (also known as pi-agent) from Earendil Works addresses this fragmentation head-on. With 61,200 GitHub stars, it has become one of the most popular coding agent frameworks available. Pi provides a self-extensible coding agent CLI backed by a unified multi-provider LLM API, letting developers write code once and run it across any model provider.
Disclosure: This article may contain affiliate links. If you sign up through them, I may earn a small commission at no extra cost to you. Disclosure Policy
DigitalOcean - Reliable cloud infrastructure for your AI applications. HTStack - High-performance server hosting. WebShare - Premium proxy services for AI data pipelines.

What Is Ruv Pi? #
Ruv Pi is a self-extensible coding agent CLI that provides an agent runtime with tool calling capabilities and a unified multi-provider LLM API. Think of it as the bridge between your coding needs and the ever-growing world of LLM providers.
At its core, Pi is built on two pillars:
- Self-Extensible Agent Runtime — The agent can add new tools, modify its own behavior, and extend its capabilities at runtime. If a task requires a tool that doesn’t exist, Pi can create it.
- Unified Multi-Provider LLM API — A single API call that works with OpenAI, Anthropic, Google, and other providers. You specify which model you want; Pi handles the rest.
Feature Image:

Core Architecture #
Pi’s architecture is designed around three main components:
Agent Runtime #
The agent runtime is the brain of the system. It maintains conversation context, manages tool execution, and orchestrates the interaction between the user, the LLM, and external tools. The runtime is stateful, maintaining conversation history and tool state across multiple interactions.
Tool System #
Pi’s tool system is what makes it self-extensible. Tools are functions that the agent can call to interact with the external world — reading files, executing commands, making API calls, running tests, and more. The unique aspect is that the agent can generate new tools on the fly when it encounters a task that requires capabilities it doesn’t currently have.
# Example: Define a custom tool for Pi
from pi_agent import tool
@tool(description="Calculate compound interest")
def calculate_compound_interest(
principal: float,
rate: float,
time: int,
compounds_per_year: int = 12
) -> dict:
"""Calculate compound interest for given parameters."""
result = principal * (1 + rate / compounds_per_year) ** (compounds_per_year * time)
return {
"final_amount": round(result, 2),
"interest_earned": round(result - principal, 2)
}
Unified LLM API #
The unified API abstracts away the differences between model providers. Whether you want to use GPT-4o, Claude Sonnet, Gemini Pro, or any other supported model, the API is consistent. This means you can switch providers by changing a single configuration value.
# Configure Pi to use different providers
# Use OpenAI
export PI_PROVIDER=openai
export PI_MODEL=gpt-4o
# Switch to Anthropic
export PI_PROVIDER=anthropic
export PI_MODEL=claude-sonnet-4-20250514
# Switch to Google
export PI_PROVIDER=google
export PI_MODEL=gemini-pro
# Use Pi's default smart routing
export PI_PROVIDER=auto
How It Works #
Pi operates through a continuous loop of three phases:
- Think — The agent analyzes the user’s request, breaking it down into subtasks and determining which tools are needed.
- Act — The agent calls the appropriate tools, executing code, reading files, querying databases, or making API calls.
- Reflect — The agent evaluates the results, checking for errors or incomplete work, and decides whether to continue or report completion.
# Start a Pi session
pi start --model claude-sonnet-4-20250514
# Start with automatic model selection
pi start --auto
# Start with a specific task
pi start --task "Refactor the authentication module to use JWT"
The agent maintains a conversation context that persists across invocations. You can think of it as a coding assistant that remembers what you’ve discussed and built in previous sessions.
# Continue a previous session
pi continue --session-id abc123
# List all sessions
pi sessions list
# Archive a completed session
pi sessions archive abc123
Installation #
Installing Pi is straightforward. The primary installation method is through pip:
# Install via pip
pip install pi-agent
# Verify the installation
pi --version
# Check available providers
pi providers list
Alternatively, you can install through npm if you prefer a JavaScript-based setup:
# Install via npm
npm install @earendil-works/pi-coding-agent
# Verify the installation
npx pi --version
For development or to contribute to the project:
# Clone the repository
git clone https://github.com/earendil-works/pi.git
# Navigate to the directory
cd pi
# Install development dependencies
pip install -e '.[dev]'
# Run tests
pytest tests/
Integration Patterns #
Pi is designed to integrate seamlessly into existing development workflows. Here are the key integration patterns:
Git Integration #
Pi can interact with your Git repository, making commits, creating branches, and managing pull requests:
# Configure Git integration
export PI_GIT_ENABLED="true"
export PI_GIT_AUTO_COMMIT="true"
export PI_GIT_COMMIT_MESSAGE="Auto-commit by Pi agent"
# Let Pi manage Git operations
pi start --task "Refactor database module and commit changes"
CI/CD Pipeline Integration #
Pi can be integrated into CI/CD pipelines for automated testing, code review, and deployment:
# Configure Pi for CI/CD
export PI_CI_ENABLED="true"
export PI_CI_MODE="review" # review, test, or deploy
# Run in CI review mode
pi ci-review --base main --head feature-branch
IDE Integration #
Pi works alongside your preferred IDE, providing intelligent suggestions and executing tasks:
# Start Pi in watch mode, monitoring file changes
pi watch --directory ./src --interval 5
# Integrate with VS Code via extension
# Install the Pi extension for VS Code from the marketplace
Multi-Provider Routing #
One of Pi’s most powerful features is intelligent model routing. Based on the task type, Pi can automatically select the best model:
# pi-config.yaml
routing:
code_generation:
model: claude-sonnet-4-20250514
temperature: 0.3
code_review:
model: gpt-4o
temperature: 0.1
debugging:
model: claude-sonnet-4-20250514
temperature: 0.5
documentation:
model: gemini-pro
temperature: 0.3
default:
model: auto
temperature: 0.7

Benchmarks and Performance #
Model Comparison #
Pi’s unified API enables direct comparison of different models on the same tasks:
| Task Type | Best Model (Pi Auto-Select) | Avg. Latency | Cost per 1K tokens | |
💬 Discussion