Inference serving

Open sourceMITUpdated July 2026

LiteLLM Model Gateway, Router, and Multi-Provider SDK

LiteLLM is an open-source Python SDK and proxy server that normalizes access to more than 100 model providers, translating requests and responses into familiar API formats while adding routing, fallbacks, usage tracking, virtual keys, budgets, logging, and policy hooks.

Intermediate · Python SDK for direct use, or LiteLLM Proxy as a self-hosted OpenAI-compatible gateway service

Editorial review

Reviewed byOpenSourcesAI EditorialLast updatedJuly 2026SourcesLiteLLM GitHub, LiteLLM official documentation, LiteLLM GitHub repository, LiteLLM repository license

Tool categories, pricing, source status, deployment options, and product claims can change quickly. Verify the official source before production or commercial use.

OpenSourcesAI verdict

LiteLLM is one of the most useful infrastructure tools for teams that have outgrown direct provider calls. The Python SDK can reduce application-level provider coupling; the Proxy Server can become a central AI gateway for authentication, routing, spend visibility, and policy. Those are two different adoption decisions. The gateway is powerful precisely because it sits on every model request, which also makes it a critical security, privacy, availability, and cost-control dependency.

Best for

Developers and platform teams that use multiple model providers, need OpenAI-compatible access to heterogeneous endpoints, want centralized virtual keys and budgets, or require routing, fallbacks, cost tracking, observability, and per-project controls without building a gateway from scratch.

Why use it

Use LiteLLM when provider-specific SDKs, credentials, error types, model names, and billing surfaces are spreading through the application. The SDK can provide one Python interface inside a service. The Proxy Server can move provider credentials and routing policy behind a shared endpoint so applications receive scoped virtual keys instead of direct access to every upstream account. This can speed provider evaluation and migration, but it does not make different models behaviorally interchangeable.

The SDK and Proxy Server are different products

The LiteLLM Python SDK is linked directly into an application. It translates provider-specific calls and can add routing, fallbacks, cost calculation, and observability inside that process. It is appropriate when one codebase owns the model integration and does not need a separate shared service.

The LiteLLM Proxy Server is a network gateway. Applications call the proxy, the proxy authenticates the caller, resolves a model route, selects an upstream deployment, attaches provider credentials, and records usage. This centralizes policy and secrets but adds a service that must be deployed, secured, scaled, monitored, and backed up.

Moving from the SDK to the proxy changes the architecture, latency path, blast radius, and ownership model. A team should not describe the proxy as merely “the SDK in Docker.”

Model aliases, routing, retries, and fallbacks

A proxy model name can represent one or more upstream deployments. The router can distribute traffic, apply retry rules, cool down unhealthy deployments, and fall back when a provider fails or a request exceeds a context window. This can improve resilience and make provider migration less invasive.

Fallbacks must preserve application intent. Two models with similar context windows may differ in tool calling, JSON behavior, safety policy, latency, price, language support, or output quality. An automatic fallback that returns a syntactically valid response can still violate product expectations.

Define fallback groups by tested capability rather than provider category alone. Log the selected deployment, reason for fallback, latency, cost, and output-quality signals so degraded behavior is visible instead of silently normalized.

Virtual keys, teams, projects, budgets, and limits

The proxy can issue virtual keys rather than exposing upstream provider credentials. Keys can be associated with users, teams, projects, models, budgets, rate limits, and other controls depending on deployment and edition. This is one of LiteLLM’s strongest platform features because applications can be revoked or constrained without rotating every upstream account.

Budgets and rate limits are operational controls, not perfect financial guarantees. Provider reporting delays, retries, streaming, cached responses, model-price changes, and incorrect cost metadata can affect accounting. Teams should reconcile LiteLLM records with provider invoices and alerts.

The proxy master key and administrative endpoints have broad power. They should never be embedded in user applications or supplied to a general chat interface. Use scoped virtual keys and separate administrative access paths.

Logging, observability, privacy, and guardrails

LiteLLM can emit callbacks and traces to observability systems, record spend and latency, and integrate with logging, evaluation, or guardrail providers. This visibility is valuable, but prompts, responses, tool arguments, document excerpts, and user identifiers can become duplicated across several downstream systems.

Decide which fields are logged, redacted, retained, and exported before production traffic begins. An observability integration should not receive sensitive content by default merely because it is convenient to enable.

Guardrails can block or transform requests and responses, but they are not a substitute for application authorization, provider-side policy, secure tool execution, or human review. Some advanced guardrail and administrative features may require commercial licensing; verify the exact feature and edition rather than assuming every documented control is included in the open-source core.

Gateway availability and failure design

