{"record":{"id":"836792ce720780de","repo":"BerriAI/litellm","slug":"error-transforming-text-to-image-params-e-got","errorCode":null,"errorMessage":"Error transforming text to image params: {e}. Got params: {text_to_image_params}, Expected params: {AmazonNovaCanvasTextToImageParams.__annotations__}","messagePattern":"Error transforming text to image params: (.+?)\\. Got params: (.+?), Expected params: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py","lineNumber":81,"sourceCode":"    def transform_request_body(cls, text: str, optional_params: dict) -> AmazonNovaCanvasRequestBase:\n        \"\"\"\n        Transform the request body for Amazon Nova Canvas model\n        \"\"\"\n        task_type: Final = optional_params.pop(\"taskType\", \"TEXT_IMAGE\")\n        image_generation_config = optional_params.pop(\"imageGenerationConfig\", {})\n\n        # Extract model_id parameter to prevent \"extraneous key\" error from Bedrock API\n        # Following the same pattern as chat completions and embeddings\n        unencoded_model_id: Final = optional_params.pop(\"model_id\", None)  # noqa: F841\n\n        image_generation_config = {**image_generation_config, **optional_params}\n        if task_type == \"TEXT_IMAGE\":\n            text_to_image_params: dict[str, Any] = image_generation_config.pop(\"textToImageParams\", {})\n            text_to_image_params = {\"text\": text, **text_to_image_params}\n            try:\n                text_to_image_params_typed: Final = AmazonNovaCanvasTextToImageParams(**text_to_image_params)\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming text to image params: {e}. Got params: {text_to_image_params}, Expected params: {AmazonNovaCanvasTextToImageParams.__annotations__}\"\n                )\n\n            try:\n                image_generation_config_typed = AmazonNovaCanvasImageGenerationConfig(**image_generation_config)\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__}\"\n                )\n\n            return AmazonNovaCanvasTextToImageRequest(\n                textToImageParams=text_to_image_params_typed,\n                taskType=task_type,\n                imageGenerationConfig=image_generation_config_typed,\n            )\n        if task_type == \"COLOR_GUIDED_GENERATION\":\n            color_guided_generation_params: dict[str, Any] = image_generation_config.pop(\n                \"colorGuidedGenerationParams\", {}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py#L63-L99","documentation":"For Nova Canvas TEXT_IMAGE generation, LiteLLM merges config and optional params into textToImageParams and validates them against the AmazonNovaCanvasTextToImageParams TypedDict/dataclass. Any constructor exception (missing required 'text', unknown key, wrong type) is re-raised as ValueError including the offending params and the expected annotations.","triggerScenarios":"litellm.image(model='bedrock/nova-canvas...', task='TEXT_IMAGE') with an invalid key inside textToImageParams (e.g. passing images/colors there), a non-string text, or text missing after an empty prompt; keys with wrong casing ('Text' instead of 'text').","commonSituations":"Hand-building textToImageParams dicts from AWS docs examples with wrong casing; forwarding arbitrary user kwargs into optional_params; prompt passed as None/empty so 'text' key ends up invalid.","solutions":["Read the error tail: Expected params lists the accepted keys — remove/rename the ones flagged in Got params.","Ensure 'text' is a non-empty string and nested textToImageParams contains only supported keys (text, negativeText, plus allowed image refs per the TypedDict).","Pass top-level OpenAI params (n, size, etc.) normally; let litellm map them into imageGenerationConfig rather than nesting them yourself."],"exampleFix":"# before\nlitellm.image(model=\"bedrock/amazon.nova-canvas-v1:0\",\n             task=\"TEXT_IMAGE\", prompt=\"a sunset\",\n             textToImageParams={\"Text\": \"a sunset\"})  # wrong casing -> ValueError\n# after\nlitellm.image(model=\"bedrock/amazon.nova-canvas-v1:0\",\n             task=\"TEXT_IMAGE\", prompt=\"a sunset\")\n# params flow automatically; use exact snake/camel keys litellm documents","handlingStrategy":"validation","validationCode":"ALLOWED_T2I = {\"text\", \"negativeText\", \"images\"}  # per AmazonNovaCanvasTextToImageParams\n\ndef valid_t2i_params(p: dict) -> bool:\n    return set(p) <= ALLOWED_T2I and isinstance(p.get(\"text\"), str) and p[\"text\"] != \"\"","typeGuard":"def is_valid_text_to_image_params(p: object) -> bool:\n    return (\n        isinstance(p, dict)\n        and isinstance(p.get(\"text\"), str)\n        and p[\"text\"].strip() != \"\"\n    )","tryCatchPattern":null,"preventionTips":["Use exact keys from the TypedDict shown in the error's Expected params.","Let litellm map standard OpenAI params; don't hand-assemble nested task dicts.","Unit-test your request builder against the expected-key set."],"tags":["bedrock","nova-canvas","image-generation","validation","params"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}