amazon bedrock package incorrectly extracting mimetype from files
Description
When I send a XLXS file to amazon bedrock (using model claude 3.7) using the amazon-bedrock package, i get the following error:
validation errors detected: Value at 'messages.3.member.content.3.member.document.format' failed to satisfy constraint:
Member must satisfy enum value set: [docx, csv, html, txt, pdf, md, doc, xlsx, xls];
I think this happens here where you are extracting the mimetype:
bedrockContent.push({
document: {
format: part.mimeType?.split(
'/',
)?.[1] as BedrockDocumentFormat,
name: generateFileId(),
source: {
bytes: part.data,
},
},
});
Additionally i think the BedrockDocumentFormat type is overly strict with only 3 file types supported. These are the supported types from amazon bedrocks api reference: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_DocumentBlock.html
Code example
No response
AI provider
@ai-sdk/amazon-bedrock 2.2.4
Additional context
No response
We're experiencing the same with .docx files. .pdf files works fine. I guess this supports the hunch of it being due to the code you're referencing, given that these are the mimetypes we use:
// file extension: mimetype
{
'.pdf': 'application/pdf',
'.doc': 'application/msword',
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
}
vnd.openxmlformats-officedocument.wordprocessingml.document is not the correct value to send as format.
as of 2025-06-11, using versions @ai-sdk/[email protected] and [email protected], this bug still exists. Luckily, @christian-bromann 's PR, https://github.com/vercel/ai/pull/6185, fixes the issue, but has not been reviewed for over a month.
I know Amazon Bedrock might not be as flashy as other providers, but it’s still a popular choice for enterprise LLM workloads, and this feature not working as expected hurts the AI SDK's perceived viability for new enterprise customers.
It would be great if the PR would get a review and be merged. 😇
+1 faced this issue with .txt with AI SDK v5 alpha 15
[Error [AI_APICallError]: undefined: 1 validation error detected: Value at 'messages.5.member.content.1.member.document.format' failed to satisfy constraint: Member must satisfy enum value set: [docx, csv, html, txt, pdf, md, doc, xlsx, xls]] {
cause: undefined,
url: 'https://bedrock-runtime.us-west-2.amazonaws.com/model/us.anthropic.claude-sonnet-4-20250514-v1%3A0/converse-stream',
requestBodyValues: [Object],
statusCode: 400,
responseHeaders: [Object],
responseBody: `{"message":"1 validation error detected: Value at 'messages.5.member.content.1.member.document.format' failed to satisfy constraint: Member must satisfy enum value set: [docx, csv, html, txt, pdf, md, doc, xlsx, xls]"}`,
isRetryable: false,
data: [Object]
}
maybe @dancer can help on this in order to fix it for next alpha releases of v5
+1 faced this issue with .txt with AI SDK v5 alpha 15
Did you get that error with testing the PR or from the main branch? I hadn't tested with the v5 yet
@brianprost tested without the PR, but with latest v5 alpha release
thank you for the ping will look into this now and check the pr
just wanted to check does this issue still occur in aisdk v5 beta if someone could let me know @arthberman @brianprost
@dancer yes it occurs with v5 beta too. Thks!
fixing now
mb took a while, landed there now will be part of our next beta release
ty for being patient