{"record":{"id":"acc44e351a44b943","repo":"BerriAI/litellm","slug":"ocr-response-usage-info-is-none","errorCode":null,"errorMessage":"OCR response usage_info is None","messagePattern":"OCR response usage_info is None","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/cost_calculator.py","lineNumber":1826,"sourceCode":"        model: str - model name\n        custom_llm_provider: Optional[str] - custom LLM provider\n        response: Optional[Any] - response object\n\n    Returns:\n        Tuple[float, float]: cost of OCR processing\n\n        (Parent function requires a tuple, so we return a tuple. Cost is only in the first element.)\n    \"\"\"\n    from litellm.llms.base_llm.ocr.transformation import OCRResponse\n\n    #########################################################\n    # validate it's an OCR response\n    #########################################################\n    if response is None or not isinstance(response, OCRResponse):\n        raise ValueError(f\"response must be of type OCRResponse got type={type(response)}\")\n\n    if response.usage_info is None:\n        raise ValueError(\"OCR response usage_info is None\")\n\n    try:\n        model_info: ModelInfo | None = litellm.get_model_info(model=model, custom_llm_provider=custom_llm_provider)\n    except Exception:\n        model_info = None\n\n    credits: Final = getattr(response.usage_info, \"credits\", None)\n    cost_per_credit = None\n    if model_info is not None:\n        cost_per_credit = model_info.get(\"ocr_cost_per_credit\")\n    if credits is not None and cost_per_credit is not None:\n        return cost_per_credit * credits, 0.0\n\n    ocr_cost_per_page: float | None = None\n    if model_info is not None:\n        ocr_cost_per_page = model_info.get(\"ocr_cost_per_page\")\n\n    pages_processed: Final = response.usage_info.pages_processed","sourceCodeStart":1808,"sourceCodeEnd":1844,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/cost_calculator.py#L1808-L1844","documentation":"The object passed the isinstance check for an OCRResponse, but its usage_info field is None. The OCR cost helper requires usage_info to extract token counts, so it raises instead of computing a cost from nothing.","triggerScenarios":"Thrown at litellm/cost_calculator.py:1826 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The OCR provider response is missing usage_info; update litellm or check the provider integration.","As a workaround, compute cost manually from pages processed."],"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-23T08:17:48.524Z"}