LiteLLM Explained: One API for a Hundred LLM Providers

LiteLLM gives you one OpenAI-format API for more than 100 LLM providers. Learn how the SDK and the proxy gateway work, and when to use each one.

By Galactic News Editorial · Published 2026-11-24T19:42:20+00:00 · Updated 2026-11-24T19:42:20+00:00

LiteLLM one API many LLM providers explained

LiteLLM Explained: One API for a Hundred LLM Providers

Every large language model provider ships its own SDK, with its own quirks. OpenAI, Anthropic, Google Vertex AI, AWS Bedrock and Azure all speak a different dialect. LiteLLM is the layer that fixes this. It is an open-source library that gives you a single, unified interface to call more than 100 language models using the OpenAI format. One function, one response shape, and the freedom to switch providers without rewriting your code.

LiteLLM One API Many LLM Providers: How It Works

LiteLLM translates between the OpenAI API format and each provider's native format. You write code against one schema. LiteLLM handles the protocol differences in the background. The project has two modes. The Python SDK is a library you import into your application. The proxy server is a self-hosted gateway that any OpenAI-compatible client can point at. Both modes return responses in the OpenAI chat completions shape, whatever provider sits behind them.

The Python SDK: One Function for Every Provider

The SDK centres on one function: completion(). You pass a model name in the form provider/model and a list of messages. The same call works for OpenAI, Anthropic, Vertex AI, Bedrock, Ollama and Azure OpenAI. Every response follows the OpenAI format, so your parsing code never changes when you switch models. Streaming works by adding stream=True, which yields response chunks as they arrive.

Installation is one command with uv or pip. For applications that use the SDK directly, a leaner distribution called litellm-core provides the shared SDK with fewer mandatory dependencies and no bundled dashboard or gateway entry points. Python imports stay the same either way. Authentication follows each provider's own convention: LiteLLM reads the same environment variables the native SDKs read, such as OPENAI_API_KEY and ANTHROPIC_API_KEY. Errors are mapped to OpenAI exception types, so existing error handling keeps working. Logging integrations cover Langfuse, MLflow and Helicone with a single callback line, and a cost callback can capture the price of each response.

The Proxy Gateway: One Endpoint for a Whole Team

The proxy is a self-hosted OpenAI-compatible gateway. Any client that works with OpenAI works with the proxy, with no code changes. Start it with a model wired up, and it listens on port 4000. Point an OpenAI client at that address, and requests route to the configured backend. A single config.yaml file controls the model list, routing rules, fallback chain and spend limits.

The proxy is the right choice when a team shares LLM access. It issues virtual keys per team or user, with per-key budgets and automatic spend tracking. An admin UI shows usage and costs. For production use with virtual keys and spend tracking, the recommended setup is Docker Compose with PostgreSQL. A quick local test needs only pip and one command.

Routing, Fallbacks and Cost Tracking

Switching providers is only half the value. The other half is resilience. LiteLLM's Router adds built-in retry and fallback logic across multiple deployments. If one provider fails or slows down, the request can fall back to another. Load balancing supports round-robin, least-busy, usage-based and latency-based routing across several API keys or providers. Spend tracking breaks down cost per key, per model and per team, with export to CSV or JSON. The proxy benchmarks at a P95 latency of around 8 milliseconds at 1,000 requests per second, according to LiteLLM's own numbers for the open-source edition.

LiteLLM Compared: SDK, Proxy and Direct Provider Code

ApproachCode changes to switch providerMulti-providerTeam controlsBest for
Direct provider SDKsRewrite the call and the parsingNoNone built inOne provider, one model, simple scripts
LiteLLM Python SDKChange the model stringYes, 100 plus providersNone built inApps that call several providers directly
LiteLLM Proxy gatewayNone, point the client at port 4000Yes, 100 plus providersVirtual keys, budgets, spend trackingTeams sharing LLM access

Getting Started in Four Steps

  1. Install. Run uv add litellm or pip install litellm. For a lean SDK-only install, use litellm-core instead.
  2. Set your keys. Export the provider keys as environment variables, for example OPENAI_API_KEY and ANTHROPIC_API_KEY.
  3. Make the first call. Call completion(model="openai/gpt-4o", messages=[...]) and read the reply from the standard response object.
  4. Switch or scale. Change the model string to try another provider, or start the proxy with litellm --config config.yaml --port 4000 and point any OpenAI client at it.

When LiteLLM Is Not the Right Tool

LiteLLM is a translation and routing layer, not an agent framework. It does not plan multi-step reasoning, manage tool schemas or build retrieval pipelines. If you need agents, retrieval or workflows, pair it with a framework that does that job. LiteLLM also cannot fix a bad prompt or a weak model. Switching providers is easy; choosing the right model for the task still takes judgement. And while the core is open source under the MIT licence, some enterprise modules sit under a separate commercial licence, so check the licence for the features you plan to use.

Bottom Line

LiteLLM earns its place when you use more than one model provider. The SDK removes the rewrite cost of switching models. The proxy adds team controls, budgets and fallbacks without touching application code. Start with the SDK for a single app, move to the proxy when a team shares access, and keep your prompts and model choices under version control either way.