Skip to main content

Installation

Verify installation:

Quick Start

Here’s everything you need to get started:

Client Setup

Basic Initialization

Environment Variables

Set these in your environment or .env file:
Then use:

Browser Client Usage

Creating a Browser Client

The browser_client() method creates a BrowserClient that automatically manages browser sessions:

Using BrowserClient

Always use the context manager - it ensures proper cleanup:

Page Automation Methods

The page object (from Stagehand) provides AI-powered browser automation:

AI-Powered Actions

Screenshots

Element Interaction

Waiting

Evaluation

Advanced Examples

Web Scraping Example

Form Filling Example

Multi-Page Workflow

Available Models

The SDK supports multiple AI models for browser automation:

Available Providers

Environment Variables

Required:
  • SIMULTANEOUS_PROJECT_ID - Your project UUID
  • OPENAI_API_KEY - For AI-powered browser actions
Optional:
  • SIMULTANEOUS_API_KEY - API key for authentication
  • ANTHROPIC_API_KEY - For Claude models (if using Models.CLAUDE_3_5)
  • BROWSERBASE_PROJECT_ID - Browserbase project ID (if different from default)
  • BROWSERBASE_REGION - Browserbase region (default: “sfo”)

Error Handling

Choosing a Model

  • Models.O4_MINI - Fast and cost-effective for simple tasks (recommended)
  • Models.GPT4O - More capable for complex interactions
  • Models.CLAUDE_3_5 - Alternative AI model (requires ANTHROPIC_API_KEY)

Best Practices

  1. ✅ Always use async with for automatic cleanup
  2. ✅ Set OPENAI_API_KEY environment variable
  3. ✅ Use O4_MINI for simple tasks to save costs
  4. ✅ Take screenshots for debugging (await page.screenshot())
  5. ✅ Wait for elements before interacting (await page.wait_for_selector())