# LiteLLMOCRLoader

> **Class** in `langchain_litellm`

📖 [View in docs](https://reference.langchain.com/python/langchain-litellm/document_loaders/litellm_ocr/LiteLLMOCRLoader)

Load documents using LiteLLM proxy's OCR endpoint.

This loader makes HTTP requests to a LiteLLM proxy server configured
with Azure Document Intelligence (or other OCR providers). The proxy
handles all provider-specific authentication and configuration.

## Signature

```python
LiteLLMOCRLoader(
    self,
    *,
    proxy_base_url: str = 'http://localhost:4000',
    api_key: Optional[str] = None,
    model: str = 'azure-document',
    file_path: Optional[str] = None,
    url_path: Optional[str] = None,
    base64_content: Optional[str] = None,
    bytes_content: Optional[bytes] = None,
    mode: Literal['single', 'page'] = 'single',
    timeout: float = 300.0,
    max_retries: int = 3,
)
```

## Description

**Note:**

Exactly one of file_path, url_path, base64_content, or bytes_content
must be provided.

**Example:**

Basic usage with default proxy:

```python
from langchain_litellm import LiteLLMOCRLoader

loader = LiteLLMOCRLoader(
    url_path="https://example.com/document.pdf",
    model="azure-document",
    mode="page",
)
documents = loader.load()
```

With custom proxy and authentication:

```python
loader = LiteLLMOCRLoader(
    proxy_base_url="https://my-proxy.com",
    api_key="my-bearer-token",
    file_path="/path/to/document.pdf",
    model="azure-document",
    mode="single",
)
documents = await loader.aload()
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `proxy_base_url` | `str` | No | Base URL of the LiteLLM proxy server. Defaults to "http://localhost:4000". (default: `'http://localhost:4000'`) |
| `api_key` | `Optional[str]` | No | Optional bearer token for proxy authentication. (default: `None`) |
| `model` | `str` | No | Model name configured in the proxy (e.g., "azure-document"). Defaults to "azure-document". (default: `'azure-document'`) |
| `file_path` | `Optional[str]` | No | Path to a local file to process. (default: `None`) |
| `url_path` | `Optional[str]` | No | URL to a remote document to process. (default: `None`) |
| `base64_content` | `Optional[str]` | No | Base64-encoded document content. (default: `None`) |
| `bytes_content` | `Optional[bytes]` | No | Raw bytes of a document. (default: `None`) |
| `mode` | `Literal['single', 'page']` | No | Output mode - "single" returns one document with all content, "page" returns one document per page. Defaults to "single". (default: `'single'`) |
| `timeout` | `float` | No | Request timeout in seconds. Must be positive. Defaults to 300.0 (5 minutes). (default: `300.0`) |
| `max_retries` | `int` | No | Maximum number of retry attempts for failed requests. Must be non-negative. Defaults to 3. (default: `3`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    *,
    proxy_base_url: str = 'http://localhost:4000',
    api_key: Optional[str] = None,
    model: str = 'azure-document',
    file_path: Optional[str] = None,
    url_path: Optional[str] = None,
    base64_content: Optional[str] = None,
    bytes_content: Optional[bytes] = None,
    mode: Literal['single', 'page'] = 'single',
    timeout: float = 300.0,
    max_retries: int = 3,
) -> None
```

| Name | Type |
|------|------|
| `proxy_base_url` | `str` |
| `api_key` | `Optional[str]` |
| `model` | `str` |
| `file_path` | `Optional[str]` |
| `url_path` | `Optional[str]` |
| `base64_content` | `Optional[str]` |
| `bytes_content` | `Optional[bytes]` |
| `mode` | `Literal['single', 'page']` |
| `timeout` | `float` |
| `max_retries` | `int` |


## Properties

- `proxy_base_url`
- `api_key`
- `model`
- `file_path`
- `url_path`
- `base64_content`
- `bytes_content`
- `mode`
- `timeout`
- `max_retries`

## Methods

- [`load()`](https://reference.langchain.com/python/langchain-litellm/document_loaders/litellm_ocr/LiteLLMOCRLoader/load)
- [`aload()`](https://reference.langchain.com/python/langchain-litellm/document_loaders/litellm_ocr/LiteLLMOCRLoader/aload)
- [`lazy_load()`](https://reference.langchain.com/python/langchain-litellm/document_loaders/litellm_ocr/LiteLLMOCRLoader/lazy_load)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-litellm/blob/d166813e37b312df5bb379de181413abbcd8ec83/langchain_litellm/document_loaders/litellm_ocr.py#L17)