1. What LiteLLM Is
LiteLLM is an open-source LLM adapter: call 100+ APIs (OpenAI, Anthropic, Gemini, Bedrock, Azure, Ollama, vLLM, Qwen, and more) using the standard OpenAI format.
Two ways to use it:
- Python SDK — called directly from your code
- AI Gateway — a team-level proxy with authentication, billing, load balancing, and an admin console
It converges “a separate SDK, auth scheme, and request format for every model” into a single interface and a single config.
2. Why You Need It
| Problem | Without a gateway | With LiteLLM |
|---|---|---|
| SDK fragmentation | A separate client per provider | A unified OpenAI format |
| Key management | Keys scattered everywhere | Held centrally by the gateway; downstream uses Virtual Keys |
| Cost tracking | Bills are hard to attribute | Stats by key/team/user |
| Model switching | Changing provider means rewriting logic | Just change config.yaml |
| High availability | Single point of failure | fallback, load balancing, retries |
3. Core Use Cases
- Unified multi-model integration — one set of OpenAI-format code; just change the model name to switch between GPT, Claude, and Qwen
- Failover — when GPT-4 is rate-limited or down, switch automatically to Claude, then to a local Llama
- Load balancing — round-robin across multiple keys or endpoints to break through TPM/RPM limits
- Enterprise AI gateway — unified keys, budget quotas, log auditing
- Cost monitoring — a built-in price table, with support for pushing to Prometheus and Langfuse
- Local/cloud switching — Ollama in development, GPT-4 in production, with no code changes
| |
When you are building an AI product and need multi-model access or team-wide key management, LiteLLM is basically the standard; if you only reach for a single model occasionally, you may not need it.
4. Two Modes of Use
4.1 Python SDK
Suited to scripts and calls embedded inside a service. The model name format is provider/model, and the SDK handles the format conversion.
| |
4.2 AI Gateway
Suited to team sharing and multi-application access. Clients just point base_url at the gateway:
| |
Client → LiteLLM Gateway (:4000) → 100+ Providers
Auth / Routing / Guardrails / Billing
| Scenario | Recommended |
|---|---|
| Personal scripts, embedded in a single service | Python SDK |
| Team sharing, Virtual Keys, budget auditing | AI Gateway |
5. Core Capabilities
- Unified endpoints:
/v1/chat/completions,/v1/embeddings, image/speech/batch inference, and more - Virtual Key: managed by a Master Key; a Virtual Key binds a budget, rate limit, and model allowlist
- Routing and fallback: multiple deployments map to the same
model_name; when the primary provider fails, switch automatically - Guardrails: PII detection, third-party guardrail services, custom hooks
- Observability: Langfuse, OpenTelemetry, Prometheus; the Admin UI is at
http://localhost:4000/ui - MCP: Agents call gateway-managed tools and models through MCP
6. Quick Start
6.1 Install and Start
| |
6.2 Multi-model config.yaml
| |
| |
6.3 Docker
| |
In production, mount config.yaml and use PostgreSQL to persist Virtual Keys and spend logs.
7. Configuration Highlights
7.1 Secret References
| |
AWS Secrets Manager, Azure Key Vault, and others are also supported.
7.2 Creating a Virtual Key
| |
8. LiteLLM vs. New API
LiteLLM and New API (a fork of One API) are both popular LLM relay tools, but they target different audiences: LiteLLM is aimed at developers, New API at administrators/relay providers.
| Dimension | LiteLLM | New API |
|---|---|---|
| Form | Python library + Proxy | Go service + Web UI |
| Focus | fallback, load balancing, LangChain integration, fine-grained budgets | user system, redemption codes, channel management, multiplier billing |
| Configuration | YAML / environment variables | Web UI operations |
| Models | major international models updated quickly | domestic models adapted well |
| Python SDK | Yes | No |
| Guardrails / MCP | Yes | Usually no |
Choose LiteLLM: writing AI applications, needing high-availability fallback, integrating with Prometheus/Langfuse, local/cloud switching.
Choose New API: key distribution and relaying, team quota management, not wanting to write YAML, mainly domestic models.
9. Common CLI Commands
| |
10. Summary
LiteLLM unifies 100+ LLMs behind an OpenAI-compatible interface and offers two modes — SDK and AI Gateway — covering key management, cost tracking, load balancing, fallback, and enterprise governance. Compared with New API, it is better suited to developers who need logic control; New API is better suited to resource distribution.
The Python gateway runs at roughly 8ms P95 under 1k RPS, and since 2026 a Rust rewrite has been underway to further reduce latency.
