BerriAI/litellm · error · ValueError
Unsupported image type for Vertex AI Imagen image edit.
Error message
Unsupported image type for Vertex AI Imagen image edit.
What it means
Inside _read_all_bytes, when the value is a list or tuple the code recurses into the first non-None element; if every element is None (or the container is empty) there is nothing to read and this ValueError is raised. It means a container reached the byte reader but carried no usable payload — distinct from the top-level 'image is None' check in transform_image_edit_request.
Source
Thrown at litellm/llms/vertex_ai/image_edit/vertex_imagen_transformation.py:298
"maskMode": "MASK_MODE_USER_PROVIDED",
"dilation": 0.03, # Default dilation value (not configurable via OpenAI API)
},
}
reference_images.append(mask_reference)
return reference_images
def _read_all_bytes(self, image: Any, depth: int = 0, max_depth: int = DEFAULT_MAX_RECURSE_DEPTH) -> bytes:
if depth > max_depth:
raise ValueError(
f"Max recursion depth {max_depth} reached while reading image bytes for Vertex AI Imagen image edit."
)
if isinstance(image, (list, tuple)):
for item in image:
if item is not None:
return self._read_all_bytes(item, depth=depth + 1, max_depth=max_depth)
raise ValueError("Unsupported image type for Vertex AI Imagen image edit.")
if isinstance(image, dict):
for key in ("data", "bytes", "content"):
if key in image and image[key] is not None:
value = image[key]
if isinstance(value, str):
try:
return base64.b64decode(value)
except Exception:
continue
return self._read_all_bytes(value, depth=depth + 1, max_depth=max_depth)
if "path" in image:
return self._read_all_bytes(image["path"], depth=depth + 1, max_depth=max_depth)
if isinstance(image, bytes):
return image
if isinstance(image, bytearray):
return bytes(image)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Filter Nones and empties out of image lists before calling litellm
- Replace failed downloads with a hard error instead of None placeholders
- Validate that at least one element is bytes/str-in-dict/file-like before sending
Example fix
# before
resp = litellm.image_edit(
model='vertex_ai/imagen-3.0-capability-001',
prompt='edit',
image=[failed_download, None], # both None-ish -> raises
)
# after
imgs = [img for img in downloads if img is not None]
if not imgs:
raise ValueError('all image downloads failed')
resp = litellm.image_edit(
model='vertex_ai/imagen-3.0-capability-001',
prompt='edit',
image=imgs,
) Defensive patterns
Strategy: validation
Validate before calling
def has_payload(container) -> bool:
return any(item is not None for item in (container or []))
if isinstance(image, (list, tuple)):
assert has_payload(image), 'image container has no usable entries' Try / catch
try:
resp = litellm.image_edit(model='vertex_ai/imagen-...', prompt=p, image=image)
except ValueError as e:
if 'Unsupported image type' in str(e) and isinstance(image, (list, tuple)):
raise ValueError('image list contained only None entries') from e
raise Prevention
- Filter Nones from every image list before it reaches litellm
- Never use [None] placeholders to satisfy list-typed parameters
- Log when image downloads fail so empty containers are visible upstream
When it happens
Trigger: image=[None] or image=[None, None] passed as the images list; the mask optional param set to an empty tuple (); a dict {'data': [None]} recursing into a None-only list.
Common situations: Placeholder lists filled with None by an earlier failed download; default arguments like image=[None] used to satisfy a type signature; multi-upload forms where every file failed to read and None was substituted.
Related errors
- Unsupported image input: plain string values are not accepte
- Unsupported image input: filesystem paths are not accepted f
- Unsupported image type for Vertex AI Imagen image edit. Got
- Unsupported image type for Vertex AI Gemini image edit.
- Vertex AI Imagen image edit requires at least one reference
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/c6494e340053fb17.
Report an issue: GitHub.