{"record":{"id":"b12243596d32a17c","repo":"BerriAI/litellm","slug":"join-finish-reasons","errorCode":null,"errorMessage":"\"; \".join(finish_reasons)","messagePattern":"\"; \"\\.join\\(finish_reasons\\)","errorType":"http","errorClass":"BedrockError","httpStatus":400,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/amazon_stability3_transformation.py","lineNumber":98,"sourceCode":"\n        No OpenAI params are mapped for Stability 3, so directly return the optional_params\n        \"\"\"\n        return optional_params\n\n    @classmethod\n    def transform_response_dict_to_openai_response(\n        cls, model_response: ImageResponse, response_dict: dict\n    ) -> ImageResponse:\n        \"\"\"\n        Transform the response dict to the OpenAI response\n        \"\"\"\n\n        stability_3_response: Final = AmazonStability3TextToImageResponse(**response_dict)\n\n        finish_reasons = stability_3_response.get(\"finish_reasons\", [])\n        finish_reasons = [reason for reason in finish_reasons if reason]\n        if len(finish_reasons) > 0:\n            raise BedrockError(status_code=400, message=\"; \".join(finish_reasons))\n\n        openai_images: Final[list[Image]] = []\n        for _img in stability_3_response.get(\"images\", []):\n            openai_images.append(Image(b64_json=_img))\n\n        model_response.data = openai_images\n        return model_response\n\n    @classmethod\n    def cost_calculator(\n        cls,\n        model: str,\n        image_response: ImageResponse,\n        size: str | None = None,\n        optional_params: dict | None = None,\n    ) -> float:\n        get_model_info: Final = get_cached_model_info()\n        model_info: Final = get_model_info(","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_generation/amazon_stability3_transformation.py#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the exception message: it is Stability's own finish_reasons list joined with '; ' and names the actual cause","Rewrite the prompt to remove the flagged content and retry","If the reason looks transient, retry once with altered wording; otherwise switch to a different image model"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.bedrock.common_utils import BedrockError\n\ntry:\n    img = litellm.image(model=\"bedrock/stability.sd3-large-v1:0\", prompt=prompt)\nexcept BedrockError as e:\n    if e.status_code == 400:\n        # e.message is '; '.join(finish_reasons) from Stability\n        log.warning(\"stability generation stopped: %s\", e.message)\n    raise","preventionTips":["Wrap Bedrock image calls and treat status 400 with joined finish_reasons as a prompt problem, not a system fault","Log the message verbatim: it is Stability's own reason list","Keep a fallback image model configured for filter-triggered failures"],"tags":["bedrock","stability","image-generation","content-filter"],"backgroundTag":"content-filter-blocked","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}