Support for csv or xlsx mediatype in messages
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
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"
The media types depend on the capabilities of the provider API. Can you show me where OpenAI supports csv/xlsx ?
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
Any updates ? having the same issue
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 !
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.
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 :)
You should go for it and just lmk if your plans change but still want the feature
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!
any updates? any workaround?
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/csvand.xlsxmedia 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.