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

  1. Pass maskPrompt in optional params: {"taskType": "INPAINTING", "maskPrompt": "..."}.
  2. Or send the mask image under the OpenAI 'mask' file field so LiteLLM encodes it as maskImage.
  3. 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

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


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