PaddlePaddle/PaddleOCR · error · InvalidRequestError
Job model is not an OCR model: {job.model}.
Error message
Job model is not an OCR model: {job.model}. What it means
Raised as InvalidRequestError by job_id_for_task() when task == 'ocr' but the Job's model fails is_ocr_model(). It catches Jobs that claim the OCR task while carrying a non-OCR model, before an OCR endpoint is called with an incompatible job id.
Source
Thrown at paddleocr/_api_client/_core.py:98
):
raise InvalidRequestError("PP-StructureV3 requires PPStructureV3Options.")
if is_vl_model(model) and not isinstance(options, PaddleOCRVLOptions):
raise InvalidRequestError("PaddleOCR-VL models require PaddleOCRVLOptions.")
return options
if model == Model.PP_STRUCTURE_V3:
return PPStructureV3Options()
return PaddleOCRVLOptions()
def job_id_for_task(job: Union[Job, str], task: str) -> str:
if isinstance(job, str):
return job
if job.task != task:
raise InvalidRequestError(
f"Job task mismatch: expected {task}, got {job.task}."
)
if task == "ocr" and not is_ocr_model(job.model):
raise InvalidRequestError(f"Job model is not an OCR model: {job.model}.")
if task == "document_parsing" and not is_document_parsing_model(job.model):
raise InvalidRequestError(
f"Job model is not a document parsing model: {job.model}."
)
return job.job_id
def extract_api_message_from_payload(payload: dict) -> Optional[str]:
for key in ("msg", "errorMsg", "message"):
value = payload.get(key)
if value:
return str(value)
data = payload.get("data")
if isinstance(data, dict):
value = data.get("errorMsg")
if value:
return str(value)
return NoneView on GitHub (pinned to 2661c7c0ef)
Solutions
- Use the Job returned by the matching create call; do not synthesize Job objects manually.
- Verify job.model is an OCR model before calling OCR follow-up methods.
- If the job is genuinely document parsing, use the document-parsing endpoint.
Example fix
# before ocr_result = client.get_ocr_result(job) # job.model is PP-StructureV3 # after assert is_ocr_model(job.model), "use document-parsing result API for this job" ocr_result = client.get_ocr_result(job)
Defensive patterns
Strategy: type-guard
Type guard
from paddleocr._api_client.models import is_ocr_model
def job_is_ocr(job) -> bool:
return job.task == "ocr" and is_ocr_model(job.model) Prevention
- Only pass Job objects returned by the corresponding create call.
- Validate deserialized Jobs before use.
When it happens
Trigger: Passing a Job whose model is a document-parsing or VL model to an OCR-scoped method (task='ocr').
Common situations: Hand-constructed or deserialized Job objects with inconsistent task/model fields, or jobs from an older version where task semantics differed.
Related errors
- Job model is not a document parsing model: {job.model}.
- Unsupported OCR model: {model}
- Unsupported document parsing model: {model}
- Unsupported model: {model}
- PP-StructureV3 requires PPStructureV3Options.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/e5577505d9b9ae53.
Report an issue: GitHub.