vercel/ai · error · UnsupportedFunctionalityError
file part media type ${fullMediaType}
Error message
file part media type ${fullMediaType} What it means
Perplexity file support is effectively limited to PDFs. When a file part's resolved full media type is anything other than application/pdf, convertToPerplexityMessages throws UnsupportedFunctionalityError naming the offending media type, because Perplexity cannot ingest it (images must be sent as image parts, not file parts).
Source
Thrown at packages/perplexity/src/convert-to-perplexity-messages.ts:68
functionality: 'file parts with provider references',
});
}
case 'text': {
throw new UnsupportedFunctionalityError({
functionality: 'text file parts',
});
}
case 'url':
case 'data': {
const topLevelMediaType = getTopLevelMediaType(
part.mediaType,
);
if (topLevelMediaType === 'application') {
const fullMediaType = resolveFullMediaType({ part });
if (fullMediaType !== 'application/pdf') {
throw new UnsupportedFunctionalityError({
functionality: `file part media type ${fullMediaType}`,
});
}
return part.data.type === 'url'
? {
type: 'file_url',
file_url: {
url: part.data.url.toString(),
},
file_name: part.filename,
}
: {
type: 'file_url',
file_url: {
url:
typeof part.data.data === 'string'
? part.data.dataView on GitHub (pinned to 69428b1f8b)
Solutions
- Convert the document to PDF before sending it to Perplexity
- Send images as image parts ({ type: 'image', ... }) rather than file parts
- Filter or reject non-PDF attachments in your app before invoking the model
Example fix
// before
{ type: 'file', data: new URL('https://example.com/shot.png'), mediaType: 'image/png' }
// after
{ type: 'image', image: new URL('https://example.com/shot.png') } Defensive patterns
Strategy: validation
Validate before calling
for (const part of msg.content) {
if (part.type === 'file') {
const mediaType = part.mediaType ?? '';
if (mediaType !== 'application/pdf') {
throw new Error(`Perplexity only supports PDF file parts, got ${mediaType}`);
}
}
} Type guard
function isPdfFilePart(part: { type: string; mediaType?: string }): part is { type: 'file'; mediaType: 'application/pdf' } {
return part.type === 'file' && part.mediaType === 'application/pdf';
} Try / catch
try {
await generateText({ model: perplexity('sonar-pro'), messages });
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e) && e.message.includes('file part media type')) {
// convert to PDF, route as image part, or drop the attachment
} else throw e;
} Prevention
- Whitelist PDF as the only file media type sent to Perplexity
- Send images as image parts, never as file parts
- Convert Office/CSV documents to PDF server-side before attaching
- Validate attachment media types at upload time in your app
When it happens
Trigger: Sending a file part with a media type such as image/png, application/msword, text/csv, or audio/* (anything non-PDF) to a Perplexity chat model, including via URL or data parts.
Common situations: Uploading images as file parts instead of image parts; passing Office/CSV documents that only some providers accept; dynamically chosen attachments where media type is not filtered before dispatch.
Related errors
- file parts with provider references
- text file parts
- AI_UnsupportedFunctionalityError
- file parts with provider references
- File URL data
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/2ff275f707242147.
Report an issue: GitHub.