vercel/ai · error · UnsupportedFunctionalityError
file parts with provider references
Error message
file parts with provider references
What it means
Perplexity's message format cannot express file parts whose data is a provider reference (a pointer to a previously uploaded/generated file). convertToPerplexityMessages throws UnsupportedFunctionalityError for part.data.type === 'reference' because there is no Perplexity representation to map it to.
Source
Thrown at packages/perplexity/src/convert-to-perplexity-messages.ts:49
(part.type === 'file' &&
getTopLevelMediaType(part.mediaType) === 'image') ||
(part.type === 'file' &&
getTopLevelMediaType(part.mediaType) === 'application'),
);
const messageContent = content
.map((part, index) => {
switch (part.type) {
case 'text': {
return {
type: 'text',
text: part.text,
};
}
case 'file': {
switch (part.data.type) {
case 'reference': {
throw new UnsupportedFunctionalityError({
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') {View on GitHub (pinned to 69428b1f8b)
Solutions
- Inline the actual file bytes as a data part (base64 data URL) instead of a reference
- Provide the file as a URL part that Perplexity can fetch
- Strip or convert reference file parts before calling Perplexity
Example fix
// before
{ type: 'file', data: { type: 'reference', fileId } }
// after
{ type: 'file', data: new URL('https://example.com/doc.pdf'), mediaType: 'application/pdf' } Defensive patterns
Strategy: validation
Validate before calling
for (const msg of messages) {
for (const part of msg.content) {
if (part.type === 'file' && part.data?.type === 'reference') {
throw new Error('Perplexity cannot consume file parts with provider references; inline data or use a URL');
}
}
} Type guard
function isReferencedFilePart(part: { type: string; data?: { type?: string } }): boolean {
return part.type === 'file' && part.data?.type === 'reference';
} Try / catch
try {
await generateText({ model: perplexity('sonar-pro'), messages });
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e) && e.message.includes('provider references')) {
// rebuild messages with inlined data/URL file parts
} else throw e;
} Prevention
- Resolve provider file references to concrete data/URLs before dispatching to Perplexity
- Sanitize shared message histories per target provider
- Avoid persisting provider-specific file references in provider-agnostic histories
When it happens
Trigger: Sending a prompt whose messages contain a file part created with a provider-generated reference (e.g. data from a prior generateImage/file upload returned as { type: 'reference', ... }) to a perplexity.chat(...) model.
Common situations: Chaining outputs between providers (OpenAI file ids or previously generated assets passed to Perplexity); reusing a shared message history that includes provider-specific file references.
Related errors
- text file parts
- file part media type ${fullMediaType}
- 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/40f887ca59580227.
Report an issue: GitHub.