ai icon indicating copy to clipboard operation
ai copied to clipboard

Support for csv or xlsx mediatype in messages

Open Shinchan3102 opened this issue 1 year ago • 10 comments

Description

On uploading a file of type text/csv or .xlsx format in the chat it is currently giving me error that the mediatype isn't supported yet

Image

AI SDK Version

  • "ai": "5.0.0-beta.3"
  • "@ai-sdk/openai": "2.0.0-beta.3"
  • "@ai-sdk/google-vertex": "3.0.0-beta.5"
  • "@ai-sdk/anthropic": "2.0.0-beta.3"
  • "@ai-sdk/react": "2.0.0-beta.3"

Shinchan3102 avatar Jul 08 '25 07:07 Shinchan3102

The media types depend on the capabilities of the provider API. Can you show me where OpenAI supports csv/xlsx ?

lgrammel avatar Jul 08 '25 08:07 lgrammel

I am using google vertex anthropic model for the messages part and I guess there is a support of csv parsing in direct anthropic api but not sure for the google vertex wrapper

Shinchan3102 avatar Jul 08 '25 08:07 Shinchan3102

Any updates ? having the same issue

Yair-Ohana avatar Aug 28 '25 14:08 Yair-Ohana

Actually, Anthropic "supports it", but the way it's being implemented so far does not leverage the files API https://docs.anthropic.com/en/docs/build-with-claude/files - which is needed indeed to be able to pass CSV files alongside the code execution tool : https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/code-execution-tool

Files are always passed again & again (from what I understand - using cache control though) - but does not allow to leverage this feature.

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

I see there is already a discussion about it, maybe a way to reference already uploaded files could be a solution !

qchuchu avatar Sep 12 '25 09:09 qchuchu

External contributor here:

I can open a PR to allow for the passing of file ids from the files API. If someone confirms that this would be helpful for them, I'll prioritizing opening one in a few days. This is not to be confused with upload functionality.

My current thinking is that it should be established as a file prefix according to the conventions established in #7915

Edit: Since .csv and other files are only supported through container_upload, this would require more impactful changes. Support for pdf and image through files API would be as simple as described above though.

psinha40898 avatar Sep 12 '25 17:09 psinha40898

I can confirm that it would be really helpful ! I can also contribute too. I understood the logic in the convention, thanks for sharing. I guess I could mimic it too :)

qchuchu avatar Sep 12 '25 17:09 qchuchu

You should go for it and just lmk if your plans change but still want the feature

psinha40898 avatar Sep 12 '25 17:09 psinha40898

Thanks for raising this issue.

I’d like to add some additional context regarding the current OpenAI API capabilities, which may support expanding the allowed media types here.

According to the official OpenAI documentation for file inputs: https://platform.openai.com/docs/guides/file-inputs

Spreadsheet formats such as the following are explicitly listed as supported input types:

  • .csv (MIME: text/csv)
  • .xls
  • .xlsx (MIME: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)

Allowing these spreadsheet media types in @ai-sdk/openai would help align the SDK with the provider's documented functionality and make it easier to pass structured data (especially CSV/XLSX) directly to models without additional preprocessing.

As a small additional note: the same OpenAI documentation also lists common document formats such as .docx and .pptx as supported file inputs. Supporting those MIME types as well would be very helpful for document-oriented workflows.

Of course, this suggestion is specifically about the OpenAI provider — other providers may have different supported file types.

Thanks again for the work on the AI SDK!

takeaki-m avatar Mar 17 '26 02:03 takeaki-m

any updates? any workaround?

filoscoder avatar May 29 '26 12:05 filoscoder

Identify issue type

Identified type: Feature
Confidence: High

Rationale: The report requests expanding supported file/media types and provider file-input capabilities rather than showing that an already promised AI SDK behavior is broken.

Evidence:

  • The issue asks for support for text/csv and .xlsx media types in chat messages, which currently return an unsupported media type error.
  • Maintainer notes media type support depends on provider API capabilities and asks where the provider supports CSV/XLSX.
  • Later comments discuss adding support via Anthropic/OpenAI files APIs and allowing spreadsheet MIME types in @ai-sdk/openai.

lgrammel avatar Jul 02 '26 09:07 lgrammel