BerriAI/litellm · error · BedrockError

"; ".join(finish_reasons)

Error message

"; ".join(finish_reasons)

What it means

AmazonStability3Config.transform_response_dict_to_openai_response raises BedrockError(400) when the Stability 3 response contains any non-empty finish_reasons entries. In the Stability API finish_reasons explains why generation stopped early (typically content policy), so LiteLLM joins the reasons with '; ' and surfaces them instead of returning images. Any images in the response are discarded when this fires.

Solutions

  1. Read the exception message: it is Stability's own finish_reasons list joined with '; ' and names the actual cause
  2. Rewrite the prompt to remove the flagged content and retry
  3. If the reason looks transient, retry once with altered wording; otherwise switch to a different image model
Defensive patterns

Strategy: try-catch

Try / catch

from litellm.llms.bedrock.common_utils import BedrockError

try:
    img = litellm.image(model="bedrock/stability.sd3-large-v1:0", prompt=prompt)
except BedrockError as e:
    if e.status_code == 400:
        # e.message is '; '.join(finish_reasons) from Stability
        log.warning("stability generation stopped: %s", e.message)
    raise

Prevention

When it happens

Trigger: Calling litellm.image() on a Bedrock Stability 3 model (e.g. 'stability.sd3-large-v1:0') with a prompt that Stability's safety filters reject or that otherwise makes the model stop before producing an image.

Common situations: Prompts with flagged or borderline content that AWS-side filters block; changes in Stability filter behavior between versions; empty or degenerate prompts that produce a filter reason.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/b12243596d32a17c. Report an issue: GitHub.

Appendix: 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 77b7c6c40c)