{"record":{"id":"887d2827734f573c","repo":"BerriAI/litellm","slug":"ocr-response-pages-processed-is-none","errorCode":null,"errorMessage":"OCR response pages_processed is None","messagePattern":"OCR response pages_processed is None","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/cost_calculator.py","lineNumber":1859,"sourceCode":"    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\n    if pages_processed is None:\n        if cost_per_credit is not None or ocr_cost_per_page is None:\n            # Surface missing usage data instead of silently under-reporting\n            # cost. The previous behavior raised ValueError; we now return 0.0\n            # for credit-priced or unpriced models, so log a warning to keep\n            # the regression visible to operators.\n            verbose_logger.warning(\n                \"OCR cost: model=%s custom_llm_provider=%s response.usage_info.\"\n                \"pages_processed is None and credits=%s; returning 0.0 cost.\",\n                model,\n                custom_llm_provider,\n                credits,\n            )\n            return 0.0, 0.0\n        raise ValueError(\"OCR response pages_processed is None\")\n\n    if ocr_cost_per_page is None:\n        # No per-page pricing configured. Either the model is on credit-based\n        # pricing (and credits weren't returned, so the credit branch above did\n        # not match) or the model has no OCR pricing entry at all. Surface a\n        # warning so that missing pricing entries are visible rather than\n        # silently producing zero cost for billable usage.\n        verbose_logger.warning(\n            \"OCR cost: model=%s custom_llm_provider=%s reported \"\n            \"pages_processed=%s but no ocr_cost_per_page is configured; \"\n            \"returning 0.0 cost.\",\n            model,\n            custom_llm_provider,\n            pages_processed,\n        )\n        return 0.0, 0.0\n\n    total_ocr_processing_cost: Final[float] = ocr_cost_per_page * pages_processed","sourceCodeStart":1841,"sourceCodeEnd":1877,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/cost_calculator.py#L1841-L1877","documentation":"OCRResponse.usage_info exists but pages_processed is None; for per-page-priced models the code now logs a warning and returns 0.0 instead of raising, keeping the missing usage data visible to operators rather than silently under-reporting.","triggerScenarios":"Thrown at litellm/cost_calculator.py:1859 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The OCR provider response is missing pages_processed; update litellm or check the provider integration.","Verify the provider returns page counts in its OCR response."],"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"}