BerriAI/litellm · error · ValueError
Unsupported image format: {image_format}. Supported formats:
Error message
Unsupported image format: {image_format}. Supported formats: {supported_image_and_video_formats} What it means
Bedrock image validation: for non-document payloads, the resolved image_format (extension like 'jpg', 'gif', 'mp4') is checked against the union of supported image and video formats, and this ValueError is raised when it is not in that list. The supported list is embedded in the message.
Source
Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:3473
supported_doc_formats: Final = litellm.AmazonConverseConfig().get_supported_document_types()
supported_video_formats: Final = litellm.AmazonConverseConfig().get_supported_video_types()
document_types: Final = ["application", "text"]
is_document: Final = any(mime_type.startswith(doc_type) for doc_type in document_types)
supported_image_and_video_formats: Final[list[str]] = supported_video_formats + supported_image_formats
if is_document:
return BedrockImageProcessor._get_document_format(
mime_type=mime_type, supported_doc_formats=supported_doc_formats
)
else:
#########################################################
# Check if image_format is an image or video
#########################################################
if image_format not in supported_image_and_video_formats:
raise ValueError(
f"Unsupported image format: {image_format}. Supported formats: {supported_image_and_video_formats}"
)
return image_format
@staticmethod
def _get_document_format(mime_type: str, supported_doc_formats: list[str]) -> str:
"""
Get the document format from the mime type
- Primary method - uses `mimetypes.guess_all_extensions`
- Fallback method - uses `get_file_extension_from_mime_type`
Relevant Issue: https://github.com/BerriAI/litellm/issues/12260
`mimetypes` is not available in docker containers, so we fallback to `get_file_extension_from_mime_type`
Args:
mime_type: The mime type of the documentView on GitHub (pinned to 6c2dcb801b)
Solutions
- Convert to a supported format first (jpeg/png/gif/webp for images; Bedrock-listed video formats) with Pillow/ffmpeg
- Check the error's supported list and re-encode your asset to one of those extensions/mime types
- Ensure the mime_type you pass matches the actual bytes so the correct format is derived
Example fix
# before
block = {"type": "image_url", "image_url": {"url": "data:image/tiff;base64,<b64>"}}
# after
from PIL import Image
import io, base64
img = Image.open("scan.tiff").convert("RGB")
buf = io.BytesIO(); img.save(buf, format="JPEG")
block = {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + base64.b64encode(buf.getvalue()).decode()}} Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_IMAGE_FORMATS = {"jpeg", "jpg", "png", "gif", "webp"}
# cross-check with the list in the error message for video formats on your Bedrock model
def validate_bedrock_image(blocks) -> None:
for b in blocks:
if isinstance(b, dict) and b.get("type") == "image_url":
fmt = image_format_from_url(b["image_url"]["url"]) # e.g. from data:image/<fmt>
if fmt.lower() not in SUPPORTED_IMAGE_FORMATS:
raise ValueError(f"convert {fmt} to a supported format before Bedrock") Type guard
from typing import Any
_OK = {"jpeg", "jpg", "png", "gif", "webp"}
def is_bedrock_supported_image(v: Any) -> bool:
if not isinstance(v, str):
return False
if v.startswith("data:image/"):
fmt = v.split("data:image/")[1].split(";", 1)[0]
return fmt.lower() in _OK
return False Prevention
- Normalize all images to jpeg/png at ingest
- Keep mime_type consistent with actual bytes
- Check the model's supported media list in AWS docs when adding new asset types
When it happens
Trigger: Sending a Bedrock converse/vision request with an image whose format is not one of the supported image/video extensions (e.g. tiff, heic, bmp, svg); a format inferred from a mime type that maps to an unsupported extension; video formats outside Bedrock's accepted set.
Common situations: Feeding raw camera/scanner output (TIFF/HEIC) to Bedrock models; mislabelled mime types causing wrong extension inference; assuming S3-stored proprietary formats will pass through.
Related errors
- Invalid image URL: {content_image_url}
- Image url not in expected format. Example Expected input - "
- No supported extensions for MIME type: {mime_type}. Supporte
- Invalid guardrailConfig={raw_guardrail_config}. Expected for
- guardrailConfig={raw_guardrail_config} is missing 'guardrail
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/2291ab1b5c72cdd9.
Report an issue: GitHub.