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.

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 markdown

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Enable verbose logging and inspect the raw response text to see what the model actually returned
  2. Retry once - empty content is often transient
  3. 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

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


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/84f1dc7f904556e2. Report an issue: GitHub.