vercel/ai · error · UnsupportedFunctionalityError
file parts with provider references
Error message
file parts with provider references
What it means
File parts whose data is a provider reference (a previously uploaded file referenced by provider-specific ID) have no representation in the Bedrock chat payload, so the converter throws UnsupportedFunctionalityError with 'file parts with provider references'.
Source
Thrown at packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts:227
guardContent: {
text: {
text: part.text,
qualifiers: textOptions.guardContentQualifiers,
},
},
});
} else {
amazonBedrockContent.push({
text: part.text,
});
}
break;
}
case 'file': {
switch (part.data.type) {
case 'reference': {
throw new UnsupportedFunctionalityError({
functionality: 'file parts with provider references',
});
}
case 'url': {
if (part.data.url.protocol !== 's3:') {
throw new UnsupportedFunctionalityError({
functionality: 'File URL data',
});
}
const fullMediaType = resolveFullMediaType({ part });
switch (getTopLevelMediaType(fullMediaType)) {
case 'image': {
amazonBedrockContent.push({
image: {
format:
getAmazonBedrockImageFormat(fullMediaType),View on GitHub (pinned to 69428b1f8b)
Solutions
- Send the file as raw binary data instead: use a Uint8Array/Buffer in the file part's data.
- For S3-hosted files, use a URL part with an s3: protocol URL.
- Convert provider references to actual bytes before calling the Bedrock model.
Example fix
// before
{ type: 'file', data: new Uint8Array(...), mediaType: 'application/pdf' } // ok
{ type: 'file', data: { type: 'reference', fileId: 'file-abc' } } // throws
// after
const bytes = await fetchStoredFileBytes('file-abc');
{ type: 'file', data: bytes, mediaType: 'application/pdf' } Defensive patterns
Strategy: validation
Validate before calling
function assertNoFileReferences(messages) {
for (const m of messages) {
const parts = Array.isArray(m.content) ? m.content : [];
for (const p of parts) {
if (p.type === 'file' && p.data?.type === 'reference') {
throw new Error('Bedrock cannot consume file parts by reference; send raw bytes or an s3:// URL.');
}
}
}
} Type guard
function isFileReference(part: any): part is { type: 'file'; data: { type: 'reference'; fileId: string } } {
return part?.type === 'file' && part?.data?.type === 'reference';
} Try / catch
try {
await streamText({ model: bedrock(modelId), messages });
} catch (error) {
if (UnsupportedFunctionalityError.isInstance(error) && error.functionality.includes('provider references')) {
// resolve reference to bytes and rebuild the message
} else {
throw error;
}
} Prevention
- Resolve provider file references to raw bytes before dispatching to any provider-agnostic pipeline.
- Keep per-provider capability checks when routing shared message arrays to different models.
- Prefer binary data or s3:// URLs for Bedrock file inputs from the start.
When it happens
Trigger: Sending a message containing a file part with `data: { type: 'reference' }` (e.g. a file stored/uploaded via another provider's file API) to a Bedrock model via generateText/streamText.
Common situations: Reusing prompts built for OpenAI file IDs; multi-provider apps sharing message arrays that contain references; tool results carrying provider file references.
Related errors
- File URL data
- AI_UnsupportedFunctionalityError
- Unsupported task type: ${taskType}
- URL-based images are not supported for Amazon Bedrock image
- AI_UnsupportedFunctionalityError
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/4b49389cd60e4f62.
Report an issue: GitHub.