{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py#L70-L106","documentation":"For a TEXT_IMAGE generation request the remaining imageGenerationConfig dict is validated by constructing AmazonNovaCanvasImageGenerationConfig(**config); unknown keys raise TypeError ('unexpected keyword argument') which LiteLLM wraps in this ValueError with the raw dict and expected annotations. Annotated keys: cfgScale, seed, quality ('standard'|'premium'), width, height, numberOfImages.","triggerScenarios":"Extra keys left in the generation config after popping task params — e.g. passing response_format, style, or output_compression via litellm.image optional params so they merge into imageGenerationConfig; misspelled 'cfg_scale' instead of 'cfgScale'.","commonSituations":"Forwarding OpenAI image kwargs to Nova Canvas unfiltered; snake_case/camelCase confusion when translating AWS examples; params meant for the proxy (like user) leaking into the typed dict.","solutions":["Keep imageGenerationConfig to annotated camelCase keys: cfgScale, seed, quality ('standard'|'premium'), width, height, numberOfImages","Strip provider-specific kwargs before calling litellm.image for bedrock models","Set drop_params=True so unsupported extras are dropped instead of failing","Read the 'Got params' section of the message to find the offending key, then move it to the correct section or remove it"],"exampleFix":"# before\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"a red house\",\n    quality=\"hd\",            # not a Nova Canvas config key value/shape\n    response_format=\"b64_json\",\n)\n\n# after\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"a red house\",\n    quality=\"premium\",       # valid Nova Canvas enum\n    width=1024,\n    height=1024,\n)","handlingStrategy":"validation","validationCode":"from litellm.types.llms.bedrock import AmazonNovaCanvasImageGenerationConfig\n\ndef validate_generation_config(cfg: dict) -> None:\n    allowed = set(AmazonNovaCanvasImageGenerationConfig.__annotations__)\n    stray = set(cfg) - allowed\n    assert not stray, f\"unknown imageGenerationConfig keys: {stray}; allowed: {sorted(allowed)}\"\n    assert cfg.get(\"quality\", \"standard\") in (\"standard\", \"premium\")\n\nvalidate_generation_config(image_generation_config)","typeGuard":"def is_valid_nova_generation_config(cfg: dict) -> bool:\n    \"\"\"True when config keys match the TypedDict and quality is a valid enum.\"\"\"\n    from litellm.types.llms.bedrock import AmazonNovaCanvasImageGenerationConfig\n    allowed = set(AmazonNovaCanvasImageGenerationConfig.__annotations__)\n    return set(cfg) <= allowed and cfg.get(\"quality\", \"standard\") in (\"standard\", \"premium\")","tryCatchPattern":"try:\n    resp = litellm.image(...)\nexcept ValueError as e:\n    if \"Error transforming image generation config\" in str(e):\n        log.exception(\"bad imageGenerationConfig\")\n        raise UserInputError(\"Check nova canvas config keys/values\") from e\n    raise","preventionTips":["Normalize OpenAI image kwargs (quality='hd', response_format) before forwarding to bedrock","Keep a typed dataclass for generation settings and convert to camelCase at the boundary","Use drop_params=True when the same call must also serve OpenAI models"],"tags":["bedrock","nova-canvas","image-generation","imagegenerationconfig","typeddict","schema-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}