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

  1. Remove imageDetail from parts that set fileData: true
  2. 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

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


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/864a15548f1b0ef0. Report an issue: GitHub.