{"record":{"id":"1e7f5454b6516289","repo":"BerriAI/litellm","slug":"bfl-error-response-data-errors-1e7f54","errorCode":null,"errorMessage":"BFL error: {response_data['errors']}","messagePattern":"BFL error: (.+?)","errorType":"exception","errorClass":"BlackForestLabsError","httpStatus":null,"severity":"error","filePath":"litellm/llms/black_forest_labs/image_generation/handler.py","lineNumber":317,"sourceCode":"        # Validate initial response status code\n        if initial_response.status_code >= 400:\n            raise BlackForestLabsError(\n                status_code=initial_response.status_code,\n                message=f\"BFL initial request failed: {initial_response.text}\",\n            )\n\n        # Parse initial response to get polling URL\n        try:\n            response_data: Final = initial_response.json()\n        except Exception as e:\n            raise BlackForestLabsError(\n                status_code=initial_response.status_code,\n                message=f\"Error parsing initial response: {e}\",\n            )\n\n        # Check for immediate errors\n        if \"errors\" in response_data:\n            raise BlackForestLabsError(\n                status_code=initial_response.status_code,\n                message=f\"BFL error: {response_data['errors']}\",\n            )\n\n        polling_url: Final = response_data.get(\"polling_url\")\n        if not polling_url:\n            raise BlackForestLabsError(\n                status_code=500,\n                message=\"No polling_url in BFL response\",\n            )\n\n        # Reject polling URLs that don't belong to BFL-controlled infrastructure.\n        # BFL uses regional subdomains (e.g. gateway.bfl.ai) that differ from the\n        # submission host (api.bfl.ai), so we validate against the registered\n        # domain rather than doing a strict same-origin check. VERIA-51.\n        assert_bfl_polling_url(polling_url)\n\n        # Get just the auth header for polling","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/black_forest_labs/image_generation/handler.py#L299-L335","documentation":"If the parsed submission JSON contains an 'errors' key, BFL reported a problem at job creation and the handler raises immediately, forwarding the errors array verbatim. This is BFL's structured rejection channel — the payload arrived and parsed, but BFL refused to create the job.","triggerScenarios":"Submission responses like {\"errors\":[{\"message\":\"Invalid prompt\",...}]} — prompt moderation refusals, invalid parameter values, or API misuse recognized synchronously by BFL.","commonSituations":"Prompts tripping BFL content moderation; unsupported parameter combinations; model/endpoint misuse; policy-restricted content in prompt or referenced images.","solutions":["Read the forwarded errors array — it contains BFL's specific per-issue messages.","Adjust the prompt/params exactly as the message indicates (rephrase moderated content, fix invalid values).","If the error is quota/billing-related in the details, settle the BFL account limits before retrying.","Reproduce with a minimal prompt to isolate which input element triggered it."],"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    if \"BFL error:\" in str(e):\n        detail = str(e)\n        if \"moderat\" in detail.lower():\n            return safer_prompt_fallback(p)\n        raise","preventionTips":["Pre-screen prompts with your own moderation filter to avoid wasted submissions.","Treat 'BFL error:' payloads as authoritative — fix the named field, don't retry blindly.","Wrap batch jobs so one rejected prompt doesn't kill the batch."],"tags":["bfl","api-error","moderation","validation","image-generation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}