BerriAI/litellm · error · ValueError
Amazon Nova Canvas INPAINTING requires either maskPrompt or
Error message
Amazon Nova Canvas INPAINTING requires either maskPrompt or maskImage (use OpenAI mask= for maskImage, or pass maskPrompt in optional params). See https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html
What it means
Inside the INPAINTING branch (entered when taskType=='INPAINTING' or when a mask/maskPrompt is present), the builder must put maskPrompt or maskImage into inPaintingParams. If neither survived parameter extraction, it raises ValueError pointing at the AWS Nova docs, since Bedrock rejects inpainting without a mask.
Source
Thrown at litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py:111
}
# Explicit taskType must be INPAINTING or omitted from here on; anything else is invalid.
if task_type is not None and str(task_type).strip() != "":
if task_type != "INPAINTING":
raise ValueError(
f"Unsupported Amazon Nova Canvas taskType: {task_type!r}. "
"Use BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING, "
"or omit taskType for automatic routing (mask → INPAINTING, else IMAGE_VARIATION)."
)
if mask_b64 is not None or mask_prompt is not None or task_type == "INPAINTING":
in_params: Final[dict[str, Any]] = {"image": image_b64, "text": text}
if mask_prompt is not None:
in_params["maskPrompt"] = mask_prompt
elif mask_b64 is not None:
in_params["maskImage"] = mask_b64
if negative_text is not None:
in_params["negativeText"] = negative_text
if "maskPrompt" not in in_params and "maskImage" not in in_params:
raise ValueError(
"Amazon Nova Canvas INPAINTING requires either maskPrompt or maskImage "
"(use OpenAI mask= for maskImage, or pass maskPrompt in optional params). "
"See https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html"
)
return {"taskType": "INPAINTING", "inPaintingParams": in_params}
var_params: Final[dict[str, Any]] = {
"images": [image_b64],
"text": text,
}
if negative_text is not None:
var_params["negativeText"] = negative_text
if similarity_strength is not None:
var_params["similarityStrength"] = similarity_strength
return {
"taskType": "IMAGE_VARIATION",
"imageVariationParams": var_params,
}
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass maskPrompt in optional params: {"taskType": "INPAINTING", "maskPrompt": "..."}.
- Or send the mask image under the OpenAI 'mask' file field so LiteLLM encodes it as maskImage.
- If you have no mask, use taskType='IMAGE_VARIATION' or omit taskType.
Example fix
# before
litellm.image_edit(model="bedrock/nova-canvas", image=img,
prompt="remove object", taskType="INPAINTING") # ValueError
# after
litellm.image_edit(model="bedrock/nova-canvas", image=img,
prompt="remove object", taskType="INPAINTING",
mask=open("mask.png", "rb")) Defensive patterns
Strategy: validation
Validate before calling
def validate_inpainting(params: dict, mask_present: bool) -> None:
if params.get("taskType") == "INPAINTING" and not (
mask_present or params.get("maskPrompt")
):
raise ValueError("INPAINTING needs mask= file or maskPrompt") Prevention
- Never send INPAINTING without mask or maskPrompt — Bedrock requires it downstream anyway.
- Name the multipart mask field exactly 'mask'.
- If no mask exists, choose IMAGE_VARIATION or omit taskType.
When it happens
Trigger: taskType='INPAINTING' with neither mask= nor maskPrompt supplied; or auto-routing selected INPAINTING via a truthy-but-empty mask edge (e.g. mask consumed earlier and produced None b64).
Common situations: Assuming Nova inpainting infers the mask from the prompt like some OpenAI workflows; passing mask as a form field the proxy didn't forward; mask file present but named differently than 'mask'.
Related errors
- OUTPAINTING requires either a mask image or a mask prompt. P
- Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use
- Nova Canvas image edit requires an image input
- Nova Canvas image edit does not support tuple FileTypes. Pas
- Amazon Nova Canvas {task_type} requires a text prompt. Pass
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/eac9eda2757ea82b.
Report an issue: GitHub.