BerriAI/litellm · error · ValueError

Missing REDUCTO_API_KEY - set it in the environment or pass

Error message

Missing REDUCTO_API_KEY - set it in the environment or pass api_key to litellm.ocr()/litellm.aocr()

What it means

Credential guard in the Reducto OCR config's validate_environment: neither the api_key argument nor the REDUCTO_API_KEY secret resolved, so the Bearer header cannot be built and the OCR request is rejected upfront.

Source

Thrown at litellm/llms/reducto/ocr/transformation.py:48

        for param, value in non_default_params.items():
            if param in supported_params:
                mapped_params[param] = value
        return mapped_params

    def validate_environment(
        self,
        headers: dict,
        model: str,
        api_key: str | None = None,
        api_base: str | None = None,
        litellm_params: dict | None = None,
        **kwargs,
    ) -> dict:
        from litellm.secret_managers.main import get_secret_str

        resolved_key: Final = api_key or get_secret_str("REDUCTO_API_KEY")
        if resolved_key is None:
            raise ValueError(
                "Missing REDUCTO_API_KEY - set it in the environment or pass api_key to litellm.ocr()/litellm.aocr()"
            )

        return {
            "Authorization": f"Bearer {resolved_key}",
            "Content-Type": "application/json",
            **headers,
        }

    def get_complete_url(
        self,
        api_base: str | None,
        model: str,
        optional_params: dict,
        litellm_params: dict | None = None,
        **kwargs,
    ) -> str:
        return "{}/parse".format((api_base or REDUCTO_API_BASE).rstrip("/"))

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set the REDUCTO_API_KEY environment variable.
  2. Or pass api_key to litellm.ocr()/litellm.aocr().

Example fix

litellm.aocr(model="reducto/...", api_key="<key>", ...)
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when calling litellm.ocr()/aocr() with the Reducto provider without REDUCTO_API_KEY set or api_key passed.

Common situations: See trigger scenarios.


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