vercel/ai · error · InvalidArgumentError

DeepSeek file uploads support JPEG, PNG, GIF, and WebP image

Error message

DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. Received unsupported media type "${mediaType}".

What it means

When the caller-supplied mediaType is not a supported image type and also not a recognized generic type (e.g. 'application/octet-stream'), the provider throws InvalidArgumentError for argument 'mediaType'. Supported uploads are JPEG, PNG, GIF, and WebP; generic types fall through to content sniffing, but anything else is rejected outright.

Source

Thrown at packages/deepseek/src/files/deepseek-files.ts:196

  if (
    detectedMediaType != null &&
    !supportedMediaTypes.has(detectedMediaType)
  ) {
    throw new InvalidArgumentError({
      argument: 'data',
      message:
        `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +
        `Detected unsupported file content type "${detectedMediaType}".`,
    });
  }

  if (supportedMediaTypes.has(normalizedMediaType)) {
    return;
  }

  if (!genericMediaTypes.has(normalizedMediaType)) {
    throw new InvalidArgumentError({
      argument: 'mediaType',
      message:
        `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +
        `Received unsupported media type "${mediaType}".`,
    });
  }

  if (detectedMediaType != null || hasSupportedFilenameExtension(filename)) {
    return;
  }

  throw new InvalidArgumentError({
    argument: 'mediaType',
    message:
      `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +
      `Provide a supported media type or a filename ending in ` +
      `.jpg, .jpeg, .png, .gif, or .webp. Received "${mediaType}".`,
  });

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Pass one of image/jpeg, image/png, image/gif, or image/webp as mediaType.
  2. Replace 'image/jpg' with 'image/jpeg' (a common typo that lands here).
  3. If the true type is unknown, pass a generic type like 'application/octet-stream' and provide a supported filename extension so sniffing can resolve it.

Example fix

// before
await files.upload({ data, mediaType: 'image/jpg' });

// after
await files.upload({ data, mediaType: 'image/jpeg', filename: 'photo.jpg' });
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/webp']);
const GENERIC = new Set(['application/octet-stream', 'application/binary']);
if (!SUPPORTED.has(mediaType) && !GENERIC.has(mediaType)) {
  throw new Error(`mediaType ${mediaType} not accepted by DeepSeek uploads; use image/jpeg|png|gif|webp`);
}

Try / catch

import { InvalidArgumentError } from '@ai-sdk/provider';
try {
  await files.upload({ data, mediaType, filename });
} catch (e) {
  if (InvalidArgumentError.isInstance(e) && e.argument === 'mediaType') {
    await files.upload({ data, mediaType: normalizeMediaType(mediaType), filename });
  } else throw e;
}

Prevention

When it happens

Trigger: Calling deepseek.files.upload with mediaType values like 'image/heic', 'video/mp4', 'text/plain', or a typo such as 'image/jpg'.

Common situations: Passing MIME types from an allowlist meant for another provider (HEIC from iOS uploads), typos in MIME strings ('image/jpg' is not a real type), or forwarding provider-specific types.

Related errors


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