Skip to main content

Agent Browser Integration

Agent Browser is a headless browser automation CLI for AI agents, built with a fast Rust CLI and Node.js fallback. By connecting agent-browser to Browserless, you get cloud-hosted browsers without managing Chrome infrastructure yourself, complete with stealth mode, residential proxies, and enterprise-grade reliability.

Prerequisites

  • Node.js 18 or later
  • agent-browser installed globally or as a project dependency
  • Browserless API token (available in your account dashboard)

Step-by-Step Setup

1. Get your API token

Go to your Browserless Account Dashboard and copy your API token.

Then set your environment variable:

BROWSERLESS_API_KEY=your-api-token

2. Install agent-browser

npm install -g agent-browser

3. Connect to Browserless

Use the -p browserless flag to route all browser commands through Browserless:

export BROWSERLESS_API_KEY="your-api-token"
agent-browser -p browserless open https://example.com

Or use environment variables for CI/scripts:

export AGENT_BROWSER_PROVIDER=browserless
export BROWSERLESS_API_KEY="your-api-token"
agent-browser open https://example.com

When enabled, agent-browser connects to a Browserless cloud session instead of launching a local browser. All commands work identically.

4. Run browser automation

Use agent-browser's CLI commands with the Browserless-powered browser:

# Navigate and take a snapshot
agent-browser -p browserless open https://www.browserless.io
agent-browser snapshot

# Interact using refs from the snapshot
agent-browser click @e2
agent-browser fill @e3 "test@example.com"

# Get text content and screenshots
agent-browser get text @e1
agent-browser screenshot page.png

# Clean up
agent-browser close

Optional Configuration

Configure Browserless behavior via environment variables:

VariableDescriptionDefault
BROWSERLESS_API_URLBase API URL (for custom regions or self-hosted)https://production-sfo.browserless.io
BROWSERLESS_BROWSER_TYPEType of browser to use (chromium or chrome)chromium
BROWSERLESS_TTLSession TTL in milliseconds300000
BROWSERLESS_STEALTHEnable stealth mode (true / false)true

Regional endpoints

Pick the region closest to you for lower latency:

RegionBROWSERLESS_API_URL value
US West (San Francisco)https://production-sfo.browserless.io
Europe (London)https://production-lon.browserless.io
Europe (Amsterdam)https://production-ams.browserless.io

Usage with AI Agents

agent-browser is designed for AI coding assistants and autonomous agents. Add it to your agent's instructions:

Use agent-browser to browse the web. Run agent-browser --help for all commands.

Core workflow:
1. agent-browser -p browserless open <url>
2. agent-browser snapshot -i (get interactive elements with refs @e1, @e2)
3. agent-browser click @e1 / fill @e2 "text" (interact using refs)
4. Re-snapshot after page changes

For richer context in AI coding assistants (Claude Code, Cursor, Codex, etc.):

npx skills add vercel-labs/agent-browser

Why use Browserless with agent-browser

  • Stealth mode: bypass bot detection with stealth enabled by default
  • Residential proxies: route traffic through real residential IPs to avoid blocks
  • Global regions: choose from US West (San Francisco), Europe (London), or Europe (Amsterdam) endpoints for lower latency
  • No infrastructure: skip managing Chrome installations, updates, or scaling
  • Parallel sessions: run multiple browser sessions simultaneously
  • Enterprise reliability: 99.9% uptime SLA with automatic failover

Resources