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
- Pass one of image/jpeg, image/png, image/gif, or image/webp as mediaType.
- Replace 'image/jpg' with 'image/jpeg' (a common typo that lands here).
- 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
- Normalize MIME types before upload ('image/jpg' -> 'image/jpeg').
- Restrict upload inputs to the four supported image MIME types.
- Share one media-type whitelist constant across your upload paths.
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
- DeepSeek file uploads support JPEG, PNG, GIF, and WebP image
- DeepSeek file uploads support JPEG, PNG, GIF, and WebP image
- DeepSeek file uploads must not exceed 64 MiB (67108864 bytes
- DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} ch
- maxEmbeddingsPerCall must be greater than 0
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/b204bd80a1252d54.
Report an issue: GitHub.