BerriAI/litellm · error · Exception
Invalid image received - {image_url}
Error message
Invalid image received - {image_url} What it means
Gemini image-part guard: the image_url is neither a recognized provider URL, data URI, nor a resolvable file reference, so no fileData/inlineData part can be created and the image is rejected as invalid.
Source
Thrown at litellm/llms/vertex_ai/gemini/transformation.py:580
# These URLs return 403 when accessed directly, so we must not try
# to resolve their MIME type via HTTP.
if format:
file_data = FileDataType(mime_type=format, file_uri=image_url)
else:
# Gemini Files API references can be passed through as URI-only.
file_data = cast(FileDataType, {"file_uri": image_url})
part = {"file_data": file_data}
return _apply_gemini_metadata(part, model, media_resolution_enum, video_metadata)
elif "https://" in image_url and (image_type := format or _get_image_mime_type_from_url(image_url)) is not None:
file_data = FileDataType(mime_type=image_type, file_uri=image_url)
part = {"file_data": file_data}
return _apply_gemini_metadata(part, model, media_resolution_enum, video_metadata)
elif "http://" in image_url or "https://" in image_url or "base64" in image_url:
image: Final = convert_to_anthropic_image_obj(image_url, format=format)
_blob: Final[BlobType] = {"data": image["data"], "mime_type": image["media_type"]}
part = {"inline_data": cast(BlobType, _blob)}
return _apply_gemini_metadata(part, model, media_resolution_enum, video_metadata)
raise Exception(f"Invalid image received - {image_url}")
except Exception as e:
raise e
def _snake_to_camel(snake_str: str) -> str:
"""Convert snake_case to camelCase"""
components: Final = snake_str.split("_")
return components[0] + "".join(x.capitalize() for x in components[1:])
def _camel_to_snake(camel_str: str) -> str:
"""Convert camelCase to snake_case"""
return re.sub(r"(?<!^)(?=[A-Z])", "_", camel_str).lower()
def _get_equivalent_key(key: str, available_keys: set) -> str | None:
"""
Get the equivalent key from available keys, checking both camelCase and snake_case variantsView on GitHub (pinned to 77b7c6c40c)
Solutions
- Provide a valid image URL or base64 data that can be fetched/decoded.
- Check the image_url value for accessibility and correct format.
Example fix
# verify the URL is reachable or use data:image/png;base64,... format.
Defensive patterns
Strategy: validation
When it happens
Trigger: Triggered when an invalid image URL/data is passed to the Vertex AI Gemini transformation.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/058c6aec5cec2dfd.
Report an issue: GitHub.