{"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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/prompt_templates/factory.py#L3455-L3491","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nblock = {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image/tiff;base64,<b64>\"}}\n\n# after\nfrom PIL import Image\nimport io, base64\nimg = Image.open(\"scan.tiff\").convert(\"RGB\")\nbuf = io.BytesIO(); img.save(buf, format=\"JPEG\")\nblock = {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image/jpeg;base64,\" + base64.b64encode(buf.getvalue()).decode()}}","handlingStrategy":"validation","validationCode":"SUPPORTED_IMAGE_FORMATS = {\"jpeg\", \"jpg\", \"png\", \"gif\", \"webp\"}\n# cross-check with the list in the error message for video formats on your Bedrock model\n\ndef validate_bedrock_image(blocks) -> None:\n    for b in blocks:\n        if isinstance(b, dict) and b.get(\"type\") == \"image_url\":\n            fmt = image_format_from_url(b[\"image_url\"][\"url\"])  # e.g. from data:image/<fmt>\n            if fmt.lower() not in SUPPORTED_IMAGE_FORMATS:\n                raise ValueError(f\"convert {fmt} to a supported format before Bedrock\")","typeGuard":"from typing import Any\n\n_OK = {\"jpeg\", \"jpg\", \"png\", \"gif\", \"webp\"}\n\ndef is_bedrock_supported_image(v: Any) -> bool:\n    if not isinstance(v, str):\n        return False\n    if v.startswith(\"data:image/\"):\n        fmt = v.split(\"data:image/\")[1].split(\";\", 1)[0]\n        return fmt.lower() in _OK\n    return False","tryCatchPattern":null,"preventionTips":["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"],"tags":["bedrock","vision","image-format","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}