A central gateway can reduce provider outages through routing, but it can also become the single point through which every request fails. Production deployments need health checks, multiple proxy instances, a reliable database where required, shared configuration, external load balancing, secret availability, and version-compatible migrations.

Retries can amplify load and cost during an incident. Set bounded retry budgets, timeouts, circuit-breaker or cooldown behavior, and idempotency expectations. Streaming requests, batch jobs, images, and tool-calling workflows may need different policies.

Test provider outages, invalid credentials, rate limits, malformed responses, database unavailability, cache failures, and partial gateway rollout. A successful normal request does not prove the routing layer fails safely.

Provider abstraction has limits

LiteLLM normalizes transport and common response shapes; it cannot make providers identical. Model identifiers, context limits, token counting, tool schemas, reasoning controls, safety behavior, multimodal formats, batch semantics, and error details still vary.

Applications should define a capability contract for each logical route and test every deployment behind it. Provider-specific parameters can be useful, but excessive use recreates the coupling that the gateway was meant to reduce.

The strongest design is usually a small set of stable internal model routes—such as fast-chat, reasoning, embedding, or vision—backed by tested providers, rather than exposing the entire upstream catalog directly to every application.

How LiteLLM compares with alternatives

Direct provider SDKs are simpler when an application uses one provider and does not need shared policy. OpenRouter and managed gateways reduce self-hosting work but move routing and data handling to another vendor. Cloud-native gateways may fit organizations already standardized on one hyperscaler.

vLLM, SGLang, Ollama, and llama.cpp run models; LiteLLM routes to model providers and inference servers. Open WebUI is a user workspace. A common stack places Open WebUI or an application in front of LiteLLM, with LiteLLM routing to vLLM, cloud APIs, or other backends.

Key features

  • Python SDK that translates calls across 100+ providers into consistent request, response, streaming, and exception patterns.
  • Proxy Server / AI Gateway with centralized authentication, authorization hooks, virtual keys, teams, users, projects, budgets, rate limits, and spend tracking.
  • Router support for load balancing, retries, cooldowns, deployment health, provider fallbacks, context-window fallbacks, and policy-based model selection.
  • Support for chat, Responses, embeddings, images, audio, batches, reranking, and additional endpoints depending on provider capability.
  • Observability callbacks and integrations for logging, cost, latency, errors, traces, caching, and evaluation systems.
  • Guardrail, caching, secret-management, database-backed, administrative, and enterprise features—with availability and licensing varying by configuration and edition.

Common AI use cases

  • Replace several provider-specific Python clients with one application interface.
  • Expose cloud and self-hosted models through one OpenAI-compatible gateway endpoint.
  • Issue scoped virtual keys to applications, teams, users, or environments.
  • Route traffic across multiple deployments and fall back during provider errors or rate limits.
  • Track model spend, latency, tokens, errors, and provider usage by project.
  • Apply shared logging, caching, guardrail, and policy hooks to model traffic.
  • Migrate a logical model route between providers without changing every client.

Business use cases

  • Create an internal AI gateway for several product and engineering teams.
  • Centralize provider credentials and revoke application access independently.
  • Set project budgets and rate limits across multiple upstream vendors.
  • Compare model providers through standardized routes and observability.
  • Provide one governed endpoint for internal assistants, agents, and customer-facing products.

How AI builders can use it

  • Start with the Python SDK when one service needs provider normalization and shared infrastructure is not yet justified.
  • Define a small internal model-route taxonomy and the capabilities each route promises.
  • Deploy the proxy on a private network with a master key, scoped virtual keys, secrets management, and minimal logging.
  • Add one primary and one tested fallback deployment, then simulate rate limits and outages.
  • Reconcile spend records with provider invoices and set alerts before enabling broad access.
  • Scale the gateway with a production database, multiple instances, health checks, and rollback-tested upgrades when it becomes shared infrastructure.

Who should use it

  • Applications that use or evaluate several model providers.
  • Platform teams centralizing AI credentials, policy, budgets, and routing.
  • Organizations that need scoped keys rather than distributing provider secrets.
  • Teams combining self-hosted inference servers with commercial APIs.
  • Developers willing to test capability differences behind normalized interfaces.

Who should not use it

  • Small applications committed to one provider with no gateway requirements.
  • Teams unwilling to operate a security- and availability-critical network service.
  • Projects expecting provider abstraction to guarantee identical model behavior.
  • Organizations that have not defined prompt, response, and logging data policies.
  • Deployments assuming every documented administrative feature is included under the same open-source license.

