- LiteLLM unifies access to over 100 LLMs through an OpenAI-compatible API, simplifying multi-vendor development.
- It combines a lightweight Python SDK with a self-hosting proxy server that centralizes security, costs, and observability.
- It offers advanced routing, fallbacks, and virtual key management, reducing vendor lock-in and improving resilience.
- It is open source, integrates with tools like LangChain or LlamaIndex, and fits well as an AI gateway in enterprise environments.

When a company starts experimenting with generative artificial intelligence, it quickly hits a wall: there are dozens of models, each with its own API, parameters, and quirks . OpenAI on one hand, Anthropic on the other, Google with its own, local providers, open-source models… and every change requires rewriting code, managing different credentials, and dealing with incompatible response formats. In the end, time is spent on technical “plumbing” instead of creating useful products.
In this context, LiteLLM emerges as a kind of "Rosetta Stone" for LLM. LiteLLM is an abstraction layer and gateway that allows you to communicate with over a hundred AI models using, essentially, the same language: the OpenAI API . It doesn't matter if you're using GPT-4o, Claude 3.5, Gemini, Vertex AI models, Ollama, or Hugging Face: your application always sends the same request structure and always receives the same type of response, while LiteLLM handles translation, routing, cost logging, and security policy enforcement.
What exactly is LiteLLM?
LiteLLM is an open-source project that unifies access to over 100 language models and multimodal models , wrapping APIs from various vendors in an OpenAI-compatible interface. Conceptually, it acts as an intermediary between your code and the LLM ecosystem, so you think in terms of a "logical model" (an alias), and LiteLLM handles the communication with the actual model on the other side.
From a practical standpoint, LiteLLM has two distinct but complementary components: a lightweight Python SDK and a proxy server (LLM Gateway) . The SDK is designed for developers who want to quickly integrate multiple LLMs into their code without setting up additional services. The proxy, on the other hand, is geared towards teams, MLOps, and organizations that require centralized cost control, security, observability, and high availability.
Thanks to this architecture, You can write the integration code once and reuse it with any provider.If today you're using GPT-4o and tomorrow you want to try a Claude 3.5 or a local model in Ollama, normally you'll only change the parameter value model or the alias you defined in the proxy settings, without touching anything else.
Another key point is that LiteLLM It standardizes not only the calls, but also the response format.The outputs of the models are consistently exposed under structures of the type response['choices'][0]['message']['content']This greatly simplifies working with frameworks like LangChain or LlamaIndex, or with any backend that expects the typical OpenAI structure.
Why a layer like LiteLLM is needed in the LLM ecosystem
The world of language models is booming: OpenAI, Anthropic, Google, Meta, cloud providers like Azure and Bedrock, and platforms like Hugging Face and Ollama are constantly launching and updating models. Each has its own API, usage limits, token format, and nuances in authentication, not to mention billing and credential management.
This diversity is an advantage because it allows you to choose the optimal model for each use case: creative text, reasoning, code, vision, voice, video, etc. But it also generates enormous complexity: if your company truly wants to be a "multi-LLM," you end up replicating integration logic, key storage, quota control, and metrics across every service. Furthermore, the risk of vendor lock-in increases if your code is tightly coupled to a specific API.
LiteLLM tackles this problem head-on by creating a standard LLM access layer that can be deployed both on-premises and in the cloud . Under the hood, the project supports:
- Business models such as GPT‑4o and family, Claude 3.5, Gemini, Vertex AI models, AWS Bedrock, Azure OpenAI, etc.
- Open source and local models through integrations with Ollama, Hugging Face and inference servers such as vLLM.
- Multimodal models (text, image, in some cases video) through specialized providers such as RunwayML or Fal.ai.
With this in mind, LiteLLM acts as a central hub where model aliases, usage policies, fallback routes, and routing strategies are defined . For teams, this means they can experiment with new models or switch providers without breaking clients already in production.
Main components: Python SDK and Proxy Server
The LiteLLM SDK in Python is the most direct way to get startedYou install it with pip, configure the API keys via environment variables, and call it. litellm.completion(...) or equivalent functions, just as you would with the OpenAI SDK. The difference is that here you can pass as model any supported identifier, for example:
model="gpt-4o" for OpenAI or model="anthropic/claude-3-5-sonnet-20240620" for Anthropic, using the same function and the same message format.
This mode is ideal when you're prototyping, running individual tests, or setting up small projects where you don't need a dedicated gateway. Switching models almost always involves modifying a string of text.
The other major component is the LiteLLM Proxy Server, also called the LLM Gateway . This is a centralized service (usually deployed on Docker or Kubernetes) through which all LLM requests from your organization pass. From there, the following are managed:
- Model aliases defined in
config.yaml, which point to specific suppliers and models. - Virtual API keys for equipment or applications, each with its own budget, usage limits, and permissions.
- Advanced routing ruleswith fallback between models, load balancing, and selection by cost or latency.
- Logging and centralized observabilityincluding latency, errors, prompts and responses (with anonymization options).
In many companies, the proxy becomes the mandatory gateway for all services that want to use LLMs , something very similar to a traditional API Gateway but specialized in generative AI.
Getting started with LiteLLM: installation, Docker, and model registration
If you want to quickly experiment with the LiteLLM proxy, the cleanest way is to clone the official repository and start the containers with Docker Compose . The typical workflow would look something like this (simplified commands):
- Clone the GitHub repo.
- Create a file
.envwith two important keys: LITELLM_MASTER_KEY (to access the panel and manage models) and LITELLM_SALT_KEY (to encrypt supplier credentials). - Build the infrastructure with
docker-compose up.
Once turned on, you normally access http://localhost:4000 and you log in with the administrator user (which you can change) and the master key defined in the environment. From that web interface, it is possible to register new models, review usage, create virtual keys, etc.
Registering a new model is relatively straightforward: In the panel, go to “Models >> Add model” and choose the provider.Then you enter the corresponding API key, define the internal alias that this model will have (for example, Llama3.2-90B-UltrafastAnd, if you wish, you can customize parameters such as cost per token or maximum incoming and outgoing tokens. This name abstraction allows you to use more user-friendly aliases than the long identifiers of the providers.
In practice, many people take advantage of this to showcase high-performance models like those from Groqwhich stand out for their very low inference latency thanks to their hardware LPU. In the panel you can register a Groq model with its original name (for example, llama-3.2-90b-text-preview) and, outwards, call it whatever you want without affecting the logic of your application.
Another very common deployment method is to use directly the LiteLLM image in Docker containers next to a config.yamlwithout needing to clone the entire repository. In that YAML you define a model_list With each alias and connection parameters (real model, base API, key, etc.), you mount the file as a volume to the container and expose port 4000 to your internal network.
How to make requests to LiteLLM (using its own SDK, OpenAI SDK, and cURL)
Once you have the proxy working, the easiest thing to do is treat it as if it were the OpenAI endpointThis means that any SDK or client compatible with the OpenAI API can be pointed to it. base_url from your LiteLLM and take advantage of the model aliases you have configured.
If you use the LiteLLM SDK in Python, The recommendation is to explicitly state the supplier and model. in the parameter modelfollowing the pattern "proveedor/nombre_modelo". For example: uterine
model="groq/Llama3.2-90B-Ultrafast"
The rest of the call is similar to OpenAI: You send him a list of messages with his role (user, system, assistant) and its content, you can activate stream=True to receive the text in chunks and process each chunk in a loop. The SDK exposes the deltas in a structure like chunk['choices'][0]['delta']['content'].
If you prefer to work with the official OpenAI SDK, it's even simpler: You configure the client with base_url="http://tu-litellm" and a “virtual” API key (which can be any string if you have defined it that way in the proxy), and you call client.chat.completions.create As always. In this scenario, the only thing that changes is the value of model, which will be the alias you defined in LiteLLM, without needing to include the provider.
Finally, you always have the option of directly pull cURL against the endpoint /v1/chat/completions from your gateway. In this case, you send a JSON object with the model, the message list, and the streaming flag if needed, and LiteLLM responds just like the official OpenAI API. This approach is great for quick terminal tests, scripts in other languages, or debugging.
Advanced features: routing, fallbacks, costs, and observability
LiteLLM isn't just a "pretty wrapper" to avoid learning 20 SDKs; it's designed for production and covers the entire lifecycle of LLM integration . Some key capabilities include:
Advanced routing and fault tolerance . You can define chains of backup models: if the primary model fails, exceeds its quota, or runs out of capacity, LiteLLM automatically retries with the next model in the list. It also supports various load balancing strategies (by cost, latency, or weight) to distribute the load across multiple deployments of the same model or equivalent models.
Cost and budget tracking . The Proxy Server offers real-time spending tracking by vendor, virtual key, user, or team . This allows you to set monthly or daily limits: if a team exceeds its budget, requests can be blocked or downgraded to a less expensive plan. For a product manager or CTO, this is a very useful tool for avoiding surprises on the AI bill.
Centralized observability . LiteLLM logs inputs, outputs, latencies, and errors in a single location , facilitating both debugging and quality monitoring. There are ready-made integrations with tools like Langfuse, Helicone, Datadog, and OpenTelemetry, as well as traditional logging systems. In regulated environments, you can configure how and how much to log, and even anonymize parts of the prompt.
Multimodal support . Although initially focused on text models, LiteLLM has expanded its capabilities to handle images and video through specific providers. All of this is done while maintaining the "same interface, different models" philosophy, which facilitates experimenting with image generation, video, or mixed pipelines without redesigning the integration.
Team management and security . Virtual API keys with specific permissions and budgets can be issued through the proxy panel . This means that end users never see the actual keys from OpenAI, Anthropic, etc., but rather internal tokens that LiteLLM maps to the master credentials. You can also limit which models each team can use, configure quotas per project, or require specific headers for auditing.
Security, key management, and attack context in the supply chain
With AI booming, security has become critical, especially regarding key management and third-party dependencies . The Python ecosystem, in particular, has suffered several supply chain attacks on PyPI in recent years, with malicious packages stealing tokens, exfiltrating data, or modifying CI/CD pipelines.
Campaigns such as GlassWorm/ForceMemo, which compromised GitHub repositories to steal credentials , have been documented , as well as incidents like the Ultralytics compromise, which affected widely used computer vision packages. Typo-squatting attacks (for example, packages with names almost identical to "colorama") that inserted backdoors into production environments have also been prevalent.
In the specific case of LiteLLM, to date there is no confirmed evidence that the package has been compromised via a supply chain attack . Some issues on GitHub have indicated problems with memory consumption or CPU spikes, but no exploitable vulnerabilities or data exfiltration linked to the project have been reported. Even so, in such a volatile environment, it's understandable that security teams are on high alert.
For founders, CTOs, and platform managers, it makes sense to take extra precautions: verify the origin and reputation of packages, use signing and verification tools (like Sigstore), and monitor for anomalous behavior on servers and containers . If anything is suspicious, aggressively rotating credentials and auditing access in pipelines and deployments is the right course of action, whether the suspicious dependency is LiteLLM or any other key package.
Technical configuration, prerequisites, and deployment with Docker Compose
For LiteLLM to function stably in a serious environment, There are a number of basic requirements that should be well defined.First, you need a compatible version of Python (if you're going to use the SDK or admin scripts), a package manager like pip and a decent editor (VS Code, PyCharm or similar) to develop your integrations.
Additionally, you'll need accounts with the LLM providers you'll be working with (OpenAI, Anthropic, Google Cloud, AWS, Hugging Face, etc.) and their corresponding API keys. Typically, these are loaded as environment variables or via a secrets manager (Vault, AWS Secrets Manager, GCP Secret Manager, etc.), and then LiteLLM securely consumes them.
Regarding configuration, there are two important sections: the LiteLLM environment variables and the proxy configuration file . The following stand out among the former:
- LITELLM_MASTER_KEY: master key to access the administration panel.
- LITELLM_SALT_KEY: seed used to encrypt and decrypt the providers' credentials.
- Supplier API keys (for example,
OPENAI_API_KEY,ANTHROPIC_API_KEY, etc.).
Then the file config.yaml Define which models are exposed through the proxy and under which aliasEach entry in model_list usually includes the model_name that your application will see, the actual provider model, the reference to the API key (often declared as os.environ/NOMBRE_VARIABLE) and adjustments such as verbosity or model-specific parameters.
Docker Compose is very practical for orchestrating a LiteLLM instance along with dependencies like Redis (for caching), databases, or observability tools . Each service runs in its own container, providing isolation, reproducibility, and easy horizontal scaling as traffic grows. With a single YAML file, you can define how all components connect and launch the entire stack in dev, staging, and production environments with virtually the same command.
LiteLLM vs. Other LLM Gateways
In a rapidly evolving market, LiteLLM competes with (and complements) solutions like OpenRouter, Portkey, and Kong AI Gateway . They all address the same fundamental problem: centralizing and standardizing access to multiple models, but with significant differences in approach and deployment.
LiteLLM stands out for being completely open source, self-hostable, and having no token fees . You manage the infrastructure (whether it's a modest server or a Kubernetes cluster) and only pay the LLM and hosting providers' bills. This makes it especially attractive for companies that want maximum control over data and regulatory compliance, or that handle sensitive information that cannot leave their network.
OpenRouter, on the other hand, functions primarily as an aggregated SaaS that exposes hundreds of models through a single, managed API . It's very convenient because you don't have to deploy anything, but it does involve relinquishing some control over the data flow and paying a small surcharge on top of the token cost. This might make sense if you prioritize convenience over control.
Portkey and Kong AI Gateway are positioned more as advanced observability, security, and governance platforms , with very powerful features for the enterprise world. In that context, LiteLLM tends to be more appealing when open source and flexibility are the priorities, while the other strengths may be more attractive when you already have a well-established stack of API gateways and observability tools.
In short, LiteLLM is a particularly good fit for teams that want an AI gateway they can audit, modify, and deploy wherever they need , without being entirely dependent on a third party. And if you ever need to integrate it with other gateways or frameworks like LangChain or LlamaIndex, the fact that it emulates the OpenAI API makes things much easier.
Practical implications for developers, product, and MLOps
Adopting LiteLLM isn't just a technical change; it also impacts how teams think and work with AI . For developers, the most obvious benefit is the time saved: instead of learning three or four different SDKs, they manage one and focus on business logic. Less "glue" and more real functionality.
For product or technical leadership roles, the value lies in visibility and cost control . Having a single point of view to see which models are being used, how much they cost, which teams consume the most tokens, and what impact switching from an expensive to a cheaper model has, provides flexibility when prioritizing initiatives and adjusting budgets.
In the realm of MLOps and AI platforms, LiteLLM can become the cornerstone of a multi-LLM strategy . From there, usage policies are defined, observability tools are integrated, fallback flows are orchestrated, and common services are provided to the rest of the organization (“AI as an internal service”). This also entails new responsibilities: robustly managing infrastructure, automating deployments, monitoring performance and latency, and closely tracking the project's progress on GitHub.
All of this is happening in parallel with a fundamental trend: the industry is shifting from thinking about “which model to use” to “which application to build and what combination of models best allows me to do so .” LiteLLM, by reducing friction in testing and combining models, is well-positioned for this future of applications driven by multiple specialized LLMs and SLMs collaborating with each other.
Given all of the above, it's easy to see why LiteLLM has become such a prominent component in the AI ecosystem: it tangibly reduces the complexity of working with many models, improves cost control and security, and opens the door for companies of any size to seriously pursue a multi-LLM approach without getting bogged down in implementation details . If your challenge today is to tame the chaos of AI APIs scattered throughout your stack, adding a LiteLLM layer is often one of the most cost-effective moves.
Table of Contents
- 1 What exactly is LiteLLM?
- 2 Why a layer like LiteLLM is needed in the LLM ecosystem
- 3 Main components: Python SDK and Proxy Server
- 4 Getting started with LiteLLM: installation, Docker, and model registration
- 5 How to make requests to LiteLLM (using its own SDK, OpenAI SDK, and cURL)
- 6 Advanced features: routing, fallbacks, costs, and observability
- 7 Security, key management, and attack context in the supply chain
- 8 Technical configuration, prerequisites, and deployment with Docker Compose
- 9 LiteLLM vs. Other LLM Gateways
- 10 Practical implications for developers, product, and MLOps