What LiteLLM Does
- Single OpenAI-compatible endpoint for 100+ providers
- Route requests between providers based on model name
- Track costs per model, per team, per API key
- Set spending limits and rate limits
- Fall back to backup providers if primary fails
- Load balance across multiple deployments
What You Need
- A VPS with at least 2 GB RAM
- Docker installed
- API keys for whichever providers you want to use
Step 1: Create the Configuration File
mkdir ~/litellm && cd ~/litellm
nano config.yamlmodel_list:
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
- model_name: claude-sonnet
litellm_params:
model: anthropic/claude-sonnet-4-6
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: local-llama
litellm_params:
model: ollama/llama3.1:8b
api_base: http://host.docker.internal:11434
general_settings:
master_key: your-master-key-hereStep 2: Deploy with Docker
nano docker-compose.ymlversion: '3.8'
services:
litellm:
image: ghcr.io/berriai/litellm:main-latest
restart: always
ports:
- "4000:4000"
volumes:
- ./config.yaml:/app/config.yaml
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY}
command: --config /app/config.yaml --port 4000
extra_hosts:
- "host.docker.internal:host-gateway"Create a .env file:
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
LITELLM_MASTER_KEY=your-master-key-heredocker compose up -dStep 3: Test the Endpoint
curl http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-master-key-here" \
-d '{
"model": "local-llama",
"messages": [{"role": "user", "content": "Hello"}]
}'Switch models by changing the model name — same endpoint, same format.
Step 4: Expose with Nginx and HTTPS
apt install -y nginx certbot python3-certbot-nginx
nano /etc/nginx/sites-available/litellmserver {
server_name llm.yourdomain.com;
location / {
proxy_pass http://localhost:4000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}ln -s /etc/nginx/sites-available/litellm /etc/nginx/sites-enabled/
certbot --nginx -d llm.yourdomain.com
nginx -t && systemctl reload nginxThe Cost Tracking Dashboard
LiteLLM ships with a built-in dashboard at /ui. Log in with your master key to see spend per model, per virtual key, and per team. Set budget limits to prevent runaway costs.
What it costs
LiteLLM is a lightweight proxy, so it barely uses resources itself; the heavy lifting stays with whichever provider you route to. The Micro plan (1 vCPU, 1 GB) runs it fine as a single gateway for your team. NoctHost bills hourly from a prepaid balance you top up with crypto, with no card and no KYC.