BerriAI/litellm · error · ValueError

Unsupported image type. Expected either image url or base64…

Error message

Unsupported image type. Expected either image url or base64 encoded string

What it means

BedrockImageProcessor.process_image_sync guard: the image_url is neither a base64 data URI nor a URL the processor can handle, so no Bedrock image block can be built. Fires when the content block's image source is an unrecognized string shape.

Solutions

  1. Pass the image as an image URL or a base64-encoded data string.
  2. Use the format {"image_url": "data:image/jpeg;base64,..."}.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:3582 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/ce331d7b68514f03. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:3582

                    name=document_name,
                )
            )
        elif is_video:
            return BedrockContentBlock(video=BedrockVideoBlock(source=_blob, format=image_format))
        else:
            return BedrockContentBlock(image=BedrockImageBlock(source=_blob, format=image_format))

    @classmethod
    def process_image_sync(cls, image_url: str, format: str | None = None) -> BedrockContentBlock:
        """Synchronous image processing."""

        if "base64" in image_url:
            img_bytes, mime_type, image_format = cls._parse_base64_image(image_url)
        elif "http://" in image_url or "https://" in image_url:
            img_bytes, mime_type = BedrockImageProcessor.get_image_details(image_url)
            image_format = mime_type.split("/")[1]
        else:
            raise ValueError("Unsupported image type. Expected either image url or base64 encoded string")

        if format:
            mime_type = format
            image_format = mime_type.split("/")[1]

        image_format = cls._validate_format(mime_type, image_format)
        return cls._create_bedrock_block(img_bytes, mime_type, image_format)

    @classmethod
    async def process_image_async(cls, image_url: str, format: str | None) -> BedrockContentBlock:
        """Asynchronous image processing."""

        if "base64" in image_url:
            img_bytes, mime_type, image_format = cls._parse_base64_image(image_url)
        elif "http://" in image_url or "https://" in image_url:
            img_bytes, mime_type = await BedrockImageProcessor.get_image_details_async(image_url)
            image_format = mime_type.split("/")[1]
        else:

View on GitHub (pinned to 77b7c6c40c)