{"record":{"id":"fc1fcd5be1d61092","repo":"vercel/ai","slug":"deepseek-file-uploads-must-not-exceed-64-mib-6710","errorCode":null,"errorMessage":"DeepSeek file uploads must not exceed 64 MiB (67108864 bytes). Received ${fileBytes.length.toLocaleString('en-US')} bytes.","messagePattern":"DeepSeek file uploads must not exceed 64 MiB \\(67108864 bytes\\)\\. Received (.+?) bytes\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/files/deepseek-files.ts","lineNumber":154,"sourceCode":"            ? { expiresAt: response.expires_at }\n            : {}),\n        },\n      },\n    };\n  }\n}\n\nfunction validateFileUpload({\n  fileBytes,\n  mediaType,\n  filename,\n}: {\n  fileBytes: Uint8Array;\n  mediaType: string;\n  filename: string | undefined;\n}) {\n  if (fileBytes.length > MAX_FILE_SIZE_BYTES) {\n    throw new InvalidArgumentError({\n      argument: 'data',\n      message:\n        `DeepSeek file uploads must not exceed 64 MiB ` +\n        `(${MAX_FILE_SIZE_BYTES.toLocaleString('en-US')} bytes). ` +\n        `Received ${fileBytes.length.toLocaleString('en-US')} bytes.`,\n    });\n  }\n\n  if (filename != null) {\n    const filenameLength = Array.from(filename).length;\n\n    if (filenameLength > MAX_FILENAME_LENGTH) {\n      throw new InvalidArgumentError({\n        argument: 'filename',\n        message:\n          `DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +\n          `Received ${filenameLength} characters.`,\n      });","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/files/deepseek-files.ts#L136-L172","documentation":"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.","triggerScenarios":"Calling deepseek.files.upload (createFiles) with a file whose Uint8Array length exceeds 67108864 bytes.","commonSituations":"Uploading high-resolution photos straight from a camera or scanner, uploading videos or large PDFs, or batch-concatenated image data.","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."],"exampleFix":"// before\nawait deepseek.files.upload({ data: rawCameraJpeg });\n\n// after\nif (rawCameraJpeg.length > 64 * 1024 * 1024) {\n  rawCameraJpeg = await sharp(Buffer.from(rawCameraJpeg)).resize({ width: 4000 }).jpeg({ quality: 80 }).toBuffer();\n}\nawait deepseek.files.upload({ data: new Uint8Array(rawCameraJpeg) });","handlingStrategy":"validation","validationCode":"const MAX = 64 * 1024 * 1024;\nif (fileBytes.length > MAX) {\n  throw new Error(`File too large for DeepSeek upload: ${fileBytes.length} > ${MAX} bytes`);\n}","typeGuard":null,"tryCatchPattern":"import { InvalidArgumentError } from '@ai-sdk/provider';\ntry {\n  await files.upload({ data: fileBytes, mediaType });\n} catch (e) {\n  if (InvalidArgumentError.isInstance(e) && e.argument === 'data') {\n    // compress/resize then retry once\n  } else throw e;\n}","preventionTips":["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."],"tags":["file-upload","size-limit","validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}