LiteLLM: One API in Front of Many Model Providers
LiteLLM is the gateway you put between your applications and whatever models they use, so the applications only ever learn one API.
One API, many backends
Nearly every model client speaks the OpenAI chat completions format. LiteLLM accepts that format and translates to Anthropic, Google, Bedrock, Azure, Mistral, and local runtimes including Ollama and vLLM.
The consequence is that switching models becomes configuration rather than code. An application written against the OpenAI SDK can be pointed at a local Llama without touching it.
model_list:
- model_name: fast
litellm_params:
model: ollama/llama3
api_base: http://ollama:11434
- model_name: smart
litellm_params:
model: anthropic/claude-sonnet-4
Your application asks for fast or smart. What that resolves to is yours to change.
Why self-hosters care
Local and remote behind one endpoint. Route cheap, high-volume calls to a local model on your own GPU, and hard ones to a hosted API, with no application awareness. Our running LLMs locally guide and ROCm and CUDA guide cover the local half.
Fallback. When a provider is down or rate-limits, requests move to the next model in the list.
Virtual keys with budgets. Issue per-application or per-user keys with spend limits and rate limits. On a shared instance that is the difference between knowing your costs and not.
One place to instrument. It emits to Langfuse among others, so observability is configured once rather than per application.
Proxy or library
It is both: a Python library for direct use, and a proxy server which is what makes it infrastructure. The proxy is the interesting mode for self-hosting.
litellm --config config.yaml --port 4000
curl http://localhost:4000/v1/models -H "Authorization: Bearer sk-..."
Postgres backs key and spend tracking, per our PostgreSQL guide.
Operational caution
It holds every provider API key you configure. That makes it a high-value target and means the config belongs in a secret store rather than a file beside the compose file, per our secrets management guide.
Never expose it without authentication. An open OpenAI-compatible endpoint with your keys behind it will be found and used, and you pay.
License
LiteLLM is released under the MIT License, with some enterprise features under a commercial licence.