### Local Development Setup Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/quickstart.md Local development setup: clone the repository, sync dependencies with uv, and use helper scripts for setup, linting, testing, and running examples. ```bash git clone https://github.com/browser-use/browser-use cd browser-use uv sync --all-extras --dev # Helper scripts ./bin/setup.sh # Complete setup ./bin/lint.sh # Formatting, linting, type checking ./bin/test.sh # CI test suite # Run examples uv run examples/simple.py ``` -------------------------------- ### Install browser-harness with uv Source: https://github.com/browser-use/browser-use/blob/main/skills/qa/SKILL.md Installs browser-harness using uv, a one-time setup that takes about 30 seconds. If uv is missing, the command installs it first via the official installer. After installation, verifies that browser-harness is on PATH. ```bash command -v uv || curl -LsSf https://astral.sh/uv/install.sh | sh # the uv installer, only if missing uv tool install "git+https://github.com/browser-use/browser-harness" command -v browser-harness # verify it's on PATH now ``` -------------------------------- ### Setup and run basic task Source: https://github.com/browser-use/browser-use/blob/main/examples/cloud/README.md Sets up the environment and runs the basic Cloud API V4 example. Requires an API key added to the .env file. ```bash uv sync cp examples/cloud/env.example .env # Add your API key to .env uv run python examples/cloud/01_basic_task.py ``` -------------------------------- ### Run helper scripts for setup, linting, and testing Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Run the helper scripts for common development tasks: setup.sh installs uv, creates a venv, and installs dependencies; lint.sh runs all pre-commit hooks; test.sh runs the core test suite used in CI. ```bash # Complete setup script - installs uv, creates a venv, and installs dependencies ./bin/setup.sh # Run all pre-commit hooks (formatting, linting, type checking) ./bin/lint.sh # Run the core test suite that's executed in CI ./bin/test.sh ``` -------------------------------- ### Run the quickstart script Source: https://github.com/browser-use/browser-use/blob/main/examples/integrations/anthropic/README.md Executes the quickstart script with uv. ```bash uv run run_browser.py ``` -------------------------------- ### Install required packages Source: https://github.com/browser-use/browser-use/blob/main/examples/integrations/slack/README.md Installs the required packages for the Slack integration example. ```sh pip install fastapi uvicorn slack_sdk ``` -------------------------------- ### CLI prompt for installing and connecting browser-use Source: https://github.com/browser-use/browser-use/blob/main/README.md Paste this prompt into Claude Code, Codex, Hermes, OpenClaw, or your favorite agent to install or upgrade browser-use, register the skill, and connect it to your browser. If setup or connection fails, the prompt directs you to the browser-harness install guide. ```text Install or upgrade browser-use to the latest stable version with uv using Python 3.12, run `browser-use skill install` to register the skill, and connect it to my browser. If setup or connection fails, follow https://github.com/browser-use/browser-harness/blob/main/install.md. ``` -------------------------------- ### Run the simple example Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Run the simple example script using uv. ```bash uv run examples/simple.py ``` -------------------------------- ### Install browser-use with uv Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/SKILL.md Install the browser-use library using uv, the recommended package manager. Run 'uv pip install browser-use' followed by 'uvx browser-use install' to set up the library. ```bash uv pip install browser-use ``` ```bash uvx browser-use install ``` -------------------------------- ### Set up project and install dependencies Source: https://github.com/browser-use/browser-use/blob/main/examples/integrations/anthropic/README.md Initializes a Python 3.12 project, adds the browser-use and anthropic packages, and installs the browser-use CLI. ```bash uv init --python 3.12 uv add browser-use anthropic uvx browser-use install ``` -------------------------------- ### Install browser-use with uv Source: https://github.com/browser-use/browser-use/blob/main/README.md Install Browser Use with uv. Requires Python >= 3.11; run `uv init --python 3.12` first if starting a new project. ```bash uv add browser-use ``` -------------------------------- ### Clone and install Browser Use Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Clone the repository and install dependencies using uv or pip. The uv command syncs all extras and dev dependencies; the pip alternative installs directly from the main branch. ```bash git clone https://github.com/browser-use/browser-use cd browser-use uv sync --all-extras --dev # or pip install -U git+https://github.com/browser-use/browser-use.git@main ``` -------------------------------- ### Manual session creation and usage Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/sessions.md Create a session with profile, proxy, and start URL. Run multiple tasks in the same session, get the live URL for monitoring, and stop the session to save state. ```python session = await client.sessions.create( profile_id="uuid", # Persistent profile proxy_country_code="us", # Residential proxy start_url="https://example.com", ) # Run multiple tasks in same session await client.run("First task", session_id=session.id) await client.run("Follow-up task", session_id=session.id) # Get live URL for monitoring session_info = await client.sessions.get(session.id) print(session_info.live_url) # Watch agent in real-time await client.sessions.stop(session.id) ``` -------------------------------- ### Install eth-account (Python) Source: https://github.com/browser-use/browser-use/blob/main/skills/x402/SKILL.md Install the eth-account library to generate a new Ethereum wallet in Python. ```bash pip install eth-account ``` -------------------------------- ### Name Actions Directly: Task Prompt Example Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/agent.md Demonstrates naming actions directly in the task prompt to guide the agent's behavior. ```python task = """ 1. Use search action to find "Python tutorials" 2. Use click to open first result in a new tab 3. Use scroll action to scroll down 2 pages 4. Use extract to extract the names of the first 5 items """ ``` -------------------------------- ### Check Browser Use CLI with --doctor and skill show Source: https://github.com/browser-use/browser-use/blob/main/skills/remote-browser/SKILL.md Run these commands to verify the Browser Use CLI is installed and working. If setup fails, follow the linked Browser Use skill. ```bash browser-use --doctor browser-use skill show ``` -------------------------------- ### Install viem (TypeScript) Source: https://github.com/browser-use/browser-use/blob/main/skills/x402/SKILL.md Install the viem library to generate a new Ethereum wallet in TypeScript. ```bash npm install viem ``` -------------------------------- ### Install browser-use CLI Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/guides/tools-integration.md Install the browser-use CLI package using uv pip. This is the first step before using any CLI commands. ```bash uv pip install 'browser-use[cli]' ``` -------------------------------- ### Install Python SDK Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/quickstart.md Install the browser-use-sdk package for Python. ```bash pip install browser-use-sdk ``` -------------------------------- ### Quick Example: Custom Tool with BrowserSession Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/tools.md Shows the minimal setup for a custom tool: create a Tools instance, decorate an async function with @tools.action, and pass the tools object to the Agent. The parameter must be named browser_session: BrowserSession (not browser: Browser) because the agent injects by name matching; a wrong name fails silently. ```python from browser_use import Tools, ActionResult, BrowserSession tools = Tools() @tools.action('Ask human for help with a question') async def ask_human(question: str, browser_session: BrowserSession) -> ActionResult: answer = input(f'{question} > ') return ActionResult(extracted_content=f'The human responded with: {answer}') agent = Agent(task='Ask human for help', llm=llm, tools=tools) ``` -------------------------------- ### Install browser-use Source: https://github.com/browser-use/browser-use/blob/main/examples/apps/ad-use/README.md Install the latest version of browser-use, which includes screenshot functionality required by this demo. Requires browser-use v0.7.7 or higher. ```bash pip install -U browser-use ``` -------------------------------- ### Start ngrok to expose local server Source: https://github.com/browser-use/browser-use/blob/main/examples/integrations/slack/README.md Starts ngrok to expose your local server. Replace 3000 with the port your server runs on. ```sh ngrok http 3000 ``` -------------------------------- ### Install browser-use with uv Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/quickstart.md Sets up a Python 3.12 virtual environment with uv, installs browser-use, and downloads Chromium via uvx. ```bash pip install uv uv venv --python 3.12 source .venv/bin/activate # Windows: .venv\Scripts\activate uv pip install browser-use uvx browser-use install # Downloads Chromium ``` -------------------------------- ### SDK Setup for v3 (Python and TypeScript) Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/api-v3.md Setup for the v3 SDK in Python (async and sync) and TypeScript. The Python async client is recommended and uses the BROWSER_USE_API_KEY environment variable by default. ```python # Python (async — recommended) from browser_use_sdk.v3 import AsyncBrowserUse client = AsyncBrowserUse() # Uses BROWSER_USE_API_KEY env var # Python (sync) from browser_use_sdk.v3 import BrowserUse client = BrowserUse() ``` ```typescript // TypeScript import { BrowserUse } from "browser-use-sdk/v3"; const client = new BrowserUse(); ``` -------------------------------- ### Install OCI SDK Source: https://github.com/browser-use/browser-use/blob/main/browser_use/llm/oci_raw/README.md Install the OCI Python SDK, which is required for the ChatOCIRaw integration. ```bash pip install oci ``` -------------------------------- ### Start local MCP server with uvx Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/guides/tools-integration.md Run this command to start the local MCP server for MCP-native agents. The agent then discovers browser tools via the MCP protocol. ```bash uvx --from 'browser-use[cli]' browser-use --mcp ``` -------------------------------- ### Install and initialize OpenLIT Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/monitoring.md Zero-code OpenTelemetry instrumentation for browser-use. Install the openlit and browser-use packages, then call openlit.init() to auto-instrument. ```bash pip install openlit browser-use ``` ```python import openlit openlit.init() # That's it — auto-instruments browser-use ``` -------------------------------- ### Install browser-use-sdk with x402 extra Source: https://github.com/browser-use/browser-use/blob/main/skills/x402/SKILL.md Installs the SDK and x402 dependencies for Python (3.10+ required) or TypeScript. Choose based on the project language: package.json/tsconfig.json → TypeScript; pyproject.toml/requirements.txt/*.py → Python. ```bash # Python (needs 3.10+ for the x402 extra) pip install "browser-use-sdk[x402]" # TypeScript npm install browser-use-sdk @x402/fetch @x402/evm viem ``` -------------------------------- ### Install Browser-Use with uv and activate environment Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md These commands create a Python 3.12 virtual environment with uv, activate it, and install browser-use along with Chromium. Use the Windows activation command on Windows. ```bash pip install uv uv venv --python 3.12 ``` ```bash source .venv/bin/activate # On Windows use `.venv\Scripts\activate` ``` ```bash uv pip install browser-use uvx browser-use install ``` -------------------------------- ### Browser-Use Cloud: Simple and Advanced Setup Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/browser.md Use the Browser-Use Cloud service by setting use_cloud=True. The advanced setup allows specifying a cloud profile ID, proxy country code, and timeout. Requires the BROWSER_USE_API_KEY environment variable. ```python # Simple browser = Browser(use_cloud=True) # Advanced — bypasses captchas, geo-restrictions browser = Browser( cloud_profile_id='your-profile-id', cloud_proxy_country_code='us', # us, uk, fr, it, jp, au, de, fi, ca, in cloud_timeout=30, # minutes (free: 15, paid: 240) ) ``` -------------------------------- ### Install and initialize Laminar Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/monitoring.md Setup for Laminar monitoring integration. Install the lmnr package and initialize it, requiring the LMNR_PROJECT_API_KEY environment variable. ```bash pip install lmnr ``` ```python from lmnr import Laminar Laminar.initialize() # Set LMNR_PROJECT_API_KEY env var ``` -------------------------------- ### Initialize AsyncBrowserUse client (SETUP = B) Source: https://github.com/browser-use/browser-use/blob/main/skills/x402/SKILL.md Use this client initialization when SETUP = B. It reads the key and endpoint from your .env file. Mode A is accountless; Mode B requires an API key. Note that x402 requires the async client; the sync BrowserUse won't run when the x402 env var is set. ```python from browser_use_sdk.v3 import AsyncBrowserUse client = AsyncBrowserUse() # Mode A (accountless) # client = AsyncBrowserUse(api_key="bu_...") # Mode B (top up existing account) ``` -------------------------------- ### Setup virtual environment with uv Source: https://github.com/browser-use/browser-use/blob/main/CLAUDE.md Sets up a virtual environment with Python 3.11, activates it, and syncs dependencies using uv. ```bash uv venv --python 3.11 source .venv/bin/activate uv sync ``` -------------------------------- ### Browser Methods: start, new_page, get_pages, get_current_page, close_page, stop Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/actor.md Core browser lifecycle and page management methods. Use to start the browser, open new tabs, list pages, get the active page, close tabs, and stop the browser. ```python browser = Browser() await browser.start() page = await browser.new_page("https://example.com") # Open new tab pages = await browser.get_pages() # List all pages current = await browser.get_current_page() # Active page await browser.close_page(page) # Close tab await browser.stop() # Cleanup ``` -------------------------------- ### Create and run a Browser Use agent Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Basic agent setup with a task and LLM, then running it asynchronously with a maximum step limit. ```python from browser_use import Agent, ChatBrowserUse agent = Agent( task="Search for latest news about AI", llm=ChatBrowserUse(), ) async def main(): history = await agent.run(max_steps=100) ``` -------------------------------- ### Configure Oracle OCI with ChatOCIRaw Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/models.md Uses Oracle Cloud Infrastructure generative AI. Requires `~/.oci/config` setup and `pip install "browser-use[oci]"`. Auth types include `API_KEY`, `INSTANCE_PRINCIPAL`, and `RESOURCE_PRINCIPAL`. ```python from browser_use import Agent, ChatOCIRaw llm = ChatOCIRaw( model="meta.llama-3.1-70b-instruct", service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com", compartment_id="your-compartment-id", ) ``` -------------------------------- ### SDK Approach: Create and Stop Browser Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/browser-api.md Python SDK example to create a browser session, print the CDP and live URLs, and stop the session with refund of unused time. ```python # Create browser browser = await client.browsers.create( profile_id="uuid", proxy_country_code="us", timeout=60, ) print(browser.cdp_url) # wss://... for CDP connection print(browser.live_url) # View in browser # Stop (unused time refunded) await client.browsers.stop(browser.id) ``` -------------------------------- ### GET /sessions/{session_id} Source: https://github.com/browser-use/browser-use/blob/main/CLOUD.md Retrieves detailed information about a specific session, including its status, live URL, start and end times, associated tasks, and public share URL. Requires the session ID and an API key. ```APIDOC ## GET /sessions/{session_id} ### Description Get detailed session information including status, URLs, and task details. ### Method GET ### Endpoint https://api.browser-use.com/api/v2/sessions/{session_id} ### Parameters #### Path Parameters - **session_id** (string, uuid) - Required - The unique identifier of the session. #### Header Parameters - **X-Browser-Use-API-Key** (string) - Required - API key for authentication. ### Response #### Success Response (200) - **id** (string, uuid) - Session ID. - **status** (SessionStatus) - Session status (active or stopped). - **liveUrl** (string, nullable) - Live URL of the session. - **startedAt** (string, date-time) - Session start time. - **finishedAt** (string, date-time, nullable) - Session end time. - **tasks** (array of TaskItemView) - List of tasks in the session. - **publicShareUrl** (string, nullable) - Public share URL. #### Response Example { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "status": "active", "liveUrl": null, "startedAt": "2024-01-01T00:00:00Z", "finishedAt": null, "tasks": [ { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "sessionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "llm": "string", "task": "string", "status": "started", "startedAt": "2024-01-01T00:00:00Z", "finishedAt": null, "metadata": {}, "output": null, "browserUseVersion": null, "isSuccess": null } ], "publicShareUrl": null } #### Error Responses - **404** - Session not found. - **422** - Validation Error. ``` -------------------------------- ### Clone Repository and Navigate to App Folder Source: https://github.com/browser-use/browser-use/blob/main/examples/apps/news-use/README.md Clone the browser-use repository and change into the news-use example directory. ```bash git clone https://github.com/browser-use/browser-use.git cd browser-use/examples/apps/news-use ``` -------------------------------- ### SDK Setup with v3 and v2 Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/guides/chat-ui.md Initializes both SDK versions: v3 for sessions/messages and v2 for profiles. Uses NEXT_PUBLIC_BROWSER_USE_API_KEY, which exposes the key to the browser; move SDK calls to server actions or API routes in production. ```typescript // api.ts import { BrowserUse as BrowserUseV3 } from "browser-use-sdk/v3"; import { BrowserUse as BrowserUseV2 } from "browser-use-sdk"; const apiKey = process.env.NEXT_PUBLIC_BROWSER_USE_API_KEY ?? ""; const v3 = new BrowserUseV3({ apiKey }); const v2 = new BrowserUseV2({ apiKey }); ``` -------------------------------- ### PZERO ChatOpenAI setup Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/models.md Configure ChatOpenAI for PZERO using the PZERO_API_KEY environment variable. Use the /v1 base URL, pass catalog model ids as-is (no openai/ prefix), and note that the default deepseek-v4-flash model is text-only — set use_vision=False on the agent unless you pick a vision-capable model. List available models with GET https://api.pzero.studio/v1/models (no auth required). ```python import os llm = ChatOpenAI( model="deepseek-v4-flash", base_url="https://api.pzero.studio/v1", api_key=os.environ["PZERO_API_KEY"], ) ``` -------------------------------- ### Run as MCP server with uvx Source: https://github.com/browser-use/browser-use/blob/main/CLAUDE.md Starts the library as an MCP server for integration with Claude Desktop. Requires the CLI extra. ```bash uvx browser-use[cli] --mcp ``` -------------------------------- ### Install TypeScript SDK Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/quickstart.md Install the browser-use-sdk package for TypeScript/JavaScript. ```bash npm install browser-use-sdk ``` -------------------------------- ### Clone repo and enter ad-use app Source: https://github.com/browser-use/browser-use/blob/main/examples/apps/ad-use/README.md Clone the browser-use repository and navigate to the ad-use example app directory. ```bash git clone https://github.com/browser-use/browser-use.git cd browser-use/examples/apps/ad-use ``` -------------------------------- ### Verify browser-harness installation Source: https://github.com/browser-use/browser-use/blob/main/skills/qa/SKILL.md Verifies that browser-harness is installed and on PATH before running any QA tests. The command prints 'browser-harness OK' if the tool is available; otherwise it fails and you must install it. ```bash command -v browser-harness && browser-harness <<'PY' print("browser-harness OK") PY ``` -------------------------------- ### Run browser task with AsyncBrowserUse (SETUP = A) Source: https://github.com/browser-use/browser-use/blob/main/skills/x402/SKILL.md Use this script to run a browser task through the SDK when SETUP = A. The SDK reads BROWSER_USE_X402_PRIVATE_KEY from the environment and finds the x402 endpoint automatically. Write it as a throwaway script in /tmp or as a background job for long tasks, run it, report the result, and delete it. ```python import asyncio, os from browser_use_sdk.v3 import AsyncBrowserUse async def main(): client = AsyncBrowserUse() # Mode B: AsyncBrowserUse(api_key=os.environ["BROWSER_USE_API_KEY"]) result = await client.run(task="") print(result.output) asyncio.run(main()) ``` -------------------------------- ### Start remote daemon and open a tab Source: https://github.com/browser-use/browser-use/blob/main/browser_use/skills/browser-use/SKILL.md These commands start a remote daemon with a made-up name (r7k2) and then open a new tab in that browser. Use the same name for BU_NAME when starting the daemon and when using it. ```bash browser-use <<'PY' start_remote_daemon("r7k2") PY ``` ```bash BU_NAME=r7k2 browser-use <<'PY' new_tab("https://example.com") print(page_info()) PY ``` -------------------------------- ### Get session live URL Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/quickstart.md Fetch session details to get the liveUrl for watching the agent in real-time. ```bash curl https://api.browser-use.com/api/v2/sessions/ \ -H "X-Browser-Use-API-Key: $BROWSER_USE_API_KEY" ``` -------------------------------- ### POST /tasks Source: https://github.com/browser-use/browser-use/blob/main/CLOUD.md Creates a new task. You can either start a new task (auto creates a new simple session) or start a new task in an existing session (you can create a custom session before starting the task and reuse it for follow-up tasks). ```APIDOC ## POST /tasks ### Description Creates a new task. You can either start a new task (auto creates a new simple session) or start a new task in an existing session (you can create a custom session before starting the task and reuse it for follow-up tasks). ### Method POST ### Endpoint https://api.browser-use.com/api/v2/tasks ### Parameters #### Header Parameters - **X-Browser-Use-API-Key** (string) - Required - API key for authentication. #### Request Body - **task** (string) - Required - The task description. - **llm** (SupportedLLMs) - Optional - The LLM to use. Supported values: browser-use-llm, gpt-4.1, gpt-4.1-mini, o4-mini, o3, gemini-2.5-flash, gemini-2.5-pro, gemini-flash-latest, gemini-flash-lite-latest, gemini-3-flash-preview, gemini-3.1-flash-lite, claude-sonnet-4-20250514, gpt-4o, gpt-4o-mini, llama-4-maverick-17b-128e-instruct, claude-3-7-sonnet-20250219. - **startUrl** (string or null) - Optional - The starting URL for the task. - **maxSteps** (integer) - Optional - Maximum number of steps. - **structuredOutput** (string or null) - Optional - Structured output specification. - **sessionId** (uuid or null) - Optional - The session ID to reuse an existing session. - **metadata** (object or null) - Optional - Additional metadata as key-value pairs. - **secrets** (object or null) - Optional - Secrets as key-value pairs. - **allowedDomains** (array of strings or null) - Optional - List of allowed domains. - **opVaultId** (string or null) - Optional - Op vault ID. - **highlightElements** (boolean) - Optional - Whether to highlight elements. - **flashMode** (boolean) - Optional - Whether to use flash mode. - **thinking** (boolean) - Optional - Whether to enable thinking. - **vision** (boolean or string) - Optional - Vision setting. Can be boolean or the string "auto". - **systemPromptExtension** (string) - Optional - Extension to the system prompt. ### Request Example { "task": "string", "llm": "browser-use-llm", "startUrl": "string", "maxSteps": 0, "structuredOutput": "string", "sessionId": "00000000-0000-0000-0000-000000000000", "metadata": {}, "secrets": {}, "allowedDomains": ["string"], "opVaultId": "string", "highlightElements": true, "flashMode": true, "thinking": true, "vision": true, "systemPromptExtension": "string" } ### Response #### Success Response (202) - **id** (uuid) - The ID of the created task. - **sessionId** (uuid) - The session ID associated with the task. #### Response Example { "id": "00000000-0000-0000-0000-000000000000", "sessionId": "00000000-0000-0000-0000-000000000000" } #### Error Responses - **400** - Session is stopped or has running task. - **404** - Session not found. - **422** - Request validation failed. - **429** - Too many concurrent active sessions. ``` -------------------------------- ### Browser Constructor Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/browser.md Documentation for initializing a Browser instance with various remote/cloud configurations. ```APIDOC ## Browser(use_cloud=True) ### Description Initializes a browser instance using the Browser-Use Cloud service. This is the recommended way to use a remote browser. ### Method Constructor ### Parameters - **use_cloud** (bool) - Required - Set to True to use the cloud service. ### Request Example ```python browser = Browser(use_cloud=True) ``` ### Response Returns a Browser instance configured for cloud use. ``` ```APIDOC ## Browser(cloud_profile_id, cloud_proxy_country_code, cloud_timeout) ### Description Initializes a browser instance with advanced cloud settings to bypass captchas and geo-restrictions. ### Method Constructor ### Parameters - **cloud_profile_id** (string) - Optional - The profile ID to use for the cloud browser. - **cloud_proxy_country_code** (string) - Optional - Country code for the proxy (us, uk, fr, it, jp, au, de, fi, ca, in). - **cloud_timeout** (integer) - Optional - Timeout in minutes (free: 15, paid: 240). ### Request Example ```python browser = Browser( cloud_profile_id='your-profile-id', cloud_proxy_country_code='us', cloud_timeout=30, ) ``` ### Response Returns a Browser instance configured with the specified cloud settings. ``` ```APIDOC ## Browser(cdp_url) ### Description Initializes a browser instance using a CDP (Chrome DevTools Protocol) URL from any provider. ### Method Constructor ### Parameters - **cdp_url** (string) - Required - The CDP endpoint URL of the remote browser. ### Request Example ```python browser = Browser(cdp_url="http://remote-server:9222") ``` ### Response Returns a Browser instance connected to the specified CDP endpoint. ``` ```APIDOC ## Browser(proxy, cdp_url) ### Description Initializes a browser instance with proxy settings and an optional CDP URL. ### Method Constructor ### Parameters - **proxy** (ProxySettings) - Required - Proxy configuration object. - **cdp_url** (string) - Optional - The CDP endpoint URL of the remote browser. ### Request Example ```python from browser_use.browser import ProxySettings browser = Browser( proxy=ProxySettings( server="http://proxy-server:8080", username="proxy-user", password="proxy-pass" ), cdp_url="http://remote-server:9222" ) ``` ### Response Returns a Browser instance configured with the specified proxy and CDP settings. ``` -------------------------------- ### Basic Agent Usage with ChatBrowserUse Source: https://github.com/browser-use/browser-use/blob/main/skills/open-source/references/agent.md Basic setup for creating an agent with a task and LLM, then running it asynchronously with a maximum step limit. The default max_steps is 500, but it can be overridden in the run call. ```python from browser_use import Agent, ChatBrowserUse agent = Agent( task="Search for latest news about AI", llm=ChatBrowserUse(), ) async def main(): history = await agent.run(max_steps=500) ``` -------------------------------- ### Webhook payload example Source: https://github.com/browser-use/browser-use/blob/main/skills/cloud/references/features.md Example webhook payload for the `agent.task.status_update` event. Contains task and session IDs, status, and metadata. ```json { "type": "agent.task.status_update", "timestamp": "2025-01-15T10:30:00Z", "payload": { "task_id": "task_abc123", "session_id": "session_xyz", "status": "finished", "metadata": {} } } ``` -------------------------------- ### Get Profile OpenAPI Specification (GET /profiles/{profile_id}) Source: https://github.com/browser-use/browser-use/blob/main/CLOUD.md OpenAPI 3.1.1 specification for the GET /profiles/{profile_id} endpoint. Requires the profile_id path parameter and the X-Browser-Use-API-Key header. Returns 200 with a ProfileView on success, 404 if the profile is not found, and 422 on validation error. ```yaml openapi: 3.1.1 info: title: Get Profile version: endpoint_profiles.get_profile_profiles__profile_id__get paths: /profiles/{profile_id}: get: operationId: get-profile-profiles-profile-id-get summary: Get Profile description: Get profile details. tags: - - subpackage_profiles parameters: - name: profile_id in: path required: true schema: type: string format: uuid - name: X-Browser-Use-API-Key in: header required: true schema: type: string responses: '200': description: Successful Response content: application/json: schema: $ref: '#/components/schemas/ProfileView' '404': description: Profile not found content: {} '422': description: Validation Error content: {} components: schemas: ProfileView: type: object properties: id: type: string format: uuid name: type: - string - 'null' lastUsedAt: type: - string - 'null' format: date-time createdAt: type: string format: date-time updatedAt: type: string format: date-time cookieDomains: type: - array - 'null' items: type: string required: - id - createdAt - updatedAt ``` -------------------------------- ### Browser() Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Initializes a Browser instance with configurable options for headless mode, window size, and other display settings. ```APIDOC ## Browser Initialization ### Description Creates a Browser instance with configurable options for headless mode, window size, and other display settings. ### Method Constructor ### Endpoint `Browser()` ### Parameters #### Constructor Parameters - **headless** (bool or None) - Optional - Run browser without UI. Auto-detects based on display availability. - **window_size** (dict or ViewportSize) - Optional - Browser window size for headful mode. Use dict `{'width': 1920, 'height': 1080}` or `ViewportSize` object. - **window_position** (dict, default: `{'width': 0, 'height': 0}`) - Optional - Window position from top-left corner in pixels. - **viewport** (dict or ViewportSize) - Optional - Content area size, same format as `window_size`. Use `{'width': 1280, 'height': 720}` or `ViewportSize` object. - **no_viewport** (bool or None) - Optional - Disable viewport emulation, content fits to window size. - **device_scale_factor** (float) - Optional - Device scale factor (DPI). Set to `2.0` or `3.0` for high-resolution screenshots. - **cdp_url** (str) - Optional - CDP URL for connecting to existing browser instance (e.g., `"http://localhost:9222"`). ### Request Example ```python from browser_use import Browser browser = Browser( headless=False, window_size={'width': 1000, 'height': 700}, ) ``` ### Response #### Success Response Returns a `Browser` instance that can be passed to an `Agent`. ### Notes - The `Browser` instance also provides all Actor methods for direct browser control (page management, element interactions, etc.). ``` -------------------------------- ### Configure environment variables Source: https://github.com/browser-use/browser-use/blob/main/AGENTS.md Copy the example environment file to .env and optionally set the logging level by uncommenting the BROWSER_USE_LOGGING_LEVEL line. ```bash # Copy the example environment file cp .env.example .env # set logging level # BROWSER_USE_LOGGING_LEVEL=debug ``` -------------------------------- ### Example scheduler output Source: https://github.com/browser-use/browser-use/blob/main/examples/apps/msg-use/README.md Example JSON output from the scheduler, showing contact, original message, composed message, and scheduled time. ```json [ { "contact": "Magnus", "original_message": "Hi", "composed_message": "Hi", "scheduled_time": "2025-06-13 18:15" }, { "contact": "Camila", "original_message": "I miss her", "composed_message": "I miss you ❤️", "scheduled_time": "2025-06-14 20:00" } ] ``` -------------------------------- ### Initial login with QR code Source: https://github.com/browser-use/browser-use/blob/main/examples/apps/msg-use/README.md Run the one-time login script. Scan the QR code when the browser opens; the session is saved for future use. ```bash python login.py ```