BerriAI/litellm · error · ValueError

Unsupported Amazon Nova Canvas taskType

Error message

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).

What it means

The Nova Canvas image-edit task body builder only knows four task types: BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, and INPAINTING. After handling the first three, any other non-empty taskType raises this ValueError because there is no matching AWS task params block to construct; an empty/whitespace taskType is treated as omitted (auto-routing).

Solutions

  1. Use one of the exact uppercase strings: BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING
  2. Omit taskType entirely and let LiteLLM route automatically: mask present -> INPAINTING, otherwise IMAGE_VARIATION
  3. For generation-only tasks (TEXT_IMAGE, COLOR_GUIDED_GENERATION) call litellm.image() instead of litellm.image_edit()

Example fix

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

# after
resp = litellm.image_edit(
    model="bedrock/amazon.nova-canvas-v1:0",
    image=open("cat.png", "rb"),
    prompt="remove background",
    taskType="BACKGROUND_REMOVAL",
)
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED = {"BACKGROUND_REMOVAL", "OUTPAINTING", "IMAGE_VARIATION", "INPAINTING"}
task = kwargs.get("taskType")
assert task is None or task in SUPPORTED, f"bad taskType {task!r}; valid: {SUPPORTED}"

Type guard

from typing import Final

NOVA_CANVAS_EDIT_TASK_TYPES: Final[frozenset[str]] = frozenset(
    {"BACKGROUND_REMOVAL", "OUTPAINTING", "IMAGE_VARIATION", "INPAINTING"}
)

def is_valid_edit_task_type(task_type: str | None) -> bool:
    """True when taskType is a Nova Canvas image-edit task or omitted."""
    return task_type is None or str(task_type).strip() == "" or task_type in NOVA_CANVAS_EDIT_TASK_TYPES

Try / catch

try:
    resp = litellm.image_edit(...)
except ValueError as e:
    if "Unsupported Amazon Nova Canvas taskType" in str(e):
        # fall back to auto-routing instead of an explicit task
        kwargs.pop("taskType", None)
        resp = litellm.image_edit(..., **kwargs)
    else:
        raise

Prevention

When it happens

Trigger: taskType='COLOR_GUIDED_GENERATION' (a generation-only task), a case mismatch like 'outpainting', or a typo like 'INPAINT' passed to litellm.image_edit with a Nova Canvas model.

Common situations: Copying taskType values from the Nova Canvas image-generation docs into an edit call; assuming case-insensitive task names; stale constants after refactoring from generation code to edit code.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py:97

    # Honour explicit IMAGE_VARIATION even when a mask is present (mask is ignored
    # for this task type; callers use INPAINTING when they want mask semantics).
    if task_type == "IMAGE_VARIATION":
        var_params_explicit: Final[dict[str, Any]] = {
            "images": [image_b64],
            "text": text,
        }
        if negative_text is not None:
            var_params_explicit["negativeText"] = negative_text
        if similarity_strength is not None:
            var_params_explicit["similarityStrength"] = similarity_strength
        return {
            "taskType": "IMAGE_VARIATION",
            "imageVariationParams": var_params_explicit,
        }
    # 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"
            )

View on GitHub (pinned to 77b7c6c40c)