BerriAI/litellm · error · ValueError
Error transforming image generation config: {e}. Got params:
Error message
Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__} What it means
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.
Source
Thrown at litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py:88
# Extract model_id parameter to prevent "extraneous key" error from Bedrock API
# Following the same pattern as chat completions and embeddings
unencoded_model_id: Final = optional_params.pop("model_id", None) # noqa: F841
image_generation_config = {**image_generation_config, **optional_params}
if task_type == "TEXT_IMAGE":
text_to_image_params: dict[str, Any] = image_generation_config.pop("textToImageParams", {})
text_to_image_params = {"text": text, **text_to_image_params}
try:
text_to_image_params_typed: Final = AmazonNovaCanvasTextToImageParams(**text_to_image_params)
except Exception as e:
raise ValueError(
f"Error transforming text to image params: {e}. Got params: {text_to_image_params}, Expected params: {AmazonNovaCanvasTextToImageParams.__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 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(View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before
litellm.image(model="bedrock/amazon.nova-canvas-v1:0",
prompt="a cat", numberOfImages="2") # str type -> ValueError
# after
litellm.image(model="bedrock/amazon.nova-canvas-v1:0",
prompt="a cat", n=2) # OpenAI param, mapped to numberOfImages int Defensive patterns
Strategy: validation
Validate before calling
ALLOWED_CFG = {"numberOfImages", "quality", "cfgScale", "seed", "width", "height"}
def valid_generation_config(c: dict) -> bool:
return (
set(c) <= ALLOWED_CFG
and all(not isinstance(v, str) for k, v in c.items() if k in {"numberOfImages", "seed", "width", "height"})
) Type guard
def is_valid_image_generation_config(c: object) -> bool:
if not isinstance(c, dict):
return False
ints = {"numberOfImages", "seed", "width", "height"}
return all(
(k not in ints or (isinstance(v, int) and not isinstance(v, bool)))
for k, v in c.items()
) Prevention
- 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.
When it happens
Trigger: 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.).
Common situations: 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.
Related errors
- Error transforming text to image params: {e}. Got params: {t
- Error transforming color guided generation params: {e}. Got
- Error transforming inpainting params: {e}. Got params: {inpa
- OUTPAINTING requires either a mask image or a mask prompt. P
- Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/b3fe9acc200638ff.
Report an issue: GitHub.