LiteLLM Cheatsheet
LiteLLM is a lightweight LLM API proxy providing a unified OpenAI-compatible interface for 100+ models. Features cost tracking, rate limiting, model fallback, and load balancing — the standard solution for managing multi-model API calls.
Quick Start
``bash
# Install
pip install litellm
# Start proxy for a single model litellm --model gpt-4o --port 4000
# Test with curl curl -s http://localhost:4000/v1/chat/completions \ -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
# List available models
curl -s http://localhost:4000/v1/models | jq .
`
Single Model Mode
Quickest way: litellm --model . Supports all OpenAI-compatible models plus Claude, Gemini, Llama, Mistral, and 100+ others through provider-specific configuration.
Multi-Model Config
For production, use a YAML config file defining multiple models with different providers, rate limits, and cost settings. Each model appears as a separate entry in the /v1/models endpoint.
Cost Management
--max-budget` sets a hard monthly cap. LiteLLM logs every request's model, tokens, and cost. The config file supports per-user and per-key spending limits for multi-tenant setups.
Startup & Modes(2)
| Command | Level | ||
|---|---|---|---|
litellm --helpShow LiteLLM help | Basic | litellm --help | |
pip install litellmInstall LiteLLM | Basic | pip install litellm |
ai-server(10)
| Command | Level | ||
|---|---|---|---|
litellm --modelSpecify model and start proxy (core usage) | Basic | litellm --model gpt-4o --port 4000 | |
litellm --model --portSpecify proxy port | Basic | litellm --model claude-3-opus --port 4000 | |
litellm --configStart proxy with config file | Intermediate | litellm --config ./litellm_config.yaml --port 4000 | |
litellm --drop-paramsDrop sensitive params from requests | Intermediate | litellm --model gpt-4o --drop-params api_key | |
litellm --max-budgetSet monthly cost limit | Intermediate | litellm --model gpt-4o --max-budget 50.0 | |
curl localhost:4000/v1/chat/completionsSend OpenAI-compatible request through proxy | Intermediate | curl -s http://localhost:4000/v1/chat/completions -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
| |
curl localhost:4000/v1/modelsList available models through proxy | Basic | curl -s http://localhost:4000/v1/models | jq . | |
curl localhost:4000/healthCheck proxy health | Basic | curl -s http://localhost:4000/health | |
litellm --num_requestsSet max concurrent requests | Intermediate | litellm --model gpt-4o --num_requests 10 | |
litellm --request_timeoutSet request timeout (seconds) | Intermediate | litellm --model gpt-4o --request_timeout 600 |