File

Files enable you to provide input data to tasks and retrieve generated output.

What are Files?

Input Files: Data you provide (documents, images, credentials, templates) Output Files: Results generated by AI agents (screenshots, reports, extracted data)

Key Properties

  • id: Unique file identifier
  • name: Original filename
  • size: File size in bytes
  • mimeType: File content type
  • presignedUrl: Temporary download URL
  • taskId: Associated task (for output files)

File Operations

1import { BrowserUseClient } from "browser-use-sdk";
2
3const client = new BrowserUseClient({ apiKey: "bu_..." });
4
5// Upload and use files
6const credFile = await client.files.upload("credentials.json");
7const templateFile = await client.files.upload("template.xlsx");
8
9// Use in tasks
10const task = await client.tasks.createTask({
11 task: "Log into dashboard using credentials and fill template",
12 inputFiles: [credFile.id, templateFile.id]
13});
14
15const result = await task.complete();
16console.log("Task completed:", result.output);

Output Files

1import * as fs from "fs";
2
3// Tasks generate output files
4const task = await client.tasks.createTask({
5 task: "Take screenshots and extract data to CSV"
6});
7
8const result = await task.complete();
9
10// Download output files
11for (const file of result.outputFiles) {
12 const data = await client.files.download(file.id);
13 fs.writeFileSync(`output/${file.name}`, data);
14}

File Management

1// List and manage files
2const files = await client.files.listFiles();
3const taskFiles = await client.files.listFiles({ taskId: "task_123" });
4const images = await client.files.listFiles({ mimeType: "image/*" });
5
6// Cleanup
7await client.files.deleteFile(fileId);

Supported Types

Input: PDF, Word, text, CSV, JSON, images (PNG, JPEG, GIF), ZIP archives Output: Screenshots, data exports (CSV, JSON, Excel), reports (PDF, HTML), downloaded content


Next Steps