ai icon indicating copy to clipboard operation
ai copied to clipboard

AI sdk v5 does not support text/plain as file part

Open niels-bosman opened this issue 1 year ago • 10 comments

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",

niels-bosman avatar Jul 18 '25 10:07 niels-bosman

Related:

https://github.com/vercel/ai/issues/6873

niels-bosman avatar Jul 18 '25 11:07 niels-bosman

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?

lgrammel avatar Jul 31 '25 07:07 lgrammel

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.

castortech avatar Jul 31 '25 08:07 castortech

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.

lawrencenika avatar Aug 12 '25 02:08 lawrencenika

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.

rohan-dave avatar Aug 15 '25 10:08 rohan-dave

I'm facing the same issue with csv file types as well.

levi-katarok avatar Aug 19 '25 23:08 levi-katarok

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.

matt-abstractai avatar Oct 06 '25 09:10 matt-abstractai

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

gr2m avatar Oct 10 '25 22:10 gr2m

closing as I don't think there is anything left to do. Feel free to create follow up issues

gr2m avatar Oct 28 '25 21:10 gr2m

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 FileUIPart with mediaType: 'text/plain' fails in AI SDK v5 despite the linked v5 documentation stating that text/* is supported.
  • Multiple commenters report that text/plain or CSV attachments worked through experimental_attachments in 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.

lgrammel avatar Jul 22 '26 14:07 lgrammel