BerriAI/litellm · error · ValueError

Error transforming color guided generation params: {e}. Got

Error message

Error transforming color guided generation params: {e}. Got params: {color_guided_generation_params}, Expected params: {AmazonNovaCanvasColorGuidedGenerationParams.__annotations__}

What it means

For task COLOR_GUIDED_GENERATION, the popped colorGuidedGenerationParams dict is merged with text and validated against AmazonNovaCanvasColorGuidedGenerationParams. Any constructor error (missing/bad 'text', invalid 'colors' entries, unknown keys, wrong types) is re-raised as this ValueError with the received and expected shapes.

Source

Thrown at litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py:110

            return AmazonNovaCanvasTextToImageRequest(
                textToImageParams=text_to_image_params_typed,
                taskType=task_type,
                imageGenerationConfig=image_generation_config_typed,
            )
        if task_type == "COLOR_GUIDED_GENERATION":
            color_guided_generation_params: dict[str, Any] = image_generation_config.pop(
                "colorGuidedGenerationParams", {}
            )
            color_guided_generation_params = {
                "text": text,
                **color_guided_generation_params,
            }
            try:
                color_guided_generation_params_typed: Final = AmazonNovaCanvasColorGuidedGenerationParams(
                    **color_guided_generation_params
                )
            except Exception as e:
                raise ValueError(
                    f"Error transforming color guided generation params: {e}. Got params: {color_guided_generation_params}, Expected params: {AmazonNovaCanvasColorGuidedGenerationParams.__annotations__}"
                )

            try:
                image_generation_config_typed = AmazonNovaCanvasImageGenerationConfig(**image_generation_config)
            except Exception as e:
                raise ValueError(
                    f"Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__}"
                )

            return AmazonNovaCanvasColorGuidedRequest(
                taskType=task_type,
                colorGuidedGenerationParams=color_guided_generation_params_typed,
                imageGenerationConfig=image_generation_config_typed,
            )
        if task_type == "INPAINTING":
            inpainting_params: dict[str, Any] = image_generation_config.pop("inpaintingParams", {})
            inpainting_params = {"text": text, **inpainting_params}

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Align colorGuidedGenerationParams with the expected keys shown in the error: text (str), colors (list of hex strings), negativeText, referenceImage where supported.
  2. Provide a non-empty prompt so 'text' is valid.
  3. Validate hex color format ('#RRGGBB') client-side before sending.

Example fix

# before
litellm.image(model="bedrock/amazon.nova-canvas-v1:0", task="COLOR_GUIDED_GENERATION",
             prompt="brand logo", colorGuidedGenerationParams={"colors": "#FF0000, #00FF00"})
# after
litellm.image(model="bedrock/amazon.nova-canvas-v1:0", task="COLOR_GUIDED_GENERATION",
             prompt="brand logo",
             colorGuidedGenerationParams={"colors": ["#FF0000", "#00FF00"]})
Defensive patterns

Strategy: validation

Validate before calling

import re

HEX = re.compile(r"^#[0-9A-Fa-f]{6}$")

def valid_color_guided_params(p: dict, prompt: str | None) -> bool:
    colors = p.get("colors", [])
    return (
        isinstance(prompt, str) and prompt != ""
        and isinstance(colors, list)
        and all(isinstance(c, str) and HEX.match(c) for c in colors)
    )

Type guard

def is_hex_color_list(v: object) -> bool:
    import re
    return (
        isinstance(v, list)
        and all(isinstance(c, str) and re.fullmatch(r"#[0-9A-Fa-f]{6}", c) for c in v)
    )

Prevention

When it happens

Trigger: litellm.image(task='COLOR_GUIDED_GENERATION', ...) with colorGuidedGenerationParams containing invalid keys, colors not as list of hex strings, referenceImage malformed, or no usable text prompt.

Common situations: Copying AWS console JSON examples with different key casing; passing 'colors' as a comma string instead of a list; empty prompt so merged text is empty/None.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/54a4de07352a1af2. Report an issue: GitHub.