BerriAI/litellm · error · BlackForestLabsError

No image URL in BFL result

Error message

No image URL in BFL result

What it means

After parsing the final BFL response, the handler extracts result.sample (single image) or iterates result as a list of URL strings/objects with a 'url' key. If neither shape yields any image, model_response.data stays empty and this BlackForestLabsError (HTTP 500) is raised. It means the job reported 'Ready' but the payload had no usable image URL.

Source

Thrown at litellm/llms/black_forest_labs/image_generation/transformation.py:294

        result: Final = response_data.get("result", {})

        if not model_response.data:
            model_response.data = []

        # Handle single image (sample) or multiple images
        if isinstance(result, dict) and "sample" in result:
            model_response.data.append(ImageObject(url=result["sample"]))
        elif isinstance(result, list):
            # Multiple images returned
            for img in result:
                if isinstance(img, str):
                    model_response.data.append(ImageObject(url=img))
                elif isinstance(img, dict) and "url" in img:
                    model_response.data.append(ImageObject(url=img["url"]))

        if not model_response.data:
            raise BlackForestLabsError(
                status_code=500,
                message="No image URL in BFL result",
            )

        model_response.created = int(time.time())
        return model_response

    def get_error_class(
        self, error_message: str, status_code: int, headers: dict | httpx.Headers
    ) -> BlackForestLabsError:
        """Return the appropriate error class for Black Forest Labs."""
        return BlackForestLabsError(
            status_code=status_code,
            message=error_message,
        )


def get_black_forest_labs_image_generation_config(

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Log the full response_data['result'] payload to see where the URL actually lives.
  2. Upgrade litellm — if BFL renamed the field, a newer integration likely handles it.
  3. Retry the generation once; empty results with Ready status are usually anomalous.
  4. If you control the request, avoid exotic output options that change the result shape, or open a litellm issue with the payload.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = litellm.images.generate(model="bfl/flux-pro-1.1", prompt=p)
except BlackForestLabsError as e:
    if "No image URL in BFL result" in str(e):
        logger.error("BFL reported Ready without a sample URL; payload logged for schema diff")
        return fallback_provider_generate(p)  # optional fallback
    raise

Prevention

When it happens

Trigger: BFL returns result as a dict without 'sample' (e.g. only 'progress' or an empty {}), or as a list whose items are neither strings nor {"url": ...} dicts — schema drift or an anomaly where 'Ready' was reported without a sample.

Common situations: BFL API schema changes moving the image URL to a new field (e.g. 'sample' renamed); requesting non-standard output formats whose result shape differs; rare server-side bugs returning Ready with an empty result.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/035a2ccc5d544389. Report an issue: GitHub.