| name | browser-use-cloud |
| description | Cloud-based AI browser agent for autonomous web tasks. Use when you need to perform complex browser automation tasks autonomously, scrape websites that require AI reasoning, fill forms intelligently, extract structured data from web pages, or perform multi-step web workflows. Triggers include "autonomous browsing", "AI browser", "browser-use", "scrape with AI", "extract structured data from website", "fill out form intelligently", "navigate website and find", or when the task requires reasoning about page content rather than just clicking elements. Prefer this over web-fetch when the task involves multiple steps, requires understanding page semantics, or when you need structured output. |
Browser Use Cloud SDK
Cloud-based AI browser agent that autonomously completes web tasks.
When to use this vs. web-fetch:
- Use browser-use-cloud for autonomous multi-step tasks requiring AI reasoning
- Use web-fetch for simple, deterministic browser automation (click this, fill that)
Setup
API key is set in environment: BROWSER_USE_API_KEY
pip install browser-use-sdk
Quick Examples
Simple Task (Python)
from browser_use_sdk.v3 import AsyncBrowserUse
client = AsyncBrowserUse()
result = await client.run("Find the latest dark pool data for AAPL on unusualwhales.com")
print(result.output)
print(result.status)
print(result.total_cost_usd)
Structured Output
from browser_use_sdk.v3 import AsyncBrowserUse
from pydantic import BaseModel
class DarkPoolData(BaseModel):
ticker: str
total_volume: int
buy_ratio: float
largest_print: int
date: str
client = AsyncBrowserUse()
result = await client.run(
"Get today's dark pool summary for NVDA from unusualwhales.com/stock/NVDA/dark-pool",
output_schema=DarkPoolData
)
print(result.output)
Session Reuse (Multi-Step)
session = await client.sessions.create(proxy_country_code="us")
result1 = await client.run(
"Go to unusualwhales.com and accept cookies",
session_id=str(session.id),
keep_alive=True
)
result2 = await client.run(
"Navigate to the options flow page and get the top 5 largest call sweeps",
session_id=str(session.id),
keep_alive=True
)
await client.sessions.stop(str(session.id))
API Reference (v3 Experimental)
Constructor
from browser_use_sdk.v3 import AsyncBrowserUse, BrowserUse
client = AsyncBrowserUse(
api_key="...",
base_url="...",
timeout=30.0
)
client = BrowserUse(api_key="...", base_url="...", timeout=30.0)
with BrowserUse() as client:
result = client.run("Find the top HN post")
run() Parameters
result = await client.run(
"Your task description",
model="bu-mini",
output_schema=MyModel,
session_id="...",
keep_alive=False,
max_cost_usd=1.0,
proxy_country_code="us",
profile_id="uuid",
)
SessionResult Fields
After await client.run():
result.output
result.id
result.status
result.model
result.live_url
result.total_cost_usd
result.llm_cost_usd
result.proxy_cost_usd
result.proxy_used_mb
result.total_input_tokens
result.total_output_tokens
result.created_at
result.updated_at
Sessions Resource
session = await client.sessions.create(
proxy_country_code="us",
profile_id="...",
)
sessions_list = await client.sessions.list(page=1, page_size=20)
details = await client.sessions.get(str(session.id))
await client.sessions.stop(str(session.id), strategy="session")
await client.sessions.stop(str(session.id), strategy="task")
await client.sessions.delete(str(session.id))
File Upload/Download
from browser_use_sdk.v3 import FileUploadItem
upload_resp = await client.sessions.upload_files(
str(session.id),
files=[FileUploadItem(name="data.csv", content_type="text/csv")]
)
file_list = await client.sessions.files(
str(session.id),
include_urls=True,
prefix="outputs/",
limit=50,
)
Error Handling
from browser_use_sdk.v3 import BrowserUseError
try:
result = await client.run("Do something")
except TimeoutError:
print("SDK polling timed out (5 min default)")
except BrowserUseError as e:
print(f"API error: {e}")
finally:
await client.close()
Key Concepts
| Concept | Description |
|---|
| Task | Text prompt → agent browses autonomously → returns output |
| Session | Stateful browser sandbox. Auto-created or manual for follow-ups |
| Profile | Persistent browser state (cookies, localStorage). Survives sessions |
| Proxies | Set proxy_country_code. 195+ countries. CAPTCHAs auto-handled |
| Stealth | On by default. Anti-detect, CAPTCHA solving, ad blocking |
| Models | bu-mini (faster/cheaper) and bu-max (more capable) |
| Cost control | Set max_cost_usd to cap spending |
| keep_alive | If True, session stays idle for follow-ups |
| Live URL | Every session has live_url for real-time monitoring |
Trading-Specific Examples
Extract Dark Pool Data
from browser_use_sdk.v3 import AsyncBrowserUse
from pydantic import BaseModel
from typing import List
class DarkPoolDay(BaseModel):
date: str
volume: int
buy_ratio: float
class DarkPoolSummary(BaseModel):
ticker: str
five_day_avg_buy_ratio: float
flow_direction: str
daily_data: List[DarkPoolDay]
client = AsyncBrowserUse()
result = await client.run(
"""Go to unusualwhales.com/stock/NVDA/dark-pool and extract:
1. The 5-day dark pool summary
2. Daily breakdown with date, volume, and buy ratio
3. Determine if the flow is ACCUMULATION (>60% buy), DISTRIBUTION (<40% buy), or NEUTRAL""",
output_schema=DarkPoolSummary,
model="bu-max"
)
print(f"NVDA: {result.output.flow_direction}")
print(f"5-day avg buy ratio: {result.output.five_day_avg_buy_ratio:.1%}")
Extract Options Flow
class OptionFlow(BaseModel):
ticker: str
strike: float
expiry: str
premium: int
side: str
type: str
class FlowSummary(BaseModel):
flows: List[OptionFlow]
total_call_premium: int
total_put_premium: int
result = await client.run(
"Go to unusualwhales.com/flow and get the top 10 largest options trades from today",
output_schema=FlowSummary
)
Multi-Step Research
session = await client.sessions.create(proxy_country_code="us")
dp_result = await client.run(
"Get 5-day dark pool summary for AAPL from unusualwhales.com",
session_id=str(session.id),
keep_alive=True
)
options_result = await client.run(
"Now navigate to the options page and get ATM call prices for next month expiry",
session_id=str(session.id),
keep_alive=True
)
news_result = await client.run(
"Check finviz.com/quote.ashx?t=AAPL for any recent news that might explain the flow",
session_id=str(session.id)
)
await client.sessions.stop(str(session.id))
Screenshot for Documentation
result = await client.run(
"Go to tradingview.com/symbols/AAPL and take a screenshot of the current price chart",
keep_alive=True
)
files = await client.sessions.files(str(result.id), include_urls=True)
for f in files.files:
print(f.url)
v2 API (Legacy)
The v2 API is still available for simpler use cases:
from browser_use_sdk import AsyncBrowserUse
client = AsyncBrowserUse()
result = await client.run("Find the top HN post")
async for step in client.run("Go to google.com and search"):
print(f"[{step.number}] {step.next_goal}")
v2-specific parameters
result = await client.run(
"task",
llm="...",
start_url="...",
max_steps=100,
secrets={"domain": "pass"},
allowed_domains=["..."],
flash_mode=True,
vision=True,
)
Best Practices
- Use structured output — Always define Pydantic models for predictable data extraction
- Set cost caps — Use
max_cost_usd to avoid runaway costs
- Reuse sessions — For multi-step tasks, create a session and reuse with
keep_alive=True
- Choose the right model —
bu-mini for simple tasks, bu-max for complex reasoning
- Use proxies — Set
proxy_country_code for sites with geo-restrictions or anti-bot
- Handle errors — Wrap in try/except for
TimeoutError and BrowserUseError
- Clean up — Always
await client.close() or use context manager
Cost Estimation
| Model | Approximate Cost |
|---|
| bu-mini | ~$0.01-0.05 per task |
| bu-max | ~$0.05-0.20 per task |
| + Proxy | ~$0.001 per MB |
Monitor costs with result.total_cost_usd after each task.