{"record":{"id":"54a4de07352a1af2","repo":"BerriAI/litellm","slug":"error-transforming-color-guided-generation-params","errorCode":null,"errorMessage":"Error transforming color guided generation params: {e}. Got params: {color_guided_generation_params}, Expected params: {AmazonNovaCanvasColorGuidedGenerationParams.__annotations__}","messagePattern":"Error transforming color guided generation 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":110,"sourceCode":"            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(\n                    **color_guided_generation_params\n                )\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming color guided generation params: {e}. Got params: {color_guided_generation_params}, Expected params: {AmazonNovaCanvasColorGuidedGenerationParams.__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 AmazonNovaCanvasColorGuidedRequest(\n                taskType=task_type,\n                colorGuidedGenerationParams=color_guided_generation_params_typed,\n                imageGenerationConfig=image_generation_config_typed,\n            )\n        if task_type == \"INPAINTING\":\n            inpainting_params: dict[str, Any] = image_generation_config.pop(\"inpaintingParams\", {})\n            inpainting_params = {\"text\": text, **inpainting_params}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py#L92-L128","documentation":"For COLOR_GUIDED_GENERATION requests, LiteLLM builds colorGuidedGenerationParams (injecting 'text') and constructs AmazonNovaCanvasColorGuidedGenerationParams(**params); unknown keys raise TypeError, wrapped in this ValueError with the raw dict and expected annotations. Annotated keys: colors (list of hex strings), referenceImage (base64), text, negativeText.","triggerScenarios":"Passing colors='#00AAFF' as a plain string, an unknown key like 'colorList' or 'reference_image' inside colorGuidedGenerationParams, or extra user kwargs that merged into the params dict during a litellm.image call with taskType='COLOR_GUIDED_GENERATION'.","commonSituations":"Translating AWS SDK color-guided examples with renamed keys; storing colors as a single string instead of a list; forwarding unvalidated user JSON as optional params.","solutions":["Use annotated camelCase keys only: colors, referenceImage, text, negativeText","Pass colors as a list of hex strings, e.g. colors=['#FF0000', '#00FF00']","Base64-encode referenceImage; do not pass a file object or URL","Check the message's 'Got params' dict to spot the exact stray key"],"exampleFix":"# before\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"a logo\",\n    taskType=\"COLOR_GUIDED_GENERATION\",\n    colors=\"#FF0000\",                 # string, not list\n    reference_image=ref_b64,          # wrong key\n)\n\n# after\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"a logo\",\n    taskType=\"COLOR_GUIDED_GENERATION\",\n    colorGuidedGenerationParams={\"colors\": [\"#FF0000\"], \"referenceImage\": ref_b64},\n)","handlingStrategy":"validation","validationCode":"from litellm.types.llms.bedrock import AmazonNovaCanvasColorGuidedGenerationParams\n\ndef validate_color_guided_params(p: dict) -> None:\n    allowed = set(AmazonNovaCanvasColorGuidedGenerationParams.__annotations__)\n    stray = set(p) - allowed\n    assert not stray, f\"unknown keys: {stray}; allowed: {sorted(allowed)}\"\n    colors = p.get(\"colors\", [])\n    assert isinstance(colors, list) and all(isinstance(c, str) and c.startswith(\"#\") for c in colors), (\n        \"colors must be a list of hex strings\"\n    )\n\nvalidate_color_guided_params(color_params)","typeGuard":"def is_valid_color_guided_params(p: dict) -> bool:\n    \"\"\"True when keys match the TypedDict and colors is a list of hex strings.\"\"\"\n    from litellm.types.llms.bedrock import AmazonNovaCanvasColorGuidedGenerationParams\n    allowed = set(AmazonNovaCanvasColorGuidedGenerationParams.__annotations__)\n    colors = p.get(\"colors\", [])\n    return (\n        set(p) <= allowed\n        and isinstance(colors, list)\n        and all(isinstance(c, str) and c.startswith(\"#\") for c in colors)\n    )","tryCatchPattern":"try:\n    resp = litellm.image(...)\nexcept ValueError as e:\n    if \"Error transforming color guided generation params\" in str(e):\n        raise UserInputError(\"colors must be ['#RRGGBB', ...] with valid keys\") from e\n    raise","preventionTips":["Coerce single color strings to a one-element list at your input boundary","Validate hex format ('#RRGGBB') before forwarding","Base64-encode referenceImage once, centrally"],"tags":["bedrock","nova-canvas","image-generation","color-guided","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"}