litellm
by BerriAI
AI gateway and Python SDK for calling over 100 language model APIs in one format with cost tracking.
- Stars
- 63,855 stars
- Forks
- 14k forks
- Last push
- today
- Activity
- Active
# Install the AI gateway$ uv tool install 'litellm[proxy]'# Start it for a model$ litellm --model gpt-6.1-solCommands from the project's README. Run them after installing (see below).
Overview
Understand litellm in 60 seconds
- What it does
- LiteLLM is an open-source AI gateway and Python SDK that lets you call 100+ LLM providers, including OpenAI, Anthropic, Gemini, Bedrock and Azure, using the OpenAI request format. Use it as a library in your code or run it as a central proxy for your team.
- The problem it solves
- Every LLM provider has its own SDK, auth, request format and errors. LiteLLM gives you one interface, so you can switch providers without rewriting code, and its gateway adds virtual keys, spend tracking, guardrails and load balancing.
- Why choose it
- Choose it for a widely used, self-hosted way to standardise and govern LLM access. Some enterprise features are under a separate commercial license.
- Who should use it
- Developers calling several LLM providers
- ML platform teams giving staff one LLM endpoint
- Companies tracking LLM spend per team or user
- Apps that need fallbacks between providers
- Setup difficulty
You'll need:
- Python with uv or pip
- API keys for the providers you use
- Docker for production deployments (stable images use the -stable tag)
How litellm works
The Python SDK exposes completion() and other functions that accept any supported model name, such as openai/... or anthropic/..., with the same OpenAI-style messages. A Router adds retries, fallbacks and load balancing across deployments, and auto routing can choose a model per prompt.
The AI Gateway (proxy server) is a central service your apps call with the regular OpenAI SDK pointed at it. It provides authentication, virtual keys, per-project and per-user spend tracking, guardrails, caching, logging and an admin dashboard. The README reports 8 ms P95 latency at 1,000 requests per second in its benchmarks.
Supported endpoints include chat completions, responses, embeddings, images, audio, batches, rerank, the A2A agent protocol and Anthropic-style messages. It can also act as an MCP gateway. Terraform modules deploy it on AWS or GCP. Code under litellm/enterprise has its own license; the rest is MIT.
Features
Key features
100+ providers
OpenAI, Anthropic, Gemini, Bedrock, Azure and more.
OpenAI format everywhere
Swap providers without rewriting code.
AI gateway
Virtual keys, spend tracking, guardrails and dashboard.
Router
Retries, fallbacks and load balancing.
MCP and A2A
Gateway support for agent protocols.
Production deploys
Docker images and Terraform for AWS and GCP.
Strengths
- De facto standard for multi-provider LLM access
- Self-hosted
- Strong cost and access controls
- MIT licensed core
Limitations
- Some features require the commercial enterprise license
- The production Terraform stacks in the README run alongside managed Postgres and Redis
- Another service in the request path
Practical use cases
One endpoint for a company
Give every team an OpenAI-compatible URL with their own keys.
Provider fallback
Fall back from one provider to another automatically.
Cost tracking
See LLM spend per project and user.
Installation
Install litellm
Commands come from LiteLLM's README. AIRepoHub hasn't run them yet. View source
Prerequisites
- Python
- Provider API keys
Supported systems
- Windows
- macOS
- Linux
- 1
Add to your project
Shelluv add litellm - 2
Call any provider
Textfrom litellm import completionimport osos.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"response = completion(model="anthropic/claude-sonnet-4-20250514", messages=[{"role": "user", "content": "Hello!"}])
- 1
Install the gateway
Shelluv tool install 'litellm[proxy]' - 2
Start it
It serves an OpenAI-compatible API on port 4000.
Shelllitellm --model gpt-6.1-sol
Configuration and API keys
| Setting | What it's for |
|---|---|
OPENAI_API_KEYOptional | Key for OpenAI models. |
ANTHROPIC_API_KEYOptional | Key for Anthropic models. |
First run
- 1
Call the gateway with the OpenAI SDK
Textimport openaiclient = openai.OpenAI(api_key="anything", base_url="http://0.0.0.0:4000")response = client.chat.completions.create( model="gpt-6.1-sol", messages=[{"role": "user", "content": "Hello!"}])
litellm's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.
Your first project
Put an AI gateway in front of your models
Run LiteLLM locally and call it with the OpenAI SDK.
Before you start
- uv
- An OpenAI API key in OPENAI_API_KEY
- 1
Install
Shelluv tool install 'litellm[proxy]' - 2
Start the gateway
Shelllitellm --model gpt-6.1-sol - 3
Send a request through it
Use the Python snippet from First run, pointed at http://0.0.0.0:4000.
What to expect
Your request goes through LiteLLM to the provider and returns an OpenAI-format response.
Next steps
- Follow the E2E tutorial to set up virtual keys
- Add more providers in a config file
- Deploy with Docker using a -stable image
Costs and requirements
What it costs to run
- License
- MIT, except code under litellm/enterprise, which has its own license.Depends
- Open source gateway and SDK
- Free to self-host.Free
- Enterprise
- Paid license for SSO, support and enterprise features.Paid
- LLM usage
- Billed by each provider.Paid
Troubleshooting
Common setup issues
Unsure which Docker image to run in production
Use images with the -stable tag, which go through 12-hour load tests.
litellm and litellm-core conflict
Install only one SDK distribution per environment; use litellm for the proxy and CLI.
Provider not supported
Check the supported providers list or raise a feature request.
Alternatives
Similar AI repositories
markitdown
microsoft
Python tool from Microsoft that converts PDFs, Word, Excel, PowerPoint and other files into Markdown for use with AI.
transformers
huggingface
Hugging Face library for defining, running and training machine learning models for text, vision and audio.
langchain
langchain-ai
Framework for building LLM-powered applications and agents.
pytorch
pytorch
Python framework for building and training neural networks with tensors and GPU acceleration.