Pi Agent: Installation & Authentication
Last updated: 2026-08-31
Sharp tools make good work. This lesson gets your Pi Agent development environment up and running in 5 minutes.
1. Requirements
| Item | Minimum | Recommended |
|---|---|---|
| Python | 3.9+ | 3.11+ |
| pip | Latest | Latest |
| OS | Windows / macOS / Linux | Any |
| RAM | 512MB free | 2GB+ |
| Disk | 200MB | 1GB+ |
Verify Python version:
BASH
python --version
# Python 3.11.8
2. Installing Pi Agent
(1) pip Install (Recommended)
BASH
pip install pi-agent
(2) Install from Source
BASH
git clone https://github.com/pi-agent/pi-agent.git
cd pi-agent
pip install -e .
(3) Verify Installation
BASH
pi-agent --version
# Pi Agent v0.8.0
(4) Optional Dependencies
BASH
pip install pi-agent[all] # Install all optional deps
pip install pi-agent[deepseek] # DeepSeek support
pip install pi-agent[local] # Local model support (llama.cpp)
pip install pi-agent[tools] # Extended tool set
3. Authentication & Model Configuration
Pi Agent supports multiple LLM providers. You need to configure API keys before use.
(1) Environment Variables (Recommended)
BASH
# DeepSeek
export PI_DEEPSEEK_API_KEY="sk-xxxxxxxx"
# OpenAI
export PI_OPENAI_API_KEY="sk-xxxxxxxx"
# Anthropic
export PI_ANTHROPIC_API_KEY="sk-ant-xxxxxxxx"
Windows PowerShell:
POWERSHELL
$env:PI_DEEPSEEK_API_KEY = "sk-xxxxxxxx"
(2) Configuration File
Create ~/.pi-agent/config.yaml:
YAML
providers:
deepseek:
api_key: "sk-xxxxxxxx"
base_url: "https://api.deepseek.com"
model: "deepseek-chat"
openai:
api_key: "sk-xxxxxxxx"
model: "gpt-4o"
anthropic:
api_key: "sk-ant-xxxxxxxx"
model: "claude-sonnet-4-20250514"
default_provider: deepseek
(3) In-Code Configuration
PYTHON
from pi_agent import Agent
agent = Agent(
name="my_agent",
provider="deepseek",
api_key="sk-xxxxxxxx",
model="deepseek-chat"
)
4. Model Providers Overview
| Provider | Model Example | Strengths | Price |
|---|---|---|---|
| DeepSeek | deepseek-chat | High cost-effectiveness, excellent Chinese | Low |
| OpenAI | gpt-4o | Strong overall capability | Medium-High |
| Anthropic | claude-sonnet-4-20250514 | Long text, strong code | Medium |
| Local models | llama.cpp | Privacy, offline | Free |
| Ollama | llama3, mistral | Easy local deployment | Free |
Example 1: Multi-Provider Switching (Difficulty: ⭐)
PYTHON
from pi_agent import Agent
deepseek_agent = Agent(provider="deepseek", model="deepseek-chat")
openai_agent = Agent(provider="openai", model="gpt-4o")
result_d = deepseek_agent.chat("Explain quantum computing in one sentence")
result_o = openai_agent.chat("Explain quantum computing in one sentence")
print(f"DeepSeek: {result_d}")
print(f"OpenAI: {result_o}")
5. First Launch Test
After installation and configuration, run a quick test:
BASH
pi-agent chat "Hello, Pi Agent!"
Expected output:
TEXT
📖 Display only
Pi Agent v0.8.0
Provider: deepseek (deepseek-chat)
Hello! I'm Pi Agent, how can I help you?
Alice completed her setup in 3 minutes following these steps. Bob says: "Pi Agent's installation is simpler than most Python tools — install, configure a key, and you're good."
FAQ
Q pip install fails?
A Upgrade pip first (
pip install --upgrade pip). If it's a network issue, use a mirror: pip install pi-agent -i https://pypi.tuna.tsinghua.edu.cn/simple.Q API key configured but not working?
A Check the environment variable name (must have
PI_ prefix), and the config file path (~/.pi-agent/config.yaml). In-code config has highest priority.Q Can I use Pi Agent without an API key?
A Yes. Install
pi-agent[local] and use llama.cpp or Ollama to run local models without any API key. See Lesson 18.Summary
- Python 3.9+ required;
pip install pi-agentgets you started - Three auth methods: environment variables (recommended), config file, in-code config
- Supports multiple LLM providers; DeepSeek offers best value; local models are free
- First launch: use
pi-agent chatto verify your setup
Exercises
- Basic (Difficulty: ⭐): Install Pi Agent and verify with
pi-agent --version. - Intermediate (Difficulty: ⭐⭐): Configure at least two LLM providers, create Agent instances for each, and verify connectivity.
- Advanced (Difficulty: ⭐⭐⭐): Write a script that auto-detects available API keys and lists currently available providers.