BerriAI/litellm · error · NotImplementedError

transform_ocr_request must be implemented by provider

Error message

transform_ocr_request must be implemented by provider

What it means

Error "transform_ocr_request must be implemented by provider" thrown in BerriAI/litellm.

Solutions

  1. Use a provider that implements OCR; transform_ocr_request is abstract in the base class.
  2. Implement transform_ocr_request in the custom provider's transformation class.
  3. Verify the model string routes to a provider with OCR support.

When it happens

Trigger: Thrown at litellm/llms/base_llm/ocr/transformation.py:176 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/1189fa211e04eb71. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/base_llm/ocr/transformation.py:176

    ) -> OCRRequestData:
        """
        Transform OCR request to provider-specific format.
        Override in provider-specific implementations.

        Note: By the time this method is called, any file-type documents have already
        been converted to document_url/image_url format with base64 data URIs by
        the preprocessing in litellm/ocr/main.py.

        Args:
            model: Model name
            document: Document to process - always a dict with type="document_url" or type="image_url"
            optional_params: Optional parameters for the request
            headers: Request headers

        Returns:
            OCRRequestData with data and files fields
        """
        raise NotImplementedError("transform_ocr_request must be implemented by provider")

    async def async_transform_ocr_request(
        self,
        model: str,
        document: DocumentType,
        optional_params: dict,
        headers: dict,
        **kwargs,
    ) -> OCRRequestData:
        """
        Async transform OCR request to provider-specific format.
        Optional method - providers can override if they need async transformations
        (e.g., Azure AI for URL-to-base64 conversion).

        Default implementation falls back to sync transform_ocr_request.

        Args:
            model: Model name

View on GitHub (pinned to 77b7c6c40c)