vercel/ai · error · UnsupportedFunctionalityError
'text file parts' functionality not supported.
Error message
'text file parts' functionality not supported.
What it means
xAI does not accept file parts whose data payload is text (i.e. a file part whose content is inline text rather than binary/reference). When converting file blocks for the Responses API, a 'text' data case throws UnsupportedFunctionalityError because there is no valid xAI representation.
Source
Thrown at packages/xai/src/responses/convert-to-xai-responses-input.ts:65
case 'text': {
contentParts.push({ type: 'input_text', text: block.text });
break;
}
case 'file': {
switch (block.data.type) {
case 'reference': {
contentParts.push({
type: 'input_file',
file_id: resolveProviderReference({
reference: block.data.reference,
provider: 'xai',
}),
});
break;
}
case 'text': {
throw new UnsupportedFunctionalityError({
functionality: 'text file parts',
});
}
case 'url':
case 'data': {
if (getTopLevelMediaType(block.mediaType) === 'image') {
const imageUrl =
block.data.type === 'url'
? block.data.url.toString()
: `data:${resolveFullMediaType({ part: block })};base64,${convertToBase64(block.data.data)}`;
const filePartOptions = await parseProviderOptions({
provider: 'xai',
providerOptions: block.providerOptions,
schema: xaiFilePartProviderOptions,
});
contentParts.push({View on GitHub (pinned to 69428b1f8b)
Solutions
- Send the content as a plain text part instead of a file part
- Upload the document to xAI's Files API and pass a provider reference (file_id) in the file part
- Use a data/url file part with an image media type if the content is an image
Example fix
// before
content: [{ type: 'file', data: { type: 'text', text: doc }, mediaType: 'text/plain' }]
// after
content: [{ type: 'text', text: doc }] Defensive patterns
Strategy: validation
Validate before calling
const hasTextFilePart = prompt.some(m => m.content.some(p => p.type === 'file' && p.data.type === 'text'));
if (hasTextFilePart) throw new Error('convert text file parts to plain text parts for xai'); Type guard
function isTextFilePart(p: unknown): boolean {
return typeof p === 'object' && p !== null && (p as any).type === 'file' && (p as any).data?.type === 'text';
} Try / catch
try {
await generateText({ model, prompt });
} catch (e) {
if ((e as any).name === 'AI_UnsupportedFunctionalityError' && (e as Error).message.includes('text file parts')) {
// fall back to text-part rendering of the file content
}
} Prevention
- Never wrap raw text as file parts
- Check provider capability docs before porting prompts across providers
- Normalize file parts to text/reference/data-url forms in a preprocessing step
When it happens
Trigger: Building a prompt with a file part whose data is of type 'text' (content: [{ type: 'file', data: { type: 'text', ... } }]) and calling generateText/streamText with an xai responses model.
Common situations: Piping documents retrieved as raw text into file parts; porting prompts from another provider that supports text file parts; dynamically generated file content typed as text.
Related errors
- 'file part media type ${block.mediaType} as inline data (xAI
- AI_UnsupportedFunctionalityError
- file parts with provider references
- File URL data
- allowedTools with only tools that cannot be allow-listed (${
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/c34f272e3e0a9c93.
Report an issue: GitHub.