Skip to main content
Extensions

Browser Automation

Let agents read and search the web from an agentOS VM using Browserbase's cloud browser through the browse CLI — no local browser or sandbox required.

Agents can read and search the web with the Browserbase browse CLI. The page loads in a real browser in Browserbase’s cloud and comes back as clean content — the VM never runs a browser.

Setup

Create a Browserbase account

Sign up and grab your API key and project id from the dashboard:

export BROWSERBASE_API_KEY=bb_...
export BROWSERBASE_PROJECT_ID=...

Install

npm install @rivet-dev/agentos @agentos-software/pi @agentos-software/browserbase

Add `browse` to the VM

import browserbase from "@agentos-software/browserbase";
import pi from "@agentos-software/pi";
import { agentOS, setup } from "@rivet-dev/agentos";

// `browse` is exposed inside the VM as a command on `$PATH`.
const vm = agentOS({
	software: [pi, browserbase],
});

export const registry = setup({ use: { vm } });
registry.start();

Use it

Command reference

browse cloud fetch https://example.com   # retrieve a page as markdown
browse cloud search "web scraping tools" # search the web
browse cloud sessions list               # list cloud browser sessions
browse cloud projects list               # list Browserbase projects

The interactive driver mode (browse open, browse click, …) is not supported inside the VM yet (#1631). For interactive automation, run browse inside an external sandbox via External Sandboxes.

Embedded API

Install the same Browserbase software package and pass its credentials through the embedded session environment.

import browserbase from "@agentos-software/browserbase";
import pi from "@agentos-software/pi";
import { AgentOs } from "@rivet-dev/agentos-core";

const { ANTHROPIC_API_KEY, BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID } =
	process.env;
if (!ANTHROPIC_API_KEY || !BROWSERBASE_API_KEY || !BROWSERBASE_PROJECT_ID) {
	throw new Error("Set the Anthropic and Browserbase environment variables.");
}

const vm = await AgentOs.create({ software: [pi, browserbase] });

try {
	await vm.sessions.open({
		agent: "pi",
		env: {
			ANTHROPIC_API_KEY,
			BROWSERBASE_API_KEY,
			BROWSERBASE_PROJECT_ID,
		},
	});
	await vm.sessions.prompt({
		content: [
			{
				type: "text",
				text: "Use browse to summarize https://example.com.",
			},
		],
	});
} finally {
	await vm.dispose();
}

Read more in the embedded API quickstart.