Compatibility Note: Only works with the browser-use
agent framework. Not supported with OpenAI CUA.
Quick Start
Upload a ZIP file containing resources that your AI agent can use to complete tasks. The ZIP file is automatically extracted and made available to the agent.
Example: Upload ZIP File
import { chromium } from 'playwright';
// 1. Create a test ZIP file with content
const testContent = 'Hello from AnchorBrowser!\nThis is a test file for the agent.';
const blob = new Blob([testContent], { type: 'text/plain' });
const formData = new FormData();
formData.append('file', blob, 'test-data.zip');
// 2. Upload to browser session
const response = await fetch(`https://api.anchorbrowser.io/v1/sessions/${sessionId}/agent/files`, {
method: 'POST',
headers: {
'anchor-api-key': apiKey
},
body: formData
});
const result = await response.json();
console.log('Upload result:', result);
// 3. Connect to the browser session and use uploaded files with AI agent
const browser = await chromium.connectOverCDP(
`wss://connect.anchorbrowser.io?apiKey=${apiKey}&sessionId=${sessionId}`
);
const context = browser.contexts()[0];
const page = context.pages()[0];
// Navigate to a website where you want to use the uploaded files
await page.goto('https://v0-download-and-upload-text.vercel.app/');
// Use AI agent to interact with the page using uploaded files
const ai = context.serviceWorkers()[0];
const aiResult = await ai.evaluate("upload a file to the server");
console.log('AI agent result:', aiResult);
That’s it! The agent can now access all uploaded files and use them to complete web tasks.