{"record":{"id":"591d80228c3af319","repo":"BerriAI/litellm","slug":"request-failed-e-591d80","errorCode":null,"errorMessage":"Request failed: {e}","messagePattern":"Request failed: (.+?)","errorType":"exception","errorClass":"BlackForestLabsError","httpStatus":500,"severity":"error","filePath":"litellm/llms/black_forest_labs/image_generation/handler.py","lineNumber":157,"sourceCode":"            input=prompt,\n            api_key=\"\",\n            additional_args={\n                \"complete_input_dict\": data,\n                \"api_base\": complete_url,\n                \"headers\": headers,\n            },\n        )\n\n        # Make initial request\n        try:\n            response: Final = sync_client.post(\n                url=complete_url,\n                headers=headers,\n                json=data,\n                timeout=timeout,\n            )\n        except Exception as e:\n            raise BlackForestLabsError(\n                status_code=500,\n                message=f\"Request failed: {e}\",\n            )\n\n        # Poll for result\n        final_response: Final = self._poll_for_result_sync(\n            initial_response=response,\n            headers=headers,\n            sync_client=sync_client,\n        )\n\n        # Transform response\n        return self.config.transform_image_generation_response(\n            model=model,\n            raw_response=final_response,\n            model_response=model_response,\n            logging_obj=logging_obj,\n            request_data=data,","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/black_forest_labs/image_generation/handler.py#L139-L175","documentation":"The synchronous BFL image-generation handler wraps the initial `POST` (to the generation endpoint) in try/except; any exception the HTTP client raises before a response exists - DNS failure, connection refused, TLS error, timeout - is re-raised as `BlackForestLabsError(status_code=500, message=\"Request failed: {e}\")`. The 500 is synthetic: it reflects a client-side transport failure, not an HTTP status from BFL.","triggerScenarios":"No internet / blocked egress when litellm POSTs to `https://api.bfl.ai/v1/...`; wrong or unreachable custom base_url; connect/read timeout shorter than BFL's slow acknowledgement; corporate proxy not set (HTTP_PROXY/HTTPS_PROXY env vars missing); TLS interception with an untrusted CA.","commonSituations":"Air-gapped or proxy-locked CI environments; typo'd `api_base`/`base_url` config; sandboxed containers without CA certificates; flaky mobile/hotel networks. The underlying httpx error text is embedded in the message, so read the tail of the message to identify which transport failure it was.","solutions":["Read the embedded exception text after 'Request failed:' - 'connect timeout', 'Name or service not known', 'certificate verify failed' each point to different fixes.","Verify egress: `curl -I https://api.bfl.ai` from the same host/container.","Set proxy env vars (HTTPS_PROXY) if a corporate proxy is required, or pass litellm-level proxy/timeout params to increase the timeout.","If the base_url was customized, check it resolves and serves the BFL endpoints."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import socket, ssl, urllib.request\n\ndef bfl_reachable(host: str = \"api.bfl.ai\", timeout: float = 5.0) -> bool:\n    try:\n        urllib.request.urlopen(f\"https://{host}/\", timeout=timeout)\n    except urllib.error.HTTPError:\n        return True   # got an HTTP response -> reachable\n    except (URLError, socket.timeout, ssl.SSLError, ConnectionError):\n        return False\n\nassert bfl_reachable(), \"no egress to api.bfl.ai - fix proxy/DNS before calling litellm\"","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 e.status_code == 500 and str(e).startswith(\"Request failed:\"):\n        # synthetic 500 = client-side transport failure; body names the cause\n        handle_transport_error(str(e))   # proxy/DNS/TLS/timeout remediation\n    else:\n        raise","preventionTips":["Run connectivity checks to api.bfl.ai at service startup, not at request time.","Configure HTTP(S)_PROXY env vars in proxy-locked environments.","Distinguish synthetic 500 ('Request failed:') from real upstream 500s before alerting."],"tags":["litellm","black-forest-labs","flux","network","connection-error","sync","transport"],"backgroundTag":"network-request-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}