vercel/ai · error · UnsupportedFunctionalityError

File URL data

Error message

File URL data

What it means

When a file part's data is a URL, Bedrock only supports S3 URLs. Any other protocol (https:, data:, etc.) triggers this UnsupportedFunctionalityError labelled 'File URL data', because non-S3 URL file sources cannot be translated to the Bedrock payload.

Source

Thrown at packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts:233

                      });
                    } 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),
                                source: getAmazonBedrockMediaSource({
                                  data: part.data,
                                  functionality: 'File URL data',
                                }),
                              },
                            });

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Change the URL to an s3:// protocol URL pointing at a bucket accessible by your Bedrock account.
  2. Otherwise download the file and pass its bytes as raw data (Uint8Array) in the file part.
  3. For web-hosted files, fetch them server-side first and embed the content.

Example fix

// before
{ type: 'file', data: { type: 'url', url: new URL('https://example.com/doc.pdf') } }
// after (option A)
{ type: 'file', data: { type: 'url', url: new URL('s3://my-bucket/doc.pdf') } }
// after (option B)
const bytes = new Uint8Array(await (await fetch('https://example.com/doc.pdf')).arrayBuffer());
{ type: 'file', data: bytes, mediaType: 'application/pdf' }
Defensive patterns

Strategy: validation

Validate before calling

function assertFileUrlProtocol(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 === 'url' && p.data.url.protocol !== 's3:') {
        throw new Error('Bedrock only supports s3:// URLs for file parts; use raw bytes for other sources.');
      }
    }
  }
}

Type guard

function isS3FileUrl(part: any): boolean {
  return part?.type === 'file' && part?.data?.type === 'url' && part?.data?.url?.protocol === 's3:';
}

Try / catch

try {
  await generateText({ model: bedrock(modelId), messages });
} catch (error) {
  if (UnsupportedFunctionalityError.isInstance(error) && error.functionality === 'File URL data') {
    // download the URL server-side, embed bytes, retry
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: Passing a file part with `data: { type: 'url', url: new URL('https://...') }` (or any non-s3: protocol) in a message sent to a Bedrock model.

Common situations: Reusing public HTTPS document URLs from prompts built for OpenAI/Anthropic direct upload APIs; assuming URL-based file input works everywhere; data: URIs embedded in messages.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/55e98d29d3aa641f. Report an issue: GitHub.