{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/black_forest_labs/image_generation/handler.py#L348-L384","documentation":"Sync BFL polling: the task reached a terminal non-success status - one of `Error`, `Failed`, `Content Moderated`, `Request Moderated` - and LiteLLM maps it to BlackForestLabsError(status_code=400) with the status string in the message. The BFL job itself finished badly; retrying the identical request will often fail the same way, except for transient `Error`/`Failed`.","triggerScenarios":"Prompt or input image violating BFL content policy (`Content Moderated` / `Request Moderated` - text or the uploaded image tripped filters); upstream BFL worker failure (`Error`/`Failed`) from malformed media, unsupported image characteristics, or infra crashes.","commonSituations":"User-generated prompts in an app hitting safety filters; NSFW-adjacent or violent wording even in legitimate contexts (medical, gaming); corrupt or unusual input images (CMYK JPEG, exotic formats) causing Failed; occasional platform-wide Error bursts.","solutions":["If status is 'Content Moderated'/'Request Moderated': rephrase the prompt or swap the input image - this is policy, not a bug; consider surfacing a user-facing moderation message.","If status is 'Error'/'Failed': retry once or twice (transient worker failures happen), then inspect the input image (re-encode to standard RGB PNG/JPEG) if it persists.","Route moderated cases to a different model or provider if the use case is legitimately benign.","Track which prompts trigger moderation so you can pre-filter instead of burning BFL credits."],"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_generation(model=\"flux-pro-1.1\", prompt=p)\nexcept BlackForestLabsError as e:\n    msg = str(e)\n    if \"Moderated\" in msg:\n        return moderation_feedback_to_user()      # do not blind-retry\n    if \"Image generation failed\" in msg:\n        return retry_with_backoff(...)            # Error/Failed may be transient\n    raise","preventionTips":["Handle Moderated statuses as user feedback, not retries - the same input fails again.","Pre-validate/rephrase user prompts before spending API credits.","Re-encode exotic input images to standard RGB PNG before upload."],"tags":["litellm","black-forest-labs","flux","content-moderation","job-failed","sync"],"backgroundTag":"image-generation-job-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}