vercel/ai · error · UnsupportedFunctionalityError
Only images and PDF file parts are supported
Error message
Only images and PDF file parts are supported
What it means
For inline (data) file parts, Mistral only accepts images and application/pdf. convertToMistralChatMessages resolves the full media type and throws UnsupportedFunctionalityError when a base64 data file part is not a PDF (and not an image, which is handled on another branch).
Source
Thrown at packages/mistral/src/convert-to-mistral-chat-messages.ts:79
case 'text': {
throw new UnsupportedFunctionalityError({
functionality: 'text file parts',
});
}
case 'url':
case 'data': {
const topLevel = getTopLevelMediaType(part.mediaType);
if (topLevel === 'image') {
return {
type: 'image_url',
image_url: formatFileUrl({ part }),
};
} else {
if (part.data.type === 'data') {
const fullMediaType = resolveFullMediaType({ part });
if (fullMediaType !== 'application/pdf') {
throw new UnsupportedFunctionalityError({
functionality:
'Only images and PDF file parts are supported',
});
}
} else if (part.mediaType !== 'application/pdf') {
throw new UnsupportedFunctionalityError({
functionality:
'Only images and PDF file parts are supported',
});
}
return {
type: 'document_url',
document_url: formatFileUrl({ part }),
};
}
}
}View on GitHub (pinned to 69428b1f8b)
Solutions
- Convert the document to PDF before sending it inline.
- Send only images or PDFs as data file parts to Mistral.
- Extract the text and send it as a text part instead.
- Use a provider that supports the given media type.
Example fix
// before
{ type: 'file', mediaType: 'application/msword', data: { type: 'data', data: bytes } }
// after: convert to PDF first
{ type: 'file', mediaType: 'application/pdf', data: { type: 'data', data: pdfBytes } } Defensive patterns
Strategy: validation
Validate before calling
function isMistralInlineData(part: { type: string; mediaType: string; data: { type: string } }): boolean {
if (part.type !== 'file' || part.data.type !== 'data') return true;
return part.mediaType.startsWith('image/') || part.mediaType === 'application/pdf';
}
// assert before sending
content.forEach(p => { if (!isMistralInlineData(p)) throw new Error('Convert to PDF or image for Mistral'); }); Type guard
function isMistralSupportedMediaType(mediaType: string): boolean {
return mediaType.startsWith('image/') || mediaType === 'application/pdf';
} Try / catch
try {
await generateText({ model: mistral(modelId), messages });
} catch (error) {
if (UnsupportedFunctionalityError.isInstance(error) &&
error.functionality.includes('Only images and PDF')) {
// convert document to PDF, or extract text, then retry
} else {
throw error;
}
} Prevention
- Restrict upload UIs to images and PDFs when targeting Mistral.
- Convert office/audio/archive files to PDF or text upstream.
- Assert media types in a shared prompt-validation helper.
When it happens
Trigger: Sending a file part with data.type === 'data' (base64) whose resolved media type is neither an image nor 'application/pdf' (e.g. application/msword, audio, zip) to a Mistral chat model.
Common situations: Attaching Word/Excel/CSV or audio files as base64 file parts; generic document-upload features routed to Mistral without media-type checks.
Related errors
- file part data type ${part.data.type}
- text file parts
- file parts with provider references
- file part media type ${fullMediaType}
- 'element streams in no-schema mode' functionality not suppor
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/50640b953a39fe3f.
Report an issue: GitHub.