vercel/ai · error · InvalidArgumentError
DeepSeek file uploads must not exceed 64 MiB (67108864 bytes
Error message
DeepSeek file uploads must not exceed 64 MiB (67108864 bytes). Received ${fileBytes.length.toLocaleString('en-US')} bytes. What it means
DeepSeek's file upload API rejects files larger than 64 MiB (67,108,864 bytes). validateFileUpload checks the byte length of the provided data before the HTTP request and throws InvalidArgumentError for argument 'data' so the failure is local and descriptive rather than a provider-side 4xx.
Source
Thrown at packages/deepseek/src/files/deepseek-files.ts:154
? { expiresAt: response.expires_at }
: {}),
},
},
};
}
}
function validateFileUpload({
fileBytes,
mediaType,
filename,
}: {
fileBytes: Uint8Array;
mediaType: string;
filename: string | undefined;
}) {
if (fileBytes.length > MAX_FILE_SIZE_BYTES) {
throw new InvalidArgumentError({
argument: 'data',
message:
`DeepSeek file uploads must not exceed 64 MiB ` +
`(${MAX_FILE_SIZE_BYTES.toLocaleString('en-US')} bytes). ` +
`Received ${fileBytes.length.toLocaleString('en-US')} bytes.`,
});
}
if (filename != null) {
const filenameLength = Array.from(filename).length;
if (filenameLength > MAX_FILENAME_LENGTH) {
throw new InvalidArgumentError({
argument: 'filename',
message:
`DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +
`Received ${filenameLength} characters.`,
});View on GitHub (pinned to 69428b1f8b)
Solutions
- Resize or recompress the image (e.g. sharp) until it is under 64 MiB before uploading.
- Check fileBytes.length client-side and reject/trim oversized files early.
- If large originals are required, store them elsewhere and upload a downscaled preview to DeepSeek.
Example fix
// before
await deepseek.files.upload({ data: rawCameraJpeg });
// after
if (rawCameraJpeg.length > 64 * 1024 * 1024) {
rawCameraJpeg = await sharp(Buffer.from(rawCameraJpeg)).resize({ width: 4000 }).jpeg({ quality: 80 }).toBuffer();
}
await deepseek.files.upload({ data: new Uint8Array(rawCameraJpeg) }); Defensive patterns
Strategy: validation
Validate before calling
const MAX = 64 * 1024 * 1024;
if (fileBytes.length > MAX) {
throw new Error(`File too large for DeepSeek upload: ${fileBytes.length} > ${MAX} bytes`);
} Try / catch
import { InvalidArgumentError } from '@ai-sdk/provider';
try {
await files.upload({ data: fileBytes, mediaType });
} catch (e) {
if (InvalidArgumentError.isInstance(e) && e.argument === 'data') {
// compress/resize then retry once
} else throw e;
} Prevention
- Check data.byteLength against 67108864 before any upload.
- Automatically resize images over a safe threshold (e.g. 8 MiB) at ingestion time.
- Log the original file size to catch sources that routinely produce oversized files.
When it happens
Trigger: Calling deepseek.files.upload (createFiles) with a file whose Uint8Array length exceeds 67108864 bytes.
Common situations: Uploading high-resolution photos straight from a camera or scanner, uploading videos or large PDFs, or batch-concatenated image data.
Related errors
- DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} ch
- DeepSeek file uploads support JPEG, PNG, GIF, and WebP image
- DeepSeek file uploads support JPEG, PNG, GIF, and WebP image
- DeepSeek file uploads support JPEG, PNG, GIF, and WebP image
- maxEmbeddingsPerCall must be greater than 0
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/fc1fcd5be1d61092.
Report an issue: GitHub.