BerriAI/litellm · error · ValueError
Nova Canvas image edit requires an image input
Error message
Nova Canvas image edit requires an image input
What it means
Nova Canvas image edit on Bedrock is an edit API: it always needs a source image, encoded to base64 by _file_types_to_b64. That helper raises immediately when image is None (the handler also maps an empty image list to None via image[0] if image else None), before any request is built.
Solutions
- Pass the source image: image=open('cat.png', 'rb'), raw bytes, a base64 string, or a pathlib.Path
- For text-to-image without an input image use litellm.image(model='bedrock/amazon.nova-canvas-v1:0', ...) instead
- Assert image is not None before the call in code where the file is optional
Example fix
# before
resp = litellm.image_edit(
model="bedrock/amazon.nova-canvas-v1:0",
prompt="make the sky sunset-colored",
)
# after
resp = litellm.image_edit(
model="bedrock/amazon.nova-canvas-v1:0",
image=open("scene.png", "rb"),
prompt="make the sky sunset-colored",
) Defensive patterns
Strategy: validation
Validate before calling
def require_image(image):
if image is None:
raise ValueError("image_edit requires a source image; use litellm.image() for generation")
return image
img = require_image(maybe_none_image) Type guard
def is_supplied(image) -> bool:
"""True when a source image/mask value is present and non-empty."""
if image is None:
return False
if isinstance(image, (list, tuple)):
return len(image) > 0
return True Try / catch
try:
resp = litellm.image_edit(...)
except ValueError as e:
if "requires an image input" in str(e):
raise UserInputError("Upload a source image to edit") from e
raise Prevention
- Make the image argument required (positional) in your own wrapper so static checks catch omissions
- Validate uploaded files exist and are readable before building the edit request
- Reserve image_edit for edits; route text-to-image traffic to litellm.image()
When it happens
Trigger: litellm.image_edit(model='bedrock/amazon.nova-canvas-v1:0', prompt='a sunset') with image omitted or image=[]; the variable holding the file object is None because an earlier upload/open failed.
Common situations: Using image_edit for pure text-to-image generation (that is litellm.image()); optional-image code paths where the file may legitimately be absent; silent failures from open()/requests producing None.
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
- Amazon Nova Canvas requires a text prompt. Pass a non-empty…
- Unsupported Amazon Nova Canvas taskType
- Amazon Nova Canvas INPAINTING requires either maskPrompt or…
- Nova Canvas image edit does not support tuple FileTypes…
- OUTPAINTING requires either a mask image or a mask prompt…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/f49555bb974ed1f0.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py:134
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,
}
def _file_types_to_b64(image: FileTypes | None) -> str:
"""Encode OpenAI image input to base64 string for Nova Canvas."""
if image is None:
raise ValueError("Nova Canvas image edit requires an image input")
if hasattr(image, "read") and callable(getattr(image, "read", None)):
if hasattr(image, "seek"):
image.seek(0)
image_bytes: Final = image.read()
return base64.b64encode(image_bytes).decode("utf-8")
if isinstance(image, bytes):
return base64.b64encode(image).decode("utf-8")
if isinstance(image, str):
return image
if isinstance(image, os.PathLike):
with open(image, "rb") as f:
return base64.b64encode(f.read()).decode("utf-8")
if isinstance(image, tuple):
raise ValueError(
"Nova Canvas image edit does not support tuple FileTypes. "
"Pass a file-like object, bytes, or a base64-encoded string."
)
return base64.b64encode(bytes(image)).decode("utf-8")View on GitHub (pinned to 77b7c6c40c)