BerriAI/litellm · error · ValueError

Got an unexpected None response from the OCR API: {response}

Error message

Got an unexpected None response from the OCR API: {response}

What it means

Guard after the awaited provider OCR call: the coroutine resolved to None instead of a response object, meaning the provider handler returned nothing usable. The raw None is echoed since it carries no further detail.

Source

Thrown at litellm/ocr/main.py:431

            model=prepared.model,
            document=prepared.document,
            optional_params=prepared.optional_params,
            timeout=prepared.effective_timeout,
            logging_obj=prepared.litellm_logging_obj,
            api_key=prepared.api_key,
            api_base=prepared.api_base,
            custom_llm_provider=prepared.custom_llm_provider,
            aocr=True,
            headers=prepared.extra_headers,
            provider_config=prepared.provider_config,
            litellm_params=prepared.litellm_params,
        )

        if asyncio.iscoroutine(response):
            response = await response

        if response is None:
            raise ValueError(f"Got an unexpected None response from the OCR API: {response}")

        return response
    except Exception as e:
        raise litellm.exception_type(
            model=model,
            custom_llm_provider=custom_llm_provider,
            original_exception=e,
            completion_kwargs=completion_kwargs,
            extra_kwargs=kwargs,
        )


#################################################
# Public utilities — used by the SDK and the proxy
#################################################

_MIME_PATTERN: Final = re.compile(r"^[\w.+-]+/[\w.+-]+$")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check that the OCR API endpoint and credentials are valid; a None response means the request returned nothing.
  2. Verify the model/provider supports OCR and the file was uploaded correctly.

Example fix

Confirm the OCR model name and API key, then retry; log response.status_code to see why the API returned None.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/ocr/main.py:431 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/da78fcce53521073. Report an issue: GitHub.