{"record":{"id":"b3fe9acc200638ff","repo":"BerriAI/litellm","slug":"error-transforming-image-generation-config-e-g","errorCode":null,"errorMessage":"Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__}","messagePattern":"Error transforming image generation config: (.+?)\\. Got params: (.+?), Expected params: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py","lineNumber":88,"sourceCode":"        # 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\", {}\n            )\n            color_guided_generation_params = {\n                \"text\": text,\n                **color_guided_generation_params,\n            }\n            try:\n                color_guided_generation_params_typed: Final = AmazonNovaCanvasColorGuidedGenerationParams(","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py#L70-L106","documentation":"Independently of the task params, LiteLLM validates the merged imageGenerationConfig against AmazonNovaCanvasImageGenerationConfig (fields like numberOfImages, quality, cfgScale, seed, width, height). Constructor failures (unknown keys, out-of-range or wrongly-typed values) raise this ValueError showing both the received config and the expected annotations.","triggerScenarios":"Passing keys Bedrock doesn't accept in imageGenerationConfig (e.g. 'style', 'response_format'), wrong types (seed as string, numberOfImages as float), or Bedrock-invalid values (width not in {512,768,1024...} depending on model, quality misspelled) for nova-canvas generations of any task type (TEXT_IMAGE, COLOR_GUIDED_GENERATION, etc.).","commonSituations":"Forwarding OpenAI gpt-image-1 params (background, output_compression, moderation) that land in the config dict; passing size strings not convertible to width/height ints; user-supplied option dicts passed verbatim.","solutions":["Match Got params against Expected params in the message; delete keys not in the expected set.","Use native config keys with valid ranges: numberOfImages 1-4ish per model, width/height among supported pixel sizes, quality 'standard'|'premium', seed int, cfgScale float.","Set drop_params=True to have unsupported extras dropped before validation where litellm supports it on this path."],"exampleFix":"# before\nlitellm.image(model=\"bedrock/amazon.nova-canvas-v1:0\",\n             prompt=\"a cat\", numberOfImages=\"2\")  # str type -> ValueError\n# after\nlitellm.image(model=\"bedrock/amazon.nova-canvas-v1:0\",\n             prompt=\"a cat\", n=2)  # OpenAI param, mapped to numberOfImages int","handlingStrategy":"validation","validationCode":"ALLOWED_CFG = {\"numberOfImages\", \"quality\", \"cfgScale\", \"seed\", \"width\", \"height\"}\n\ndef valid_generation_config(c: dict) -> bool:\n    return (\n        set(c) <= ALLOWED_CFG\n        and all(not isinstance(v, str) for k, v in c.items() if k in {\"numberOfImages\", \"seed\", \"width\", \"height\"})\n    )","typeGuard":"def is_valid_image_generation_config(c: object) -> bool:\n    if not isinstance(c, dict):\n        return False\n    ints = {\"numberOfImages\", \"seed\", \"width\", \"height\"}\n    return all(\n        (k not in ints or (isinstance(v, int) and not isinstance(v, bool)))\n        for k, v in c.items()\n    )","tryCatchPattern":null,"preventionTips":["Send OpenAI-style params (n, size) and let litellm translate to numberOfImages/width/height.","Restrict quality to the values Nova documents; keep width/height in supported sizes.","Drop provider-specific extras before forwarding user input."],"tags":["bedrock","nova-canvas","image-generation","validation","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}