BerriAI/litellm · error · ValueError
No content in DeepSeek OCR response
Error message
No content in DeepSeek OCR response
What it means
ValueError raised when the DeepSeek OCR response has choices but choices[0].message.content is empty (missing key, empty string, or empty dict). Without content the transformer cannot build OCR pages, so it fails immediately after the 'no choices' check.
Solutions
- Enable verbose logging and inspect the raw response text to see what the model actually returned
- Retry once - empty content is often transient
- If systematic, the document may be unsupported or too large: try another format, fewer pages, or re-encode the file
Defensive patterns
Strategy: retry
Try / catch
for attempt in range(2):
try:
resp = litellm.ocr(model=model, document=doc)
break
except ValueError as e:
if 'No content' in str(e) and attempt == 0:
continue # empty content is frequently transient
raise Prevention
- Pre-check that documents are readable and non-empty before OCR
- Cap document size to the model's limits
- Retry empty-content responses once before surfacing errors to users
When it happens
Trigger: The model returns an empty message (safety filter, internal truncation, transient model failure); the message contains only other fields; upstream returns content: ''.
Common situations: Documents that trip safety filtering; oversized or corrupt inputs producing empty output; transient service hiccups.
Related errors
- No choices in DeepSeek OCR response
- Expected document dict, got
- Expected document dict, got
- Missing vertex_project - Set VERTEXAI_PROJECT environment…
- Missing vertex_project - Set VERTEXAI_PROJECT environment…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/84f1dc7f904556e2.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/vertex_ai/ocr/deepseek_transformation.py:276
Returns:
OCRResponse in standard format
"""
verbose_logger.debug("Vertex AI DeepSeek OCR transform_ocr_response called")
verbose_logger.debug("Raw response: %s", raw_response.text)
try:
response_json: Final = raw_response.json()
# Extract OCR content from provider response
choices: Final = response_json.get("choices", [])
if not choices:
raise ValueError("No choices in DeepSeek OCR response")
message: Final = choices[0].get("message", {})
content: Final = message.get("content", "")
if not content:
raise ValueError("No content in DeepSeek OCR response")
# Try to parse content as JSON (OCR result might be JSON string)
ocr_data = None
try:
# If content is a JSON string, parse it
if isinstance(content, str) and content.strip().startswith("{"):
ocr_data = json.loads(content)
elif isinstance(content, dict):
ocr_data = content
else:
# If content is markdown text, create a single page with the markdown
ocr_data = {
"pages": [{"index": 0, "markdown": content}],
"model": model,
"usage_info": response_json.get("usage", {}),
}
except json.JSONDecodeError:
# If JSON parsing fails, treat content as markdownView on GitHub (pinned to 77b7c6c40c)