AI sdk v5 does not support text/plain as file part
Description
With the following code:
const files: FileUIPart[] = attachmentData.map(({ name, text }) => ({
type: 'file',
filename: name,
mediaType: 'text/plain',
url: `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`,
}));
chat.sendMessage(
{ text: message, files: files.length > 0 ? files : undefined },
);
I get the following error:
[Error [AI_UnsupportedFunctionalityError]: 'file part media type text/plain' functionality not supported.] {
cause: undefined,
functionality: 'file part media type text/plain'
}
The documentation for v5 says text/* is supported, is it not?
https://v5.ai-sdk.dev/docs/ai-sdk-ui/chatbot#filelist
AI SDK Version
"@ai-sdk/azure": "2.0.0-beta.10", "@ai-sdk/react": "2.0.0-beta.23", "ai": "5.0.0-beta.23",
Related:
https://github.com/vercel/ai/issues/6873
What is supported depends on the LLM / provider that you are using. Not all LLMs support text/plain, text/csv etc parts. Can you provide a full reproduction and information about the provider that you are using?
IMHO this begs the question why basic types such as text/plain, text/csv or Markdown that are all text based cannot be automatically "casted" as text content if there is no specific file part handler in the LLM. After crash and burn trying to use FilePart we had to just do that on our own. Also a mechanism by which we can also query for supported type by provider/model would make it much more natural to use FileParts.
Having the same error here for using text/plain as mediaType for FileUIPart, the same worked for experimental_attachments in v4.2 but not in v5 anymore.
I am also experiencing similar error for PDF files as signed URLs using AI SDK v5, AI Gateway with GPT-4o.
Error: AI_UnsupportedFunctionalityError PDF file parts with URLs' functionality not supported.
Seems pretty high-priority since we can't send more than 4.5MB as data URI due to vercel functions data payload limitations.
I'm facing the same issue with csv file types as well.
Commented on related issue that this is still not working with 5.0.60.
Using Azure Open AI and Open AI models in V4 I was sending experimental_attachments with text/plain content type and base64 data urls which was working fine.
Commented on related issue that this is still not working with 5.0.60.
Using Azure Open AI and Open AI models in V4 I was sending experimental_attachments with text/plain content type and base64 data urls which was working fine.
in v4 it was a universal implementation, but not all models support text/plain file types, so now the support depends on the provider models.
We recommend to type: 'text' instead, see https://github.com/vercel/ai/pull/9295/files
closing as I don't think there is anything left to do. Feel free to create follow up issues
Identify issue type
Identified as Bug
Confidence: Medium
Rationale
The issue reports a concrete v5 regression and behavior that appears to contradict the documented file support, even though maintainers later described the provider-dependent behavior as intentional and supplied a workaround.
Evidence
- Using a
FileUIPartwithmediaType: 'text/plain'fails in AI SDK v5 despite the linked v5 documentation stating thattext/*is supported. - Multiple commenters report that
text/plainor CSV attachments worked throughexperimental_attachmentsin v4 but fail in v5. - Maintainers clarified that v5 delegates file-type support to the provider/model and recommended sending the content as
type: 'text'instead.