Evaluation checklist

  • Does the project need the Python SDK, the Proxy Server, or both?
  • Which logical model routes and capability guarantees will clients use?
  • Which providers, regions, and self-hosted endpoints are approved?
  • How will virtual keys, teams, projects, budgets, and rate limits be structured?
  • Which retries and fallbacks are safe for each request type?
  • What prompt, response, tool, and user data may be logged or exported?
  • Which features are open-source core versus commercial or enterprise?
  • How will the proxy, database, cache, secrets, and load balancer remain available?
  • How will provider invoices be reconciled with gateway spend records?

Security and admin notes

  • Protect the proxy master key and administrative endpoints; applications should receive scoped virtual keys only.
  • Store provider credentials in a secret manager or protected environment, not in client-visible configuration.
  • Restrict network access, require TLS, rate-limit callers, and validate request sizes and allowed models.
  • Redact or disable sensitive prompt and response logging before enabling observability callbacks.
  • Review third-party callbacks, guardrails, caches, and logging destinations as data processors.
  • Pin LiteLLM and database versions, test migrations, and keep a rollback path for gateway upgrades.
  • Audit fallback routes so traffic does not cross an unapproved provider, region, or retention policy during incidents.

Pricing notes

LiteLLM’s core repository is primarily MIT-licensed outside separately licensed enterprise directories, while commercial features, support, and enterprise components have separate terms. Operating cost includes proxy infrastructure, database and cache services, observability, engineering, and upstream model usage. Verify current licensing and feature packaging before standardizing on administrative or enterprise controls.

Tradeoffs

LiteLLM can simplify provider access and centralize governance, but it adds another critical hop and does not erase model differences. Misconfigured retries can increase cost, logging can widen data exposure, virtual-key administration can become complex, and the proxy can become a shared outage domain. It is most valuable when the organization has enough providers, applications, or policy requirements to justify a gateway.

Recommended workflow

  • Choose SDK or proxy based on ownership and sharing requirements.
  • Define stable internal routes and test provider capabilities behind each route.
  • Launch privately with one primary provider, scoped keys, minimal logs, and bounded retries.
  • Add a tested fallback and simulate provider, credential, rate-limit, and database failures.
  • Reconcile cost reporting and verify budgets and limits with controlled traffic.
  • Add redundancy, monitoring, backup, and rollback before the gateway becomes a shared production dependency.

Pros

  • Broad provider coverage through consistent SDK and proxy interfaces.
  • Useful routing, retries, fallbacks, load balancing, and spend tracking.
  • Virtual keys and project controls reduce direct provider-secret distribution.
  • Fits both cloud providers and self-hosted OpenAI-compatible servers.
  • Large integration ecosystem for observability, caching, and guardrails.

Cons

  • Central proxy becomes a security- and availability-critical dependency.
  • Provider normalization cannot guarantee behavioral equivalence.
  • Production database, scaling, and migrations add operational complexity.
  • Retries and fallbacks can hide degradation or increase spend.
  • Feature licensing varies between open-source core and commercial components.

Alternatives

  • Direct provider SDKs may be better for a small single-provider application.
  • OpenRouter may be better when a managed multi-provider routing service is preferred.
  • Cloud-native AI gateways may be better for organizations standardized on one hyperscaler.
  • Portkey or similar managed gateways may be better when hosted governance and observability are preferred.
  • A custom gateway may be better when policy and protocol requirements are highly specialized.

FAQ

Is LiteLLM an inference server?

No. LiteLLM is an SDK and gateway that calls model providers or inference servers. Backends such as vLLM, Ollama, cloud APIs, or other compatible services perform the actual inference.

What is the difference between the LiteLLM SDK and Proxy?

The SDK runs inside a Python application. The Proxy Server is a central network service that can issue virtual keys, route requests, track spend, and apply shared controls across many applications.

Can LiteLLM make all providers interchangeable?

It normalizes common API shapes and errors, but model behavior, tools, context, safety, latency, pricing, and provider-specific features still differ. Each logical route needs capability tests.

Does LiteLLM support self-hosted models?

Yes. It can route to many self-hosted or OpenAI-compatible endpoints in addition to commercial providers, making it useful as a common gateway across mixed infrastructure.

Is every LiteLLM feature MIT-licensed?

The core outside separately licensed enterprise directories is available under MIT terms, while enterprise components and services have separate licensing. Verify the exact feature and current repository license before adoption.

Official verification sources

Direct official links used to verify pricing, features, security claims, and product packaging.

CategoryInference servingLicenseMITDeploymentPython SDK for direct use, or LiteLLM Proxy as a self-hosted OpenAI-compatible gateway serviceModeSelf-hosted proxy or cloud
LiteLLM GitHub

OpenSourcesAI ecosystem connections

Use these next-step links to move from this profile into related tools, comparisons, guides, stacks, and curated shortlists.