BerriAI/litellm · error · BlackForestLabsError
No image URL in BFL result
Error message
No image URL in BFL result
What it means
The final edit response is expected to look like {"status":"Ready","result":{"sample":"https://..."}}. If JSON parsing succeeded but response_data['result']['sample'] is missing, empty, or null, this 500 BlackForestLabsError is raised. BFL signalled completion but delivered no image URL — usually a schema change or an upstream inconsistency.
Source
Thrown at litellm/llms/black_forest_labs/image_edit/transformation.py:305
) -> ImageResponse:
"""
Transform Black Forest Labs response to OpenAI-compatible ImageResponse.
This is called with the FINAL polled response (after handler does polling).
The response contains: {"status": "Ready", "result": {"sample": "https://..."}}
"""
try:
response_data: Final = raw_response.json()
except Exception as e:
raise BlackForestLabsError(
status_code=raw_response.status_code,
message=f"Error parsing BFL response: {e}",
)
# Get image URL from result
image_url: Final = response_data.get("result", {}).get("sample")
if not image_url:
raise BlackForestLabsError(
status_code=500,
message="No image URL in BFL result",
)
# Build ImageResponse
return ImageResponse(
created=int(time.time()),
data=[ImageObject(url=image_url)],
)
def get_error_class(
self, error_message: str, status_code: int, headers: dict | httpx.Headers
) -> BlackForestLabsError:
"""Return the appropriate error class for Black Forest Labs."""
return BlackForestLabsError(
status_code=status_code,
message=error_message,
)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Log the full response JSON on failure to see the actual schema; if the URL moved to another key, report/patch the transformation in LiteLLM and update.
- Ensure you are hitting the official api.bfl.ai base unless you control the alternative's schema.
- Retry the edit once — occasional null samples on BFL's side are transient.
- Upgrade LiteLLM in case a newer release already tracks the new BFL schema.
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try:
resp = await litellm.aimage_edit(model=M, image=img, prompt=p)
except Exception as e:
if "No image URL in BFL result" in str(e):
return await litellm.aimage_edit(model=M, image=img, prompt=p) # transient null sample
raise Prevention
- Retry once on missing-URL errors; they are frequently transient.
- Keep LiteLLM current to pick up BFL schema-tracking fixes.
- Alert when this error rate climbs — it signals upstream schema drift.
When it happens
Trigger: The polling endpoint returns JSON with status 'Ready' but no result.sample key (renamed field, null sample, or a different response shape from a new BFL API version or custom api_base).
Common situations: BFL ships an API revision that renames the sample field; pointing api_base at a BFL-compatible gateway that returns a slightly different schema; race where the job flips to Ready before the artifact is attached.
Related errors
- Error parsing BFL response: {e}
- No polling_url in BFL response
- Error apply_db_fixes: {str(e)}
- Error in response object format, got None
- BFL_API_KEY is not set. Please set it via environment variab
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/1e1e18315a19bf2a.
Report an issue: GitHub.