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. Detected unsupported file content type "${detectedMediaType}". What it means
The provider sniffs the actual bytes of the upload (detectMediaType) and rejects files whose detected content is not one of the supported image types (JPEG, PNG, GIF, WebP), throwing InvalidArgumentError for argument 'data'. This catches cases where the declared mediaType does not match the real content, e.g. a PDF or text file labeled as an image.
Source
Thrown at packages/deepseek/src/files/deepseek-files.ts:183
if (filenameLength > MAX_FILENAME_LENGTH) {
throw new InvalidArgumentError({
argument: 'filename',
message:
`DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +
`Received ${filenameLength} characters.`,
});
}
}
const normalizedMediaType = normalizeMediaType(mediaType);
const detectedMediaType = detectMediaType({ data: fileBytes });
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}".`,
});View on GitHub (pinned to 69428b1f8b)
Solutions
- Only upload JPEG, PNG, GIF, or WebP image data to DeepSeek files.
- Convert unsupported content (e.g. PDF pages, HEIC, TIFF) to PNG/JPEG before uploading.
- Detect the content type yourself first (or fix the source of mislabeled data) so you can fail with a friendlier message.
Example fix
// before
await files.upload({ data: pdfBytes, mediaType: 'application/pdf' });
// after
// convert first page to an image, e.g. with pdf-to-image / sharp
const png = await renderPdfPageToPng(pdfBytes, 0);
await files.upload({ data: png, mediaType: 'image/png', filename: 'page-1.png' }); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/webp']);
const detected = detectMediaType({ data: fileBytes });
if (detected && !SUPPORTED.has(detected)) {
throw new Error(`Unsupported upload content: ${detected}. Convert to JPEG/PNG/GIF/WebP first.`);
} Try / catch
import { InvalidArgumentError } from '@ai-sdk/provider';
try {
await files.upload({ data: fileBytes, mediaType });
} catch (e) {
if (InvalidArgumentError.isInstance(e) && e.argument === 'data') {
// convert content to a supported image type before retrying
} else throw e;
} Prevention
- Whitelist image inputs at the application boundary before they reach the upload code.
- Never trust declared mediaType for documents/videos; sniff or enforce extensions.
- Provide a conversion path (PDF->PNG, HEIC->JPEG) for common non-image inputs.
When it happens
Trigger: Uploading to deepseek.files.upload a file whose magic-byte signature detects as an unsupported type (PDF, MP4, SVG, text, etc.), regardless of the mediaType argument.
Common situations: Passing documents (PDFs) or videos to a files API that only accepts images, or mislabeled uploads where the extension/mediaType says PNG but the payload is something else.
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/7cc9b11e6d485f52.
Report an issue: GitHub.