Skip to main content
LiteLLM is a library that simplifies calling Anthropic, Azure, Huggingface, Replicate, etc. This page covers how to get started using LangChain with the LiteLLM I/O library. This integration provides two chat model classes:
  • ChatLiteLLM: The main LangChain chat wrapper for LiteLLM.
  • ChatLiteLLMRouter: A ChatLiteLLM wrapper that leverages LiteLLM’s Router for load balancing and fallbacks.
The package also ships LiteLLMEmbeddings, LiteLLMEmbeddingsRouter, and LiteLLMOCRLoader. See the providers page for details.

Overview

Integration details

ClassPackageSerializableJS supportDownloadsVersion
ChatLiteLLMlangchain-litellmPyPI - DownloadsPyPI - Version
ChatLiteLLMRouterlangchain-litellmPyPI - DownloadsPyPI - Version

Model features

Tool callingStructured outputImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs

Setup

To access ChatLiteLLM and ChatLiteLLMRouter models, you’ll need to install the langchain-litellm package and create an OpenAI, Anthropic, Azure, Replicate, OpenRouter, Hugging Face, Together AI, or Cohere account. Then, you have to get an API key and export it as an environment variable.

Credentials

You have to choose the LLM provider you want and sign up with them to get their API key.

Example - Anthropic

Head to the Claude console to sign up and generate a Claude API key. Once you’ve done this set the ANTHROPIC_API_KEY environment variable:

Example - OpenAI

Head to platform.openai.com/api-keys to sign up for OpenAI and generate an API key. Once you’ve done this, set the OPENAI_API_KEY environment variable.

Installation

The LangChain LiteLLM integration is available in the langchain-litellm package:

Instantiation

ChatLiteLLM

You can instantiate a ChatLiteLLM model by providing a model name supported by LiteLLM.

ChatLiteLLMRouter

You can also leverage LiteLLM’s routing capabilities by defining your model list as specified in the LiteLLM routing documentation.

Invocation

Whether you’ve instantiated a ChatLiteLLM or a ChatLiteLLMRouter, you can now use the ChatModel through LangChain’s API.

Async and streaming functionality

ChatLiteLLM and ChatLiteLLMRouter also support async and streaming functionality:

Advanced features

Use Google Search grounding with Vertex AI models (e.g., gemini-3.5-flash). Citations and metadata are returned in response_metadata (batch) or additional_kwargs (streaming). Setup
Batch usage
Streaming usage

API reference

For detailed documentation of all ChatLiteLLM and ChatLiteLLMRouter features and configurations, see the langchain-litellm API reference.