Skip to main content

Installation Guide

This guide covers different ways to install AgentRouter and its dependencies.

Requirements

Before installing AgentRouter, ensure you have:

  • Python: Version 3.8 or higher
  • pip: Latest version recommended
  • Operating System: Windows, macOS, or Linux
  • Memory: At least 4GB RAM recommended
  • Network: Internet connection for API calls

Installation Methods

Install from PyPI

The simplest way to install AgentRouter:

pip install agentrouter

This will automatically install all required dependencies including:

  • OpenAI SDK for LLM integration
  • httpx for HTTP requests
  • pydantic for data validation
  • tenacity for retry logic
  • And all other core dependencies listed below

Verify Installation

After installation, verify that AgentRouter is properly installed:

# Check installation
python -c "import agentrouter; print(agentrouter.__version__)"

Expected output:

0.1.0

Dependencies

AgentRouter automatically installs these core dependencies:

PackageVersionPurpose
httpx>=0.24.0HTTP client with async support
openai>=1.0.0OpenAI SDK integration
pydantic>=2.0.0Data validation
python-dotenv>=1.0.0Environment management
tenacity>=8.2.0Retry logic
typing-extensions>=4.7.0Type hints
jsonschema>=4.18.0JSON schema validation
orjson>=3.9.0Fast JSON processing
aiofiles>=23.0.0Async file operations
aiodns>=3.0.0Async DNS resolver
structlog>=23.1.0Structured logging
rich>=13.5.0Rich terminal output
pyyaml>=6.0.1YAML configuration support
backoff>=2.2.0Exponential backoff/retry
cachetools>=5.3.0Caching utilities
validators>=0.20.0Data validators
asyncio-throttle>=1.0.2Async rate limiting
python-dateutil>=2.8.2Date utilities

Optional Dependencies

For additional features:

FeaturePackageInstall Command
Developmentpytest, pytest-asyncio, pytest-cov, black, isort, flake8, mypy, sphinxpip install agentrouter[dev]
Async SupportasyncioIncluded in Python 3.7+

Note: Visualization features are built into the core package and don't require additional dependencies.

Environment Setup

Setting up API Keys

AgentRouter requires API keys for LLM providers. Set them up using environment variables:

Method 1: Using .env file

Create a .env file in your project root:

# .env
AGENTROUTER_API_KEY=your-api-key-here

Load in your Python code:

from dotenv import load_dotenv
import os

load_dotenv()

api_key = os.getenv("AGENTROUTER_API_KEY")

Method 2: Export Environment Variables

# Linux/macOS
export AGENTROUTER_API_KEY="your-api-key-here"

# Windows (Command Prompt)
set AGENTROUTER_API_KEY=your-api-key-here

# Windows (PowerShell)
$env:AGENTROUTER_API_KEY="your-api-key-here"

Method 3: Pass Directly in Code

from agentrouter import ManagerAgent

manager = ManagerAgent(
name="my_manager",
api_key="your-api-key-here", # Direct assignment
model="usf-mini"
)

Virtual Environment Setup

We recommend using a virtual environment:

Using venv

# Create virtual environment
python -m venv agentrouter-env

# Activate on Linux/macOS
source agentrouter-env/bin/activate

# Activate on Windows
agentrouter-env\Scripts\activate

# Install AgentRouter
pip install agentrouter

# Deactivate when done
deactivate

Using conda

# Create conda environment
conda create -n agentrouter python=3.9

# Activate environment
conda activate agentrouter

# Install AgentRouter
pip install agentrouter

# Deactivate when done
conda deactivate

Docker Installation

For containerized deployments:

# Dockerfile
FROM python:3.9-slim

WORKDIR /app

# Install AgentRouter
RUN pip install agentrouter

# Copy your application
COPY . .

# Run your application
CMD ["python", "your_app.py"]

Build and run:

# Build image
docker build -t my-agentrouter-app .

# Run container
docker run -e AGENTROUTER_API_KEY=your-key my-agentrouter-app

Troubleshooting

Common Installation Issues

Issue 1: Permission Denied

# Use --user flag
pip install --user agentrouter

# Or use sudo (not recommended)
sudo pip install agentrouter

Issue 2: SSL Certificate Error

# Upgrade certificates
pip install --upgrade certifi

# Or use trusted host
pip install --trusted-host pypi.org agentrouter

Issue 3: Incompatible Python Version

# Check Python version
python --version

# Install specific Python version
# macOS with Homebrew
brew install python@3.9

# Ubuntu/Debian
sudo apt-get install python3.9

Issue 4: Missing Dependencies

# Update pip
pip install --upgrade pip

# Install with all dependencies
pip install --no-cache-dir agentrouter

Platform-Specific Instructions

macOS

# Install Homebrew if needed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Python
brew install python@3.9

# Install AgentRouter
pip3 install agentrouter

Ubuntu/Debian

# Update package list
sudo apt update

# Install Python and pip
sudo apt install python3.9 python3-pip

# Install AgentRouter
pip3 install agentrouter

Windows

# Install Python from python.org
# Then in PowerShell:

# Upgrade pip
python -m pip install --upgrade pip

# Install AgentRouter
pip install agentrouter

Google Colab

# In a Colab cell
!pip install agentrouter

# Import and use
from agentrouter import ManagerAgent

Updating AgentRouter

Keep AgentRouter up to date:

# Update to latest version
pip install --upgrade agentrouter

# Update to specific version
pip install agentrouter==0.2.0

# Check current version
pip show agentrouter

Uninstalling

To remove AgentRouter:

# Uninstall package
pip uninstall agentrouter

# Remove all dependencies (careful!)
pip uninstall agentrouter -y