Skip to main content

Function: file()

file(data, mimeType, options?): UnifiedMessageInput

Defined in: packages/core/src/multimodal.ts:255

Create a file input for documents, PDFs, and other file types.

Accepts binary data (Blob, Uint8Array, ArrayBuffer, base64 string) or an HTTPS URL. When an HTTPS URL is provided, the AI provider fetches the file server-side — the bytes never transit through your application. Works across all providers via the AI SDK. HTTP (non-TLS) URLs are rejected for security.

Parameters

data

string | ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob

mimeType

string

options?

cacheControl?

boolean

Returns

UnifiedMessageInput

Examples

bot.process(combine(
text('Summarize this contract'),
file('https://storage.example.com/contract.pdf', 'application/pdf', { cacheControl: true })
));
const pdfBlob = await fetch('report.pdf').then(r => r.blob());
bot.process(combine(text('Summarize this'), file(pdfBlob, 'application/pdf')));
bot.process(file(pdfBuffer, 'application/pdf', { cacheControl: true }));