{"record":{"id":"438b60f73ea8447f","repo":"BerriAI/litellm","slug":"image-generation-failed-status-438b60","errorCode":null,"errorMessage":"Image generation failed: {status}","messagePattern":"Image generation failed: (.+?)","errorType":"exception","errorClass":"BlackForestLabsError","httpStatus":400,"severity":"error","filePath":"litellm/llms/black_forest_labs/image_generation/handler.py","lineNumber":366,"sourceCode":"                raise BlackForestLabsError(\n                    status_code=response.status_code,\n                    message=f\"Polling failed: {response.text}\",\n                )\n\n            data = response.json()\n            status = data.get(\"status\")\n\n            verbose_logger.debug(\"BFL poll status: %s\", status)\n\n            if status == \"Ready\":\n                return response\n            elif status in [\n                \"Error\",\n                \"Failed\",\n                \"Content Moderated\",\n                \"Request Moderated\",\n            ]:\n                raise BlackForestLabsError(\n                    status_code=400,\n                    message=f\"Image generation failed: {status}\",\n                )\n\n            time.sleep(interval)\n\n        raise BlackForestLabsError(\n            status_code=408,\n            message=f\"Polling timed out after {max_wait} seconds\",\n        )\n\n    async def _poll_for_result_async(\n        self,\n        initial_response: httpx.Response,\n        headers: dict,\n        async_client: AsyncHTTPHandler,\n        max_wait: float = DEFAULT_MAX_POLLING_TIME,\n        interval: float = DEFAULT_POLLING_INTERVAL,","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/black_forest_labs/image_generation/handler.py#L348-L384","documentation":"Each poll reads a status field; besides 'Ready' (success) the loop treats 'Error', 'Failed', 'Content Moderated', and 'Request Moderated' as terminal failures and raises a 400 BlackForestLabsError embedding that status. This is BFL itself reporting the job died — not a LiteLLM-side or network problem.","triggerScenarios":"The polled job transitions to a terminal failure status: 'Error'/'Failed' from internal BFL processing, or 'Content Moderated'/'Request Moderated' when the prompt or (for edits) the image trips BFL's moderation.","commonSituations":"Prompts with policy-sensitive content; NSFW or violent imagery in image-edit inputs; occasionally BFL-side internal failures on hard generations; rare transient 'Error' statuses on overloaded nodes.","solutions":["Check which status string is embedded: the two 'Moderated' ones are content-policy — rephrase the prompt or change the input image.","'Error'/'Failed': retry once; a subset are transient processing failures.","Sanitize/soften content that moderation flags, or route to a provider without equivalent policy for that content.","If failures cluster, check BFL status pages for incident-driven 'Error' rates."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    img = litellm.image_generation(model=M, prompt=p)\nexcept Exception as e:\n    msg = str(e)\n    if \"Image generation failed: Error\" in msg or \"Image generation failed: Failed\" in msg:\n        return litellm.image_generation(model=M, prompt=p)  # transient processing failure\n    if \"Moderated\" in msg:\n        return litellm.image_generation(model=M, prompt=soften(p))\n    raise","preventionTips":["Pre-filter prompts and edit-source images for policy-sensitive content.","Retry once on Error/Failed but never on Moderated statuses.","Track failure-status ratios per prompt template to find systematically rejected content."],"tags":["bfl","moderation","job-failed","polling","image-generation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}