{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/black_forest_labs/image_generation/handler.py#L299-L335","documentation":"Sync BFL flow: the initial response parsed as JSON and contains an `errors` key, which the BFL API uses to report request-level problems (validation, auth, credits) even alongside a 2xx-ish status. LiteLLM surfaces it as BlackForestLabsError with the initial status code and the raw `errors` value in the message, so the actionable detail is inside the message text.","triggerScenarios":"BFL accepting the HTTP request but rejecting it semantically: invalid parameter values (e.g. unsupported aspect_ratio or seed type), prompt failing server-side validation, insufficient credits flagged at submission, or key lacking permission for the requested model.","commonSituations":"First runs against a new BFL model before reading its parameter schema; draining a prepaid credit balance mid-batch; account-level restrictions on certain FLUX models; API version drift where a formerly-valid field value is now rejected.","solutions":["Read the `errors` payload embedded in the exception message - it names the offending field or reason.","Correct the named request parameter (type/range) per BFL's API docs for the exact model.","Check account credits/permissions in the BFL dashboard if the error mentions quota or access.","Upgrade LiteLLM so any request-shape fixes for newer BFL validations are applied."],"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    if str(e).startswith(\"BFL error:\"):\n        errors = json.loads(str(e)[len(\"BFL error:\"):].strip())\n        surface_field_errors(errors)   # show user which param was wrong\n    else:\n        raise","preventionTips":["Validate enum-ish params (aspect_ratio, output_format) client-side against the model's docs.","Check credits before large batches to avoid mid-batch submission errors.","Parse the embedded errors payload - it identifies the offending field precisely."],"tags":["litellm","black-forest-labs","flux","api-error","validation","credits"],"backgroundTag":"api-error-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}