{"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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/black_forest_labs/image_edit/transformation.py#L287-L323","documentation":"The final edit response is expected to look like {\"status\":\"Ready\",\"result\":{\"sample\":\"https://...\"}}. If JSON parsing succeeded but response_data['result']['sample'] is missing, empty, or null, this 500 BlackForestLabsError is raised. BFL signalled completion but delivered no image URL — usually a schema change or an upstream inconsistency.","triggerScenarios":"The polling endpoint returns JSON with status 'Ready' but no result.sample key (renamed field, null sample, or a different response shape from a new BFL API version or custom api_base).","commonSituations":"BFL ships an API revision that renames the sample field; pointing api_base at a BFL-compatible gateway that returns a slightly different schema; race where the job flips to Ready before the artifact is attached.","solutions":["Log the full response JSON on failure to see the actual schema; if the URL moved to another key, report/patch the transformation in LiteLLM and update.","Ensure you are hitting the official api.bfl.ai base unless you control the alternative's schema.","Retry the edit once — occasional null samples on BFL's side are transient.","Upgrade LiteLLM in case a newer release already tracks the new BFL schema."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    resp = await litellm.aimage_edit(model=M, image=img, prompt=p)\nexcept Exception as e:\n    if \"No image URL in BFL result\" in str(e):\n        return await litellm.aimage_edit(model=M, image=img, prompt=p)  # transient null sample\n    raise","preventionTips":["Retry once on missing-URL errors; they are frequently transient.","Keep LiteLLM current to pick up BFL schema-tracking fixes.","Alert when this error rate climbs — it signals upstream schema drift."],"tags":["bfl","response-parsing","schema","image-edit"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}