> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LiteLLM integrations

> Integrate with LiteLLM using LangChain Python.

> [LiteLLM](https://github.com/BerriAI/litellm) is a library that simplifies calling Anthropic, Azure, Huggingface, Replicate, and many other LLM providers through a single unified interface.

## Installation and setup

<CodeGroup>
  ```bash pip theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  pip install langchain-litellm
  ```

  ```bash uv theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  uv add langchain-litellm
  ```
</CodeGroup>

## Chat models

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import ChatLiteLLM
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import ChatLiteLLMRouter
```

See the [LiteLLM chat guide](/oss/python/integrations/chat/litellm) for full usage details, including streaming, tool calling, structured output, and Vertex AI Grounding.

## Embeddings

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import LiteLLMEmbeddings
```

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import LiteLLMEmbeddingsRouter
```

`LiteLLMEmbeddings` embeds text across 100+ providers with a single consistent interface. All configuration is explicit, with no environment variables required.

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import LiteLLMEmbeddings

embeddings = LiteLLMEmbeddings(
    model="openai/text-embedding-3-small",
    api_key="sk-...",
)

vectors = embeddings.embed_documents(["hello", "world"])
query_vector = embeddings.embed_query("hello")
```

Switch providers by changing `model`. The interface stays the same:

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
# Cohere
embeddings = LiteLLMEmbeddings(
    model="cohere/embed-english-v3.0",
    api_key="...",
    document_input_type="search_document",
    query_input_type="search_query",
)

# Azure OpenAI
embeddings = LiteLLMEmbeddings(
    model="azure/my-embedding-deployment",
    api_key="...",
    api_base="https://my-resource.openai.azure.com",
    api_version="2024-02-01",
)

# Bedrock
embeddings = LiteLLMEmbeddings(
    model="bedrock/amazon.titan-embed-text-v1",
)
```

For load-balancing across multiple deployments of the same model, use `LiteLLMEmbeddingsRouter`:

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from litellm import Router
from langchain_litellm import LiteLLMEmbeddingsRouter

router = Router(model_list=[
    {
        "model_name": "text-embedding-3-small",
        "litellm_params": {
            "model": "openai/text-embedding-3-small",
            "api_key": "sk-key1",
        },
    },
    {
        "model_name": "text-embedding-3-small",
        "litellm_params": {
            "model": "openai/text-embedding-3-small",
            "api_key": "sk-key2",
        },
    },
])

embeddings = LiteLLMEmbeddingsRouter(router=router)
```

## Document loaders

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import LiteLLMOCRLoader
```

`LiteLLMOCRLoader` loads documents via a LiteLLM proxy's OCR endpoint (e.g. Azure Document Intelligence). The proxy handles all provider-specific authentication and configuration.

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_litellm import LiteLLMOCRLoader

loader = LiteLLMOCRLoader(
    proxy_base_url="http://localhost:4000",
    api_key="my-bearer-token",
    url_path="https://example.com/document.pdf",
    model="azure-document",
    mode="page",  # "page" = one Document per page; "single" = concatenate all pages
)
documents = loader.load()
```

Async loading is also supported:

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
documents = await loader.aload()
```

***

## API reference

For detailed documentation of all classes and configurations, see the [langchain-litellm](https://reference.langchain.com/python/langchain-litellm/) API reference.

| Class                                                                                                                                 | Description                                                         |
| :------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------ |
| [ChatLiteLLM](https://reference.langchain.com/python/langchain-litellm/chat_models/litellm/ChatLiteLLM)                               | LangChain chat model wrapper for LiteLLM                            |
| [ChatLiteLLMRouter](https://reference.langchain.com/python/langchain-litellm/chat_models/litellm_router/ChatLiteLLMRouter)            | Router-backed chat model for load balancing and fallbacks           |
| [LiteLLMEmbeddings](https://reference.langchain.com/python/langchain-litellm/embeddings/litellm/LiteLLMEmbeddings)                    | Embed text across 100+ providers with a single consistent interface |
| [LiteLLMEmbeddingsRouter](https://reference.langchain.com/python/langchain-litellm/embeddings/litellm_router/LiteLLMEmbeddingsRouter) | Router-backed embeddings for load balancing across deployments      |
| [LiteLLMOCRLoader](https://reference.langchain.com/python/langchain-litellm/document_loaders/litellm_ocr/LiteLLMOCRLoader)            | Document loader via LiteLLM proxy's OCR endpoint                    |

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/litellm.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
