vercel/ai · error · UnsupportedFunctionalityError

Unsupported image mime type: ${mimeType}, expected one of: $

Error message

Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(', ')}

What it means

getAmazonBedrockImageFormat maps an image MIME type to a Bedrock image format and throws UnsupportedFunctionalityError when the MIME type is absent from BEDROCK_IMAGE_MIME_TYPES. Bedrock only accepts jpeg, png, gif, and webp images, and requires the format field to match the payload.

Source

Thrown at packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts:657

  }

  return { system, messages };
}

// wrap invalid tool call input because Bedrock requires it to be an object
function toBedrockToolInput(input: unknown): JSONObject {
  return typeof input === 'object' && input !== null && !Array.isArray(input)
    ? (input as JSONObject)
    : { rawInvalidInput: input as JSONValue };
}

function getAmazonBedrockImageFormat(
  mimeType: string,
): AmazonBedrockImageFormat {
  const format =
    BEDROCK_IMAGE_MIME_TYPES[mimeType as AmazonBedrockImageMimeType];
  if (!format) {
    throw new UnsupportedFunctionalityError({
      functionality: `image mime type: ${mimeType}`,
      message: `Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(', ')}`,
    });
  }

  return format;
}

function getAmazonBedrockDocumentFormat(
  mimeType: string,
): AmazonBedrockDocumentFormat {
  const format =
    BEDROCK_DOCUMENT_MIME_TYPES[mimeType as AmazonBedrockDocumentMimeType];
  if (!format) {
    throw new UnsupportedFunctionalityError({
      functionality: `file mime type: ${mimeType}`,
      message: `Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(', ')}`,
    });

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Convert the image to PNG or JPEG before sending (sharp/canvas on server, browser canvas API on client).
  2. Set an explicit supported mediaType on the image part instead of relying on inference.
  3. Check the error message's 'expected one of' list and match one of those MIME types.
  4. For SVG, rasterize it to PNG first — Bedrock cannot ingest vector images.

Example fix

// before
{ type: 'image', mediaType: 'image/svg+xml', data: svgBytes }
// after
const png = await sharp(svgBytes).png().toBuffer();
{ type: 'image', mediaType: 'image/png', data: png }
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_IMAGE = ['image/jpeg','image/png','image/gif','image/webp'];
if (!SUPPORTED_IMAGE.includes(imagePart.mediaType)) {
  imagePart = { ...imagePart, mediaType: 'image/png', data: await convertToPng(imagePart.data) };
}

Type guard

function isBedrockSupportedImage(mediaType) {
  return ['image/jpeg','image/png','image/gif','image/webp'].includes(mediaType);
}

Try / catch

try {
  return await generateText({ model, messages });
} catch (error) {
  if (UnsupportedFunctionalityError.isInstance(error) && error.message.includes('Unsupported image mime type')) {
    // convert images to PNG and retry once
    messages = await convertAllImagesToPng(messages);
    return generateText({ model, messages });
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing an image part with a mediaType outside {image/jpeg, image/png, image/gif, image/webp} — e.g. image/svg+xml, image/tiff, image/heic, or an empty/missing media type.

Common situations: Sending screenshots in HEIC from iOS, SVGs generated by tools, or TIFF scans; also occurs when mediaType is omitted so it defaults to something Bedrock cannot map.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/bc2186cb01a15718. Report an issue: GitHub.