vercel/ai · error · UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
Error message
'file part data type ${part.data.type}' functionality not supported. What it means
formatImageUrl converts AI SDK file parts into data URLs for Alibaba messages. Only 'url' and 'data' (binary) part types are convertible; any other part.data.type (e.g. a new or provider-specific kind) reaches the final throw of UnsupportedFunctionalityError.
Source
Thrown at packages/alibaba/src/convert-to-alibaba-chat-messages.ts:23
} from '@ai-sdk/provider';
import {
convertToBase64,
getTopLevelMediaType,
resolveFullMediaType,
} from '@ai-sdk/provider-utils';
import type { AlibabaChatPrompt } from './alibaba-chat-prompt';
import type { CacheControlValidator } from './get-cache-control';
function formatImageUrl({ part }: { part: LanguageModelV4FilePart }): string {
if (part.data.type === 'url') {
return part.data.url.toString();
}
if (part.data.type === 'data') {
return `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`;
}
throw new UnsupportedFunctionalityError({
functionality: `file part data type ${part.data.type}`,
});
}
export function convertToAlibabaChatMessages({
prompt,
cacheControlValidator,
}: {
prompt: LanguageModelV4Prompt;
cacheControlValidator?: CacheControlValidator;
}): AlibabaChatPrompt {
const messages: AlibabaChatPrompt = [];
for (const { role, content, ...message } of prompt) {
const messageCacheControl = cacheControlValidator?.getCacheControl(
message.providerOptions,
);
View on GitHub (pinned to 69428b1f8b)
Solutions
- Send file parts with { type: 'url' } or raw binary { type: 'data' } (Uint8Array) instead
- Strip or convert reference-type parts before the call
- Update @ai-sdk/alibaba in case a newer core introduced the new part type
Example fix
// before
content: [{ type: 'file', data: { type: 'reference', reference: fileRef }, mediaType: 'image/png' }]
// after
content: [{ type: 'file', data: { type: 'url', url: 'https://.../img.png' }, mediaType: 'image/png' }] Defensive patterns
Strategy: validation
Validate before calling
prompt.forEach(m => m.content.forEach(p => {
if (p.type === 'file' && p.data.type !== 'url' && p.data.type !== 'data') throw new Error('Unsupported file part data type');
})); Type guard
function isConvertibleFilePart(p: any): boolean {
return p?.type === 'file' && (p.data?.type === 'url' || p.data?.type === 'data');
} Try / catch
try {
await streamText({ model: alibabaModel, messages });
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e) && e.functionality.startsWith('file part data type')) {
// rebuild messages with url/data file parts
}
} Prevention
- Normalize file parts to url or data types in cross-provider pipelines
- Strip provider-specific references before sending to Alibaba
- Add prompt sanitization when routing shared conversation state across providers
When it happens
Trigger: Passing a message file part whose data.type is neither 'url' nor 'data' — e.g. { type: 'reference' } routed through formatImageUrl or a future/unknown part kind — while converting the prompt for Alibaba chat.
Common situations: Forwarding provider-specific file references (e.g. from another provider's response) into an Alibaba request, or SDK version skew introducing new file part data types.
Related errors
- file parts with provider references
- File URL data
- media type: ${part.mediaType}
- file parts with provider references
- text file parts
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/3c3061697c041510.
Report an issue: GitHub.