{"record":{"id":"1e1e18315a19bf2a","repo":"BerriAI/litellm","slug":"no-image-url-in-bfl-result","errorCode":null,"errorMessage":"No image URL in BFL result","messagePattern":"No image URL in BFL result","errorType":"exception","errorClass":"BlackForestLabsError","httpStatus":500,"severity":"error","filePath":"litellm/llms/black_forest_labs/image_edit/transformation.py","lineNumber":305,"sourceCode":"    ) -> ImageResponse:\n        \"\"\"\n        Transform Black Forest Labs response to OpenAI-compatible ImageResponse.\n\n        This is called with the FINAL polled response (after handler does polling).\n        The response contains: {\"status\": \"Ready\", \"result\": {\"sample\": \"https://...\"}}\n        \"\"\"\n        try:\n            response_data: Final = raw_response.json()\n        except Exception as e:\n            raise BlackForestLabsError(\n                status_code=raw_response.status_code,\n                message=f\"Error parsing BFL response: {e}\",\n            )\n\n        # Get image URL from result\n        image_url: Final = response_data.get(\"result\", {}).get(\"sample\")\n        if not image_url:\n            raise BlackForestLabsError(\n                status_code=500,\n                message=\"No image URL in BFL result\",\n            )\n\n        # Build ImageResponse\n        return ImageResponse(\n            created=int(time.time()),\n            data=[ImageObject(url=image_url)],\n        )\n\n    def get_error_class(\n        self, error_message: str, status_code: int, headers: dict | httpx.Headers\n    ) -> BlackForestLabsError:\n        \"\"\"Return the appropriate error class for Black Forest Labs.\"\"\"\n        return BlackForestLabsError(\n            status_code=status_code,\n            message=error_message,\n        )","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/black_forest_labs/image_edit/transformation.py#L287-L323","documentation":"The final BFL poll response parsed as JSON successfully, but `response_data[\"result\"][\"sample\"]` was missing or falsy, so LiteLLM cannot build the OpenAI-compatible ImageResponse and raises BlackForestLabsError(500). The BFL contract expected here is `{\"status\": \"Ready\", \"result\": {\"sample\": \"https://...\"}}`; the poll loop only returns on status == \"Ready\", so this fires when a Ready payload lacks the sample URL (API contract change or unexpected payload shape).","triggerScenarios":"BFL ships a payload where the image moved to a different field than `result.sample`; `result` present but `sample` null/empty (e.g. generation produced no output); a modified/custom base_url pointing at a BFL-compatible service that returns Ready with a different schema.","commonSituations":"Running an older LiteLLM against a newer BFL API after a response-format change; pointing `api_base`/base_url at a self-hosted BFL-compatible gateway whose schema differs; occasionally an upstream data issue where the task completes but no sample is attached.","solutions":["Upgrade LiteLLM to the latest release - BFL schema handling is maintained there (`pip install -U litellm`).","Dump the final poll response body (enable verbose logging or a custom logger) to see which field actually carries the image URL.","If using a custom/compatible gateway, align its Ready payload to `{\"status\": \"Ready\", \"result\": {\"sample\": \"<url>\"}}` or point at the official endpoint.","Retry once - a Ready-with-no-sample can be a transient upstream data issue."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.black_forest_labs.common_utils import BlackForestLabsError\n\ntry:\n    resp = litellm.image_edit(model=\"flux-kontext-pro\", image=img, prompt=p)\nexcept BlackForestLabsError as e:\n    if \"No image URL in BFL result\" in str(e):\n        log.error(\"BFL schema drift? raw status=%s\", e.status_code)\n        raise RuntimeError(\"provider returned no image URL\") from e\n    raise","preventionTips":["Pin and regularly upgrade litellm when using BFL, since this error tracks schema drift.","Don't build logic that assumes data[0].url always exists - validate the response shape.","Monitor for this error to detect upstream API changes early."],"tags":["litellm","black-forest-labs","flux","image-edit","response-parsing","schema-change"],"backgroundTag":"missing-response-field","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}