{"record":{"id":"2291ab1b5c72cdd9","repo":"BerriAI/litellm","slug":"unsupported-image-format-image-format-supporte","errorCode":null,"errorMessage":"Unsupported image format: {image_format}. Supported formats: {supported_image_and_video_formats}","messagePattern":"Unsupported image format: (.+?)\\. Supported formats: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/prompt_templates/factory.py","lineNumber":3473,"sourceCode":"        supported_doc_formats: Final = litellm.AmazonConverseConfig().get_supported_document_types()\n        supported_video_formats: Final = litellm.AmazonConverseConfig().get_supported_video_types()\n\n        document_types: Final = [\"application\", \"text\"]\n        is_document: Final = any(mime_type.startswith(doc_type) for doc_type in document_types)\n\n        supported_image_and_video_formats: Final[list[str]] = supported_video_formats + supported_image_formats\n\n        if is_document:\n            return BedrockImageProcessor._get_document_format(\n                mime_type=mime_type, supported_doc_formats=supported_doc_formats\n            )\n\n        else:\n            #########################################################\n            # Check if image_format is an image or video\n            #########################################################\n            if image_format not in supported_image_and_video_formats:\n                raise ValueError(\n                    f\"Unsupported image format: {image_format}. Supported formats: {supported_image_and_video_formats}\"\n                )\n            return image_format\n\n    @staticmethod\n    def _get_document_format(mime_type: str, supported_doc_formats: list[str]) -> str:\n        \"\"\"\n        Get the document format from the mime type\n\n        - Primary method - uses `mimetypes.guess_all_extensions`\n        - Fallback method - uses `get_file_extension_from_mime_type`\n\n        Relevant Issue: https://github.com/BerriAI/litellm/issues/12260\n\n        `mimetypes` is not available in docker containers, so we fallback to `get_file_extension_from_mime_type`\n\n        Args:\n            mime_type: The mime type of the document","sourceCodeStart":3455,"sourceCodeEnd":3491,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/prompt_templates/factory.py#L3455-L3491","documentation":"Bedrock image processing: the derived image/video format (extension) is not in the supported list for that model (supported_video_formats + supported_image_formats), so litellm raises rather than sending a format Bedrock will reject. Documents take a separate path and do not reach this check.","triggerScenarios":"Sending an image or video whose extension is unsupported by the Bedrock model in use - e.g. .tiff, .avif, .svg, or an unusual extension guessed from the mime type when the URL lacks one.","commonSituations":"iPhone HEIC media; CAD/print formats (TIFF); URLs without extensions where mimetypes.guess_all_extensions picks an exotic suffix; new formats not yet in Bedrock's list.","solutions":["Convert the media to a supported format (JPEG/PNG/GIF/WEBP for images; the model's listed video formats for video)","Rename/serve the file with a standard extension so format detection picks a supported one","Check the error's supported list against your format before filing bugs"],"exampleFix":"# before: TIFF sent to Bedrock Anthropic\n{\"type\": \"image\", \"source\": {\"type\": \"base64\", \"media_type\": \"image/tiff\", \"data\": tiff_b64}}\n\n# after: convert to PNG\nfrom PIL import Image\nimport base64, io\nbuf = io.BytesIO()\nImage.open(\"scan.tiff\").convert(\"RGB\").save(buf, format=\"PNG\")\npng_b64 = base64.b64encode(buf.getvalue()).decode()\n{\"type\": \"image\", \"source\": {\"type\": \"base64\", \"media_type\": \"image/png\", \"data\": png_b64}}","handlingStrategy":"validation","validationCode":"SUPPORTED_IMAGE_FORMATS = {\"jpeg\", \"jpg\", \"png\", \"gif\", \"webp\"}\nSUPPORTED_VIDEO_FORMATS = {\"mp4\", \"mov\", \"mkv\", \"webm\", \"flv\", \"mpeg\", \"mpg\", \"wmv\", \"3gp\"}\n\ndef media_format_supported(url_or_mime: str) -> bool:\n    ext = url_or_mime.rsplit(\".\", 1)[-1].lower() if \".\" in url_or_mime else url_or_mime.split(\"/\")[-1].lower()\n    return ext in (SUPPORTED_IMAGE_FORMATS | SUPPORTED_VIDEO_FORMATS)\n\n# convert unsupported media to PNG/MP4 before building the bedrock payload","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"bedrock/anthropic.claude-...\", messages=messages)\nexcept ValueError as e:\n    if \"Unsupported image format\" in str(e):\n        messages = reencode_media_to_png(messages)  # PIL convert, then retry\n    else:\n        raise","preventionTips":["Transcode user uploads to PNG/JPEG (images) or MP4 (video) before sending to Bedrock","Serve media from URLs with standard extensions so format detection is deterministic","Whitelist formats at ingest and reject exotic ones with a clear user-facing message"],"tags":["bedrock","image","video","format","validation"],"backgroundTag":"unsupported-image-format","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}