BerriAI/litellm · error · ValueError
OCR response pages_processed is None
Error message
OCR response pages_processed is None
What it means
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.
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/cost_calculator.py:1859 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/887d2827734f573c.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/cost_calculator.py:1859
if model_info is not None:
ocr_cost_per_page = model_info.get("ocr_cost_per_page")
pages_processed: Final = response.usage_info.pages_processed
if pages_processed is None:
if cost_per_credit is not None or ocr_cost_per_page is None:
# Surface missing usage data instead of silently under-reporting
# cost. The previous behavior raised ValueError; we now return 0.0
# for credit-priced or unpriced models, so log a warning to keep
# the regression visible to operators.
verbose_logger.warning(
"OCR cost: model=%s custom_llm_provider=%s response.usage_info."
"pages_processed is None and credits=%s; returning 0.0 cost.",
model,
custom_llm_provider,
credits,
)
return 0.0, 0.0
raise ValueError("OCR response pages_processed is None")
if ocr_cost_per_page is None:
# No per-page pricing configured. Either the model is on credit-based
# pricing (and credits weren't returned, so the credit branch above did
# not match) or the model has no OCR pricing entry at all. Surface a
# warning so that missing pricing entries are visible rather than
# silently producing zero cost for billable usage.
verbose_logger.warning(
"OCR cost: model=%s custom_llm_provider=%s reported "
"pages_processed=%s but no ocr_cost_per_page is configured; "
"returning 0.0 cost.",
model,
custom_llm_provider,
pages_processed,
)
return 0.0, 0.0
total_ocr_processing_cost: Final[float] = ocr_cost_per_page * pages_processedView on GitHub (pinned to 77b7c6c40c)