Skip to content

Migrating from Browserbase

Browserbase and Clearcote's hosted browsers are built the same way: create a session, get a CDP address, connect Playwright, Puppeteer or Stagehand. Moving is a change to the create call. What happens after the connect stays.

The change

import os
from browserbase import Browserbase
from playwright.sync_api import sync_playwright
from clearcote import launch

session = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"]).sessions.create()
browser = sync_playwright().start().chromium.connect_over_cdp(session.connect_url)
page = browser.contexts[0].pages[0]
browser = launch(cloud=True, identity="acct-1", country="us")   # creates the session and connects
page = browser.contexts[0].new_page()
page.goto("https://example.com")
browser.close()
This tab runs on your machine.

Get the key on the API keys page. One thing works differently: the connectUrl is single-use and expires 45 seconds after the create call, so connect right away and create a new session for every new connection. The browser starts as you connect, which is why the examples give Playwright a two-minute timeout.

Session settings

BrowserbaseClearcote create body
proxies: true, a proxy geolocationThe managed residential pool is the default; country, state, city pick the exit
your own proxy in proxiesproxy: { server, username, password }
a context ID with persist: trueprofile: { name: "acct-1", persist: true }
fingerprint settingsfingerprint (a seed), timezone, locale, or identity for the same device and IP per account. Hosted browsers present a Windows device
keepAlive, timeoutkeepAlive, timeoutSec, idleTimeoutSec
session recordingrecord: true, then the recording and its replay
the live debugger URLthe live view in the dashboard, which you can take control of and share

All options: Options & identities. Live view and sharing: Live view & sessions. Recordings: Recordings & events.

Stagehand and other agent frameworks

Point the framework at the connectUrl instead of a Browserbase session:

javascript
// Stagehand v4
import { localBrowser, Stagehand } from "@browserbasehq/stagehand";
const stagehand = await Stagehand.create({ browser: await localBrowser.connect({ cdpUrl: session.connectUrl }) });
python
# Browser Use
from browser_use import Agent, Browser
agent = Agent(task="Find the cheapest flight to Lisbon next Friday", llm=llm, browser=Browser(cdp_url=session["connectUrl"]))
await agent.run()

Crawl4AI and others: Frameworks & Playground. To skip the framework, send the task in plain language as an agent run and get JSON back.

The same code on your own machines

Leave cloud out and set CLEARCOTE_CLOUD=1 in production: the same launch() starts a local browser on your laptop and a hosted one in production. See Local or cloud. Hosted browsers are paid per GB of traffic from a prepaid balance: Pricing & traffic.