{"record":{"id":"11b95b55f2596404","repo":"BerriAI/litellm","slug":"invalid-document-type-doc-type-must-be-docume-11b95b","errorCode":null,"errorMessage":"Invalid document type: {doc_type}. Must be 'document_url', 'image_url', or 'file'","messagePattern":"Invalid document type: (.+?)\\. Must be 'document_url', 'image_url', or 'file'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/ocr/main.py","lineNumber":88,"sourceCode":"    timeout: float | httpx.Timeout | None,\n    custom_llm_provider: str | None,\n    extra_headers: dict[str, object] | None,\n    kwargs: dict[str, object],\n) -> _PreparedOCRRequest:\n    litellm_logging_obj: Final = cast(LiteLLMLoggingObj, kwargs.pop(\"litellm_logging_obj\"))\n    litellm_call_id: Final = cast(str | None, kwargs.get(\"litellm_call_id\", None))\n\n    if not isinstance(document, dict):\n        raise ValueError(f\"document must be a dict with 'type' and URL/file field, got {type(document)}\")\n\n    doc_type = document.get(\"type\")\n\n    if doc_type == \"file\":\n        document = convert_file_document_to_url_document(document)\n        doc_type = document.get(\"type\")\n\n    if doc_type not in [\"document_url\", \"image_url\"]:\n        raise ValueError(f\"Invalid document type: {doc_type}. Must be 'document_url', 'image_url', or 'file'\")\n\n    caller_supplied_api_base: Final = api_base is not None\n\n    (\n        model,\n        custom_llm_provider,\n        dynamic_api_key,\n        dynamic_api_base,\n    ) = litellm.get_llm_provider(\n        model=model,\n        custom_llm_provider=custom_llm_provider,\n        api_base=api_base,\n        api_key=api_key,\n    )\n\n    suppress_dynamic_api_base: Final = (\n        not caller_supplied_api_base\n        and custom_llm_provider == \"azure_ai\"","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/ocr/main.py#L70-L106","documentation":"Raised while preparing an OCR request when the `document` dict's 'type' field is not one of the three recognized kinds ('document_url', 'image_url', 'file'). The preceding check already guarantees document is a dict, so this error specifically means the type discriminator is missing or misspelled — e.g. a caller sent 'url' instead of 'document_url'.","triggerScenarios":"Thrown at litellm/ocr/main.py:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the supported document types: 'document_url', 'image_url', or 'file'.","Fix the 'type' value in the document dict to one of the supported literals."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}