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
Every Nova Canvas image edit fundamentally needs a source image. The helper _file_types_to_b64 encodes the OpenAI image input to base64 and raises ValueError when image is None, i.e. the request reached transformation without any image payload.
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 6c2dcb801b)
Solutions
- Include the source image as the 'image' file part of the multipart images/edits request.
- Acceptable forms: file-like object, raw bytes, base64 string, or os.PathLike path (tuples are rejected separately).
- If you meant generation from text only, call /v1/images/generations instead.
Example fix
# before
litellm.image_edit(model="bedrock/nova-canvas", prompt="a cat") # no image
# after
with open("cat.png", "rb") as f:
litellm.image_edit(model="bedrock/nova-canvas", prompt="a cat", image=f) Defensive patterns
Strategy: type-guard
Validate before calling
def has_image(image) -> bool:
return image is not None and image != [] Type guard
def is_usable_nova_image(v: object) -> bool:
import os
return (
v is not None
and (hasattr(v, "read") or isinstance(v, (bytes, str, os.PathLike)))
) Prevention
- Make the image argument required in internal wrappers around images/edits.
- Assert the multipart request contains an 'image' file part before sending.
- Use /images/generations for prompt-only workflows.
When it happens
Trigger: POST /v1/images/edits on a nova-canvas model with no 'image' file part (only prompt), or litellm.image_edit(image=None) / empty list; also when a gateway drops the multipart image field.
Common situations: Client code written for DALL-E-style prompt-only edits; sending image as a JSON field instead of multipart file; test harness that omits fixtures.
Related errors
- OUTPAINTING requires either a mask image or a mask prompt. P
- Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use
- Amazon Nova Canvas INPAINTING requires either maskPrompt or
- 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/f49555bb974ed1f0.
Report an issue: GitHub.