BerriAI/litellm · error · BedrockError
"; ".join(finish_reasons)
Error message
"; ".join(finish_reasons)
What it means
After a Stability 3 image request on Bedrock returns 200, the response is parsed into AmazonStability3TextToImageResponse. If finish_reasons[] contains any non-empty entries, Bedrock reported generation failures and litellm raises BedrockError(status_code=400) with the reasons joined by '; '. This is a server-side content- or input-quality failure delivered in a successful HTTP response.
Source
Thrown at litellm/llms/bedrock/image_generation/amazon_stability3_transformation.py:98
No OpenAI params are mapped for Stability 3, so directly return the optional_params
"""
return optional_params
@classmethod
def transform_response_dict_to_openai_response(
cls, model_response: ImageResponse, response_dict: dict
) -> ImageResponse:
"""
Transform the response dict to the OpenAI response
"""
stability_3_response: Final = AmazonStability3TextToImageResponse(**response_dict)
finish_reasons = stability_3_response.get("finish_reasons", [])
finish_reasons = [reason for reason in finish_reasons if reason]
if len(finish_reasons) > 0:
raise BedrockError(status_code=400, message="; ".join(finish_reasons))
openai_images: Final[list[Image]] = []
for _img in stability_3_response.get("images", []):
openai_images.append(Image(b64_json=_img))
model_response.data = openai_images
return model_response
@classmethod
def cost_calculator(
cls,
model: str,
image_response: ImageResponse,
size: str | None = None,
optional_params: dict | None = None,
) -> float:
get_model_info: Final = get_cached_model_info()
model_info: Final = get_model_info(View on GitHub (pinned to 6c2dcb801b)
Solutions
- Read the joined finish_reasons in the BedrockError message — it states the exact cause (usually content filter or invalid input).
- Rephrase the prompt to remove flagged terms; try a simpler prompt to confirm the filter is the cause.
- Check/adjust Stability-specific params (aspect_ratio, seed, negative_prompt) against the Stability 3 API spec.
- If the filter is a false positive, switch to a different image model (e.g. Nova Canvas / Titan Image).
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.exceptions import BedrockError
try:
resp = litellm.image_generation(model="bedrock/stability.stable-image-core-1:0", prompt=p)
except BedrockError as e:
if e.status_code == 400 and "finish_reason" not in str(e):
raise # unrelated 400
log.warning("Stability rejected prompt: %s", e.message)
return fallback_prompt_or_model(p) Prevention
- Wrap Stability image calls in BedrockError handling — content-filter failures arrive as 400 with finish_reason text despite HTTP 200 semantics upstream.
- Keep a moderated-prompt precheck or a sanitizing step for user-supplied prompts.
- Have a second model configured as fallback for filtered prompts.
When it happens
Trigger: Calling litellm.image_generation() with model='bedrock/stability.stable-image-core-1:0' (or ultra/core variants) where Stability rejects the prompt (content filter) or the request has invalid parameters; finish_reasons like 'Invalid prompt: Input text prompt contains unsafe content' come back non-empty.
Common situations: Prompts with NSFW/violent content triggering Stability's filter, negative-prompt misuse, aspect_ratio/seed-strength values Stability rejects, or intermittent safety-filter false positives.
Related errors
- Model needs to be set for bedrock
- completion_response must be of type ImageResponse for bedroc
- Parameter {k} is not supported for model {model}. Supported
- Error transforming text to image params: {e}. Got params: {t
- Error transforming image generation config: {e}. Got params:
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/b12243596d32a17c.
Report an issue: GitHub.