{"record":{"id":"f6b75426f6cb2131","repo":"PaddlePaddle/PaddleOCR","slug":"unsupported-ocr-model-model","errorCode":null,"errorMessage":"Unsupported OCR model: {model}","messagePattern":"Unsupported OCR model: (.+?)","errorType":"validation","errorClass":"InvalidRequestError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_core.py","lineNumber":54,"sourceCode":"\n\ndef validate_input_source(file_url: Optional[str], file_path: Optional[str]) -> None:\n    if not file_url and not file_path:\n        raise InvalidRequestError(\"Either file_url or file_path is required.\")\n    if file_url and file_path:\n        raise InvalidRequestError(\"file_url and file_path are mutually exclusive.\")\n\n\ndef default_payload(model: Model) -> dict:\n    if is_ocr_model(model):\n        return OCROptions().to_payload()\n    return resolve_document_options(model, None).to_payload()\n\n\ndef resolve_ocr_model(model: Union[Model, str]) -> Model:\n    resolved = resolve_model(model)\n    if not is_ocr_model(resolved):\n        raise InvalidRequestError(f\"Unsupported OCR model: {model}\")\n    return resolved\n\n\ndef resolve_document_model(model: Union[Model, str]) -> Model:\n    resolved = resolve_model(model)\n    if not is_document_parsing_model(resolved):\n        raise InvalidRequestError(f\"Unsupported document parsing model: {model}\")\n    return resolved\n\n\ndef resolve_model(model: Union[Model, str]) -> Model:\n    if isinstance(model, Model):\n        return model\n    try:\n        return Model(model)\n    except ValueError as e:\n        raise InvalidRequestError(f\"Unsupported model: {model}\") from e\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_core.py#L36-L72","documentation":"Raised as InvalidRequestError by resolve_ocr_model() when the resolved model is not in the OCR model set. The model may be a valid Model enum member (e.g. a document-parsing or VL model) but is being passed to an OCR-specific entry point. Resolution happens before any request is sent.","triggerScenarios":"Calling an OCR method with model='PP-StructureV3' or a VL model string/enum, or any string that resolves to a non-OCR Model.","commonSituations":"Confusing the OCR and document-parsing APIs after a version upgrade that split them, or reusing a configured model name across different endpoints.","solutions":["Use an OCR model (check the Model enum members satisfying is_ocr_model) for OCR calls.","If you intended document parsing or VL, call the document-parsing entry point instead.","List valid options via the Model enum to confirm naming."],"exampleFix":"# before\nresult = client.ocr(file_path=\"a.png\", model=\"PP-StructureV3\")\n\n# after\nresult = client.ocr(file_path=\"a.png\", model=\"PP-OCRv5\")  # or use the document-parsing API","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from paddleocr._api_client.models import is_ocr_model, resolve_model\n\ndef usable_for_ocr(model) -> bool:\n    try:\n        return is_ocr_model(resolve_model(model))\n    except Exception:\n        return False","tryCatchPattern":"from paddleocr._api_client.errors import InvalidRequestError\ntry:\n    result = client.ocr(file_path=p, model=model)\nexcept InvalidRequestError as e:\n    if \"Unsupported OCR model\" in str(e):\n        model = \"PP-OCRv5\"  # fall back to a known OCR model","preventionTips":["Keep model names in typed config validated against the Model enum at startup.","Use separate config fields for OCR vs document-parsing models."],"tags":["validation","model","client-side"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}