BerriAI/litellm · error · BlackForestLabsError
Image generation failed: {status}
Error message
Image generation failed: {status} What it means
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.
Source
Thrown at litellm/llms/black_forest_labs/image_generation/handler.py:366
raise BlackForestLabsError(
status_code=response.status_code,
message=f"Polling failed: {response.text}",
)
data = response.json()
status = data.get("status")
verbose_logger.debug("BFL poll status: %s", status)
if status == "Ready":
return response
elif status in [
"Error",
"Failed",
"Content Moderated",
"Request Moderated",
]:
raise BlackForestLabsError(
status_code=400,
message=f"Image generation failed: {status}",
)
time.sleep(interval)
raise BlackForestLabsError(
status_code=408,
message=f"Polling timed out after {max_wait} seconds",
)
async def _poll_for_result_async(
self,
initial_response: httpx.Response,
headers: dict,
async_client: AsyncHTTPHandler,
max_wait: float = DEFAULT_MAX_POLLING_TIME,
interval: float = DEFAULT_POLLING_INTERVAL,View on GitHub (pinned to 6c2dcb801b)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try:
img = litellm.image_generation(model=M, prompt=p)
except Exception as e:
msg = str(e)
if "Image generation failed: Error" in msg or "Image generation failed: Failed" in msg:
return litellm.image_generation(model=M, prompt=p) # transient processing failure
if "Moderated" in msg:
return litellm.image_generation(model=M, prompt=soften(p))
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- BFL error: {response_data['errors']}
- No polling_url in BFL response
- Polling failed: {response.text}
- Polling timed out after {max_wait} seconds
- Request failed: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/438b60f73ea8447f.
Report an issue: GitHub.