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

AWS requires Nova Canvas inPaintingParams to include either maskImage or maskPrompt. LiteLLM enters the INPAINTING branch when a mask/maskPrompt is present or taskType='INPAINTING' is explicit; if the branch is entered but neither mask field ended up in in_params (i.e. explicit INPAINTING with no mask supplied), it raises this ValueError before sending the request.

Solutions

  1. Pass a mask image: litellm.image_edit(..., mask=open('mask.png', 'rb')) (OpenAI-style mask= becomes maskImage)
  2. Or pass maskPrompt in optional params describing the region to inpaint
  3. If no mask is intended, drop taskType so the call routes to IMAGE_VARIATION

Example fix

# before
resp = litellm.image_edit(
    model="bedrock/amazon.nova-canvas-v1:0",
    image=open("cat.png", "rb"),
    prompt="a red collar",
    taskType="INPAINTING",
)

# after
resp = litellm.image_edit(
    model="bedrock/amazon.nova-canvas-v1:0",
    image=open("cat.png", "rb"),
    prompt="a red collar",
    taskType="INPAINTING",
    mask=open("collar-mask.png", "rb"),   # or maskPrompt="the neck area"
)
Defensive patterns

Strategy: validation

Validate before calling

def validate_inpainting_call(kwargs: dict) -> None:
    if kwargs.get("taskType") == "INPAINTING":
        assert kwargs.get("mask") is not None or kwargs.get("maskPrompt"), (
            "INPAINTING needs mask= (maskImage) or maskPrompt"
        )

validate_inpainting_call(kwargs)

Type guard

def has_inpainting_mask(kwargs: dict) -> bool:
    """True when INPAINTING kwargs carry maskImage or maskPrompt."""
    if kwargs.get("taskType") != "INPAINTING":
        return True
    return kwargs.get("mask") is not None or bool(kwargs.get("maskPrompt"))

Try / catch

try:
    resp = litellm.image_edit(...)
except ValueError as e:
    if "INPAINTING requires either maskPrompt or maskImage" in str(e):
        raise UserInputError("Pass mask=<file> or maskPrompt for inpainting") from e
    raise

Prevention

When it happens

Trigger: litellm.image_edit(model='bedrock/amazon.nova-canvas-v1:0', image=source, prompt='add a hat', taskType='INPAINTING') with neither mask=<file> nor maskPrompt in optional params.

Common situations: Assuming INPAINTING works from the prompt alone; passing the mask under a key the transformer does not read; migrating from Stability edits where mask wiring differs.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: 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 77b7c6c40c)