Installation¶
Complete installation guide for SaaS LiteLLM, covering local development setup and all configuration options.
System Requirements¶
Required Software¶
- Python 3.9+ - Programming language runtime
- Docker - Container platform for PostgreSQL and Redis
- Docker Compose - Multi-container orchestration
- Git - Version control (for cloning the repository)
- uv - Fast Python package installer (installed during setup)
Recommended¶
- PostgreSQL client (psql) - For database inspection
- Redis client (redis-cli) - For cache inspection
Hardware¶
- RAM: 4GB minimum, 8GB recommended
- Storage: 2GB free space
- CPU: 2+ cores recommended
Installation Methods¶
Choose the installation method that best fits your needs:
Full development setup with all services running locally via Docker.
Best for: - Development and testing - Learning the platform - Contributing to the project
Run everything in Docker containers.
Best for: - Production deployments - Isolated environments - CI/CD pipelines
Deploy to Railway cloud platform.
Best for: - Production hosting - Quick deployments - Managed infrastructure
Local Development Setup¶
Step 1: Clone or Access Repository¶
If you have access to the repository:
Step 2: Install Python Dependencies¶
Install uv package manager and project dependencies:
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Reload shell to get uv in PATH
source ~/.bashrc # or ~/.zshrc
# Run setup script (creates venv and installs dependencies)
./scripts/setup_local.sh
This script will: - Create a Python virtual environment in .venv/ - Install all required dependencies - Set up the project for development
Manual installation (alternative):
# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
source .venv/bin/activate
# Install dependencies
pip install -e .
Step 3: Start Docker Services¶
Start PostgreSQL and Redis containers:
This will: - Pull PostgreSQL 15 and Redis 7 images - Create and start containers - Initialize PostgreSQL with the correct database
Verify Docker services:
Expected output:
Step 4: Configure Environment Variables¶
Copy the local environment template:
Edit .env and add your API keys:
# Required: OpenAI API key
OPENAI_API_KEY=sk-your-actual-openai-key-here
# Optional: Other providers
ANTHROPIC_API_KEY=sk-ant-your-key-here
GOOGLE_API_KEY=your-google-key-here
Environment file locations: - .env - Your actual environment (not in git) - .env.local - Template for local development - .env.example - Template for Railway deployment
Step 5: Run Database Migrations¶
Create the job tracking tables:
Expected output:
✅ Migration completed: 001_create_job_tracking_tables.sql
✅ Migration completed: 002_add_teams_table.sql
✅ Migration completed: 003_add_organizations.sql
...
🎉 All migrations completed successfully!
Manual migration (alternative):
for file in scripts/migrations/*.sql; do
docker exec -i litellm-postgres sh -c \
'PGPASSWORD=litellm_password psql -U litellm_user -d litellm' < "$file"
echo "✅ Migration completed: $(basename $file)"
done
Step 6: Start the Services¶
You'll need two terminal windows.
Terminal 1: LiteLLM Backend
Wait for:
Terminal 2: SaaS API
Wait for:
Step 7: Verify Installation¶
Check that all services are running:
# Check LiteLLM backend
curl http://localhost:8002/health
# Check SaaS API
curl http://localhost:8003/health
# Check PostgreSQL
docker exec litellm-postgres pg_isready -U litellm_user
# Check Redis
docker exec litellm-redis redis-cli ping
All should return successful responses.
Database Setup¶
PostgreSQL Configuration¶
The Docker setup creates a PostgreSQL database with these settings:
| Setting | Value |
|---|---|
| Host | localhost |
| Port | 5432 |
| Database | litellm |
| User | litellm_user |
| Password | litellm_password |
Connecting to PostgreSQL¶
# Using Docker exec
docker exec -it litellm-postgres psql -U litellm_user -d litellm
# Using local psql client
PGPASSWORD=litellm_password psql -h localhost -U litellm_user -d litellm
Useful psql commands:
\dt -- List all tables
\d table_name -- Describe a table
\l -- List databases
\du -- List users
\q -- Quit
Database Tables¶
After migrations, you'll have these tables:
Your SaaS Tables: - jobs - Job tracking - llm_calls - Individual LLM call records - job_cost_summaries - Aggregated costs - organizations - Organization management - teams - Team management - model_access_groups - Model access control - model_aliases - Model configuration - credit_transactions - Credit history
LiteLLM Tables (auto-created): - LiteLLM_VerificationToken - API keys - LiteLLM_UserTable - Users - LiteLLM_TeamTable - Teams - LiteLLM_SpendLogs - Usage tracking
Inspecting Data¶
# View recent jobs
docker exec -it litellm-postgres psql -U litellm_user -d litellm \
-c "SELECT job_id, team_id, status, created_at FROM jobs ORDER BY created_at DESC LIMIT 5;"
# View teams
docker exec -it litellm-postgres psql -U litellm_user -d litellm \
-c "SELECT team_id, organization_id, credits_allocated, credits_remaining FROM teams;"
Redis Setup¶
Redis Configuration¶
| Setting | Value |
|---|---|
| Host | localhost |
| Port | 6380 (non-standard to avoid conflicts) |
| Password | None |
Connecting to Redis¶
# Using Docker exec
docker exec -it litellm-redis redis-cli
# Using local redis-cli
redis-cli -p 6380
Useful Redis commands:
PING -- Test connection
KEYS * -- List all keys (dev only!)
GET key_name -- Get a value
FLUSHALL -- Clear all data (use with caution!)
INFO -- Server information
QUIT -- Exit
Port Configuration¶
Default ports for local development:
| Service | Port | URL |
|---|---|---|
| SaaS API | 8003 | http://localhost:8003 |
| SaaS API Docs | 8003 | http://localhost:8003/docs |
| LiteLLM Proxy | 8002 | http://localhost:8002 |
| LiteLLM Admin UI | 8002 | http://localhost:8002/ui |
| PostgreSQL | 5432 | localhost:5432 |
| Redis | 6380 | localhost:6380 |
| Admin Dashboard | 3002 | http://localhost:3002 |
Why non-standard ports?
We use ports 8002/8003 locally to avoid conflicts with other services. In production (Railway), standard port 8000 is used.
Optional: Admin Dashboard¶
If you want to use the Next.js admin dashboard:
Access at: http://localhost:3002
Troubleshooting¶
"uv: command not found"¶
Install uv manually:
"Port already in use"¶
Find and kill the process:
"Docker daemon not running"¶
Start Docker Desktop or the Docker daemon:
"PostgreSQL connection refused"¶
Check PostgreSQL is running:
docker compose ps postgres
docker compose logs postgres
# Restart if needed
docker compose restart postgres
"Module not found" errors¶
Reinstall dependencies:
"Migration already exists"¶
Migrations are idempotent. If you need to reset:
# Remove all data
docker compose down -v
# Start fresh
docker compose up -d postgres redis
sleep 10
./scripts/run_migrations.sh
Common Operations¶
Restart Everything¶
# Stop Docker services
docker compose down
# Start Docker services
docker compose up -d
# Restart Python services (Ctrl+C in each terminal, then restart)
View Logs¶
# PostgreSQL logs
docker compose logs -f postgres
# Redis logs
docker compose logs -f redis
# SaaS API logs (if redirected to file)
tail -f logs/saas_api.log
Reset Database¶
Update Dependencies¶
Development Tools¶
pgAdmin (Optional)¶
Web-based PostgreSQL management:
Access at: http://localhost:5050 - Email: admin@litellm.local - Password: admin
Redis Commander (Optional)¶
Add to docker-compose.yml if needed for Redis visualization.
Next Steps¶
Now that installation is complete:
- Follow the Quickstart - Test your installation
- Learn the Architecture - Understand the system
- Integration Guide - Start building
- Set up Admin Dashboard - Manage teams
Additional Resources¶
- Troubleshooting Guide - Common issues
- Environment Variables - Configuration reference
- Docker Guide - Docker deployment details