LiteLLM

LiteLLM

BerriAI · Coding · Other

LiteLLM is an open-source AI gateway and Python library that calls 100+ LLMs through one OpenAI-format interface, adding routing, spend tracking and guardrails.

Interface preview of LiteLLM

About LiteLLM

What Is LiteLLM

LiteLLM is a tool from BerriAI that gives developers one interface for calling models from OpenAI, Anthropic, Gemini, Bedrock, Azure, Ollama and dozens of other providers. Instead of learning a different SDK, auth pattern and response shape for every vendor, you write one call and swap the model string when you want to change backends.

The problem it solves is vendor lock-in. Teams that build on a single provider often discover that switching models means rewriting request builders, error handling and streaming logic across an entire codebase. LiteLLM puts a translation layer underneath your code so the business logic stays the same while the underlying model changes in a config file.

Two ways to run it cover most needs. The Python SDK drops into an existing app as a package, while the gateway (proxy server) runs as a self-hosted service that centralizes virtual keys, budgets and logging for a whole team. The trade-off is that the gateway adds infrastructure to maintain, and the open-source version expects you to host and upgrade it yourself.

Getting Started

  1. Install the package with uv add litellm or pip install litellm, then set your provider API keys as environment variables.
  2. For the SDK path, import completion and call it with a model string such as openai/gpt-4o or anthropic/claude-sonnet-4, passing your messages list.
  3. For the gateway path, run litellm --model gpt-4o or deploy the Docker image, then point any OpenAI client at the local base URL.
  4. Add a Router config when you want retries and fallbacks across multiple deployments, and connect Postgres and Redis if you run more than one gateway instance.
  5. Track usage through the admin dashboard or a callback, and set budgets per key, user or team as traffic grows.

Product Information

A quick look at LiteLLM's pricing, supported platforms, and performance.

Free PlanYes
Paid Plans$0 - Custom (Enterprise)
PlatformWeb, self-hosted server, Python library, Docker, Kubernetes
DeveloperBerriAI
CategoryCoding · Other
Release DateJul 2023
Latest UpdatedOct 2025
Website Visits595.3K
Website Global Rank96.2K
API AvailabilityYes

Best for

The users, tasks, and scenarios where this tool fits best.

Users

  • Backend engineers
  • Platform and ML teams
  • Product managers running experiments

Tasks

  • Unified model access
  • Cost control
  • Failover and load balancing
  • Observability

Scenarios

  • A startup that started on one provider and wants to add cheaper models without touching business logic.
  • An enterprise running a self-hosted gateway so model traffic and keys stay inside its own infrastructure.
  • A prototyping session where a single script tests the same prompt against five different models.

Key features

Unified API Across 100+ Providers

One interface covers OpenAI, Anthropic, Gemini, Bedrock, Azure, Vertex AI, Ollama, vLLM and more. Every response comes back in the OpenAI chat completions shape, so code that reads choices[0].message.content keeps working after you switch providers.

Drop-In OpenAI Compatibility

Existing projects that use the OpenAI SDK can point their client at a LiteLLM gateway by changing the base URL and key. No request code changes, which makes it a low-risk way to introduce multi-model support into a running app.

LLM Proxy Server and Gateway

The self-hosted gateway acts as a central control point for a team. It manages virtual keys, tracks spend by key, user, team and organization, enforces RPM and TPM limits, and ships with an admin dashboard for day to day operations.

Router with Retries and Fallbacks

The Router module coordinates several deployments of the same model. It retries failed calls, falls back to a healthy deployment when a provider goes down, and balances load across backends so one slow endpoint does not stall the whole app.

Cost Tracking and Budgets

LiteLLM calculates the cost of each call and records it against the key or project that made it. Teams can set monthly budgets and rate limits, then review spend without hand-building their own metering.

Observability and Guardrails

A single callback line sends logs, token counts and traces to Langfuse, MLflow, Helicone and other tools. Guardrails let you filter or block unsafe input and output, and error mapping keeps provider-specific exceptions in familiar OpenAI types.

Pros and cons

Pros

  • One OpenAI-format interface removes the need to learn a separate SDK for every model provider.
  • Model changes happen in configuration, which cuts the risk of a provider switch breaking production code.
  • The open-source core is free under the MIT license and can run fully self-hosted.
  • Router retries and fallbacks improve uptime when a provider has an outage.
  • Cost tracking and budgets give teams visibility into spend that is often invisible otherwise.

Cons

  • The gateway is another service to deploy, monitor and upgrade, which adds operational work for small teams.
  • Running it across multiple instances requires Postgres and Redis, so a serious deployment carries real infrastructure needs.
  • Features like SSO, SCIM, audit logs and air-gapped deployment sit behind the paid Enterprise plan.
  • New provider quirks can lag behind official SDKs, so rarely used endpoints may need extra configuration.

Frequently asked questions

LiteLLM lets an application call many different LLM providers through one OpenAI-format interface. Developers use it to avoid rewriting code when they switch models and to centralize keys, budgets and logging behind a self-hosted gateway.