vercel/ai · error · InvalidPromptError
DeepSeek `imageDetail` cannot be combined with `fileData`.
Error message
DeepSeek `imageDetail` cannot be combined with `fileData`.
What it means
DeepSeek's imageDetail provider option is incompatible with fileData mode. The SDK throws InvalidPromptError when both deepseek.fileData === true and deepseek.imageDetail are set on the same image part.
Source
Thrown at packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts:218
userContent.push({
type: 'image_url',
image_url: {
url,
...(filePartOptions?.imageDetail != null && {
detail: filePartOptions.imageDetail,
}),
},
});
} else {
const dataUrl = `data:${
resolvedMediaType === 'image/jpg'
? 'image/jpeg'
: resolvedMediaType
};base64,${convertToBase64(part.data.data)}`;
if (filePartOptions?.fileData === true) {
if (filePartOptions.imageDetail != null) {
throw new InvalidPromptError({
prompt,
message:
'DeepSeek `imageDetail` cannot be combined with `fileData`.',
});
}
userContent.push({
type: 'file',
file_data: dataUrl,
...(part.filename != null && { filename: part.filename }),
});
} else {
userContent.push({
type: 'image_url',
image_url: {
url: dataUrl,
...(filePartOptions?.imageDetail != null && {
detail: filePartOptions.imageDetail,View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove imageDetail from parts that set fileData: true
- Keep imageDetail only on inline-data/URL parts that do not use fileData
Example fix
// before
providerOptions: { deepseek: { fileData: true, imageDetail: 'high' } }
// after
providerOptions: { deepseek: { fileData: true } } Defensive patterns
Strategy: validation
Validate before calling
function assertNoImageDetailWithFileData(opts) {
if (opts?.deepseek?.fileData === true && opts?.deepseek?.imageDetail != null) {
throw new Error('imageDetail cannot be combined with fileData');
}
} Try / catch
try { ... } catch (e) { if (InvalidPromptError.isInstance(e) && /imageDetail/.test(e.message)) { /* strip imageDetail and retry */ } throw e; } Prevention
- Pick one mode per image part: fileData OR imageDetail
- Strip conflicting keys when copying provider options between parts
- Add an options schema/lint check in your prompt builder
When it happens
Trigger: Setting both options on one image part: providerOptions: { deepseek: { fileData: true, imageDetail: 'high' } }.
Common situations: Spreading a shared providerOptions object that includes imageDetail into parts that also enable fileData; migrating from URL-based parts (where imageDetail is meaningful) to fileData parts without removing imageDetail.
Related errors
- DeepSeek `fileData` image parts require inline data, not a U
- DeepSeek image media type ${resolvedMediaType}
- DeepSeek image URLs must not exceed 8192 characters.
- Unsupported image mime type: ${mimeType}, expected one of: $
- DeepSeek assistant prefix completion requires `prefix: true`
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/864a15548f1b0ef0.
Report an issue: GitHub.