{"record":{"id":"c34f272e3e0a9c93","repo":"vercel/ai","slug":"text-file-parts-functionality-not-supported-c34f27","errorCode":null,"errorMessage":"'text file parts' functionality not supported.","messagePattern":"'text file parts' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/xai/src/responses/convert-to-xai-responses-input.ts","lineNumber":65,"sourceCode":"            case 'text': {\n              contentParts.push({ type: 'input_text', text: block.text });\n              break;\n            }\n\n            case 'file': {\n              switch (block.data.type) {\n                case 'reference': {\n                  contentParts.push({\n                    type: 'input_file',\n                    file_id: resolveProviderReference({\n                      reference: block.data.reference,\n                      provider: 'xai',\n                    }),\n                  });\n                  break;\n                }\n                case 'text': {\n                  throw new UnsupportedFunctionalityError({\n                    functionality: 'text file parts',\n                  });\n                }\n                case 'url':\n                case 'data': {\n                  if (getTopLevelMediaType(block.mediaType) === 'image') {\n                    const imageUrl =\n                      block.data.type === 'url'\n                        ? block.data.url.toString()\n                        : `data:${resolveFullMediaType({ part: block })};base64,${convertToBase64(block.data.data)}`;\n\n                    const filePartOptions = await parseProviderOptions({\n                      provider: 'xai',\n                      providerOptions: block.providerOptions,\n                      schema: xaiFilePartProviderOptions,\n                    });\n\n                    contentParts.push({","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/xai/src/responses/convert-to-xai-responses-input.ts#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncontent: [{ type: 'file', data: { type: 'text', text: doc }, mediaType: 'text/plain' }]\n// after\ncontent: [{ type: 'text', text: doc }]","handlingStrategy":"validation","validationCode":"const hasTextFilePart = prompt.some(m => m.content.some(p => p.type === 'file' && p.data.type === 'text'));\nif (hasTextFilePart) throw new Error('convert text file parts to plain text parts for xai');","typeGuard":"function isTextFilePart(p: unknown): boolean {\n  return typeof p === 'object' && p !== null && (p as any).type === 'file' && (p as any).data?.type === 'text';\n}","tryCatchPattern":"try {\n  await generateText({ model, prompt });\n} catch (e) {\n  if ((e as any).name === 'AI_UnsupportedFunctionalityError' && (e as Error).message.includes('text file parts')) {\n    // fall back to text-part rendering of the file content\n  }\n}","preventionTips":["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"],"tags":["xai","unsupported-functionality","file-parts","responses-api"],"backgroundTag":"unsupported-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}