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()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
| Browserbase | Clearcote create body |
|---|---|
proxies: true, a proxy geolocation | The managed residential pool is the default; country, state, city pick the exit |
your own proxy in proxies | proxy: { server, username, password } |
a context ID with persist: true | profile: { name: "acct-1", persist: true } |
| fingerprint settings | fingerprint (a seed), timezone, locale, or identity for the same device and IP per account. Hosted browsers present a Windows device |
keepAlive, timeout | keepAlive, timeoutSec, idleTimeoutSec |
| session recording | record: true, then the recording and its replay |
| the live debugger URL | the 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:
// Stagehand v4
import { localBrowser, Stagehand } from "@browserbasehq/stagehand";
const stagehand = await Stagehand.create({ browser: await localBrowser.connect({ cdpUrl: session.connectUrl }) });# 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.