This guide is dedicated to running your own browser-use agent while connecting to an Anchor browser. To use the embedded browser use capability, refer to AI task completion
1

Step one - Create an Anchor browser session

import requests

ANCHOR_API_KEY = "YOUR_ANCHOR_API_KEY"

response = requests.post(
    "https://api.anchorbrowser.io/v1/sessions",
    headers={
        "anchor-api-key": ANCHOR_API_KEY,
        "Content-Type": "application/json",
    },
    json={
      "browser": {
        "headless": {"active": False} # Use headless false to view the browser when combining with browser-use
      }
    }).json()

# Access the data object from the response
session_data = response["data"]

Returns:

{
  "data": {
    "id": "<string>",
    "cdp_url": "<string>",
    "live_view_url": "https://live.anchorbrowser.io?sessionId=<session_id>"
    // Use the live view URL to view the browser session in real-time
  }
}
2

Point browser-use to the Anchor browser instance

from browser_use import BrowserConfig

config = BrowserConfig(
    cdp_url=f"wss://connect.anchorbrowser.io?apiKey={ANCHOR_API_KEY}&sessionId={session_data['id']}"
    # Use the session ID returned from the first step
)
3

Optional - Live view the browser

Use the live_view_url returned on the first step to view the browser session in real-time, or to embed it as a UI component

<iframe src="https://live.anchorbrowser.io?sessionId=<session_id>" sandbox="allow-same-origin allow-scripts" allow="clipboard-read; clipboard-write" style="border: 0px; display: block; width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;"></iframe>