Skip to main content
Browser-Use is an open-source framework for building autonomous AI agents that browse the web. Combine it with Browser Cash for stealth browsing capabilities.

Installation

# Create environment with uv (Python >= 3.11)
uv init
uv add browser-use requests
uv sync

Setup

Get your API keys:
  1. Browser-Use Cloud API key
  2. Browser Cash API key
# .env
BROWSER_USE_API_KEY=your-browser-use-key
BROWSER_API_KEY=your-browser-cash-key

Quick Start

Python
import os
import asyncio
import requests
from browser_use import Agent, Browser, ChatBrowserUse


async def run_agent():
    # Create Browser Cash session
    resp = requests.post(
        "https://api.browser.cash/v1/browser/session",
        headers={
            "Authorization": f"Bearer {os.getenv('BROWSER_API_KEY')}",
            "Content-Type": "application/json",
        },
        json={},
    )
    resp.raise_for_status()
    data = resp.json()

    # Create Browser-Use browser with Browser Cash CDP URL
    browser = Browser(cdp_url=data["cdpUrl"])
    llm = ChatBrowserUse()

    # Create and run agent
    agent = Agent(
        task="Find the current price of Bitcoin",
        llm=llm,
        browser=browser,
    )

    result = await agent.run()

    # Cleanup
    requests.delete(
        "https://api.browser.cash/v1/browser/session",
        headers={"Authorization": f"Bearer {os.getenv('BROWSER_API_KEY')}"},
        params={"sessionId": data["sessionId"]},
    )

    return result


if __name__ == "__main__":
    result = asyncio.run(run_agent())
    print(result)

With Session Options

Python
resp = requests.post(
    "https://api.browser.cash/v1/browser/session",
    headers={
        "Authorization": f"Bearer {os.getenv('BROWSER_API_KEY')}",
        "Content-Type": "application/json",
    },
    json={
        "country": "US",
        "type": "consumer_distributed",  # Maximum stealth
        "windowSize": "1920x1080",
    },
)

Complex Tasks

Python
agent = Agent(
    task="""
    1. Go to Amazon.com
    2. Search for "wireless headphones"
    3. Find the top-rated product under $100
    4. Extract the product name, price, and rating
    """,
    llm=llm,
    browser=browser,
)

With Persistent Profiles

Keep login sessions across agent runs:
Python
import os
import requests

headers = {
    "Authorization": f"Bearer {os.getenv('BROWSER_API_KEY')}",
    "Content-Type": "application/json",
}

# First run — login
resp = requests.post(
    "https://api.browser.cash/v1/browser/session",
    headers=headers,
    json={
        "profile": {"name": "my-agent-profile", "persist": True}
    },
)

# Agent logs into a service...

# Later runs — already logged in
resp = requests.post(
    "https://api.browser.cash/v1/browser/session",
    headers=headers,
    json={
        "profile": {"name": "my-agent-profile", "persist": True}
    },
)

Why Browser Cash + Browser-Use?

  • Stealth browsing — Consumer distributed nodes avoid detection
  • Global reach — Run agents from different countries
  • Persistent state — Maintain logins across agent sessions
  • Scalability — No local browser management