{"record":{"id":"1189fa211e04eb71","repo":"BerriAI/litellm","slug":"transform-ocr-request-must-be-implemented-by-provi","errorCode":null,"errorMessage":"transform_ocr_request must be implemented by provider","messagePattern":"transform_ocr_request must be implemented by provider","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/ocr/transformation.py","lineNumber":176,"sourceCode":"    ) -> OCRRequestData:\n        \"\"\"\n        Transform OCR request to provider-specific format.\n        Override in provider-specific implementations.\n\n        Note: By the time this method is called, any file-type documents have already\n        been converted to document_url/image_url format with base64 data URIs by\n        the preprocessing in litellm/ocr/main.py.\n\n        Args:\n            model: Model name\n            document: Document to process - always a dict with type=\"document_url\" or type=\"image_url\"\n            optional_params: Optional parameters for the request\n            headers: Request headers\n\n        Returns:\n            OCRRequestData with data and files fields\n        \"\"\"\n        raise NotImplementedError(\"transform_ocr_request must be implemented by provider\")\n\n    async def async_transform_ocr_request(\n        self,\n        model: str,\n        document: DocumentType,\n        optional_params: dict,\n        headers: dict,\n        **kwargs,\n    ) -> OCRRequestData:\n        \"\"\"\n        Async transform OCR request to provider-specific format.\n        Optional method - providers can override if they need async transformations\n        (e.g., Azure AI for URL-to-base64 conversion).\n\n        Default implementation falls back to sync transform_ocr_request.\n\n        Args:\n            model: Model name","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/ocr/transformation.py#L158-L194","documentation":"Base OCR transformation stub for transform_ocr_request: converting the unified document input (document_url / image_url dict produced by litellm/ocr/main.py preprocessing) into a provider payload is provider-specific, so the base class raises NotImplementedError. A config without this override cannot serve OCR requests.","triggerScenarios":"litellm.ocr() invoked with a provider config lacking transform_ocr_request; partially implemented custom OCR integration; provider resolution falling through to the base config (unknown custom_llm_provider).","commonSituations":"Contributing a new OCR provider and forgetting the request transform; model strings like 'ocr/my-provider' not matching any registered config; running an older litellm against docs for a newer provider integration.","solutions":["Implement transform_ocr_request in the provider config returning OCRRequestData(data=..., files=...).","Confirm the provider string in the model name resolves to a concrete OCR config (check the provider registry).","Switch to a supported OCR provider until the custom one is complete.","Update litellm if support for the provider exists upstream."],"exampleFix":"# before\nclass MyOCRConfig(BaseOCRConfig): ...\n# NotImplementedError at request transform\n\n# after\nclass MyOCRConfig(BaseOCRConfig):\n    def transform_ocr_request(self, model, document, optional_params, headers, **kwargs):\n        return OCRRequestData(data={'url': document['document_url']['url'], 'model': model}, files=None)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def can_transform_ocr_request(config) -> bool:\n    return type(config).transform_ocr_request is not BaseOCRConfig.transform_ocr_request","tryCatchPattern":"try:\n    req = config.transform_ocr_request(model, document, optional_params, headers)\nexcept NotImplementedError:\n    raise ConfigError('provider config incomplete: transform_ocr_request missing') from None","preventionTips":["Write the full provider contract (URL + request + response) before registering a config.","Add unit tests exercising each hook directly on registered configs.","Route unknown provider strings to an explicit error instead of the base config."],"tags":["ocr","not-implemented","request-pipeline","provider-config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}