> ## Documentation Index
> Fetch the complete documentation index at: https://docs.styne.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Switch from Browserbase

> Point the Browserbase SDK at Styne by changing its base URL and key. Playwright or Puppeteer then connects to the session's connectUrl as before.

The unmodified Browserbase SDK, Python `browserbase` 1.24.0 and JavaScript `@browserbasehq/sdk` 2.25.0, creates a session, connects Playwright over CDP, loads a page and releases the session. This page shows the change you make.

## The one line

```text theme={"theme":"css-variables"}
BROWSERBASE_BASE_URL=https://api.styne.ai/browserbase
BROWSERBASE_API_KEY=<your Styne API key>
```

```python theme={"theme":"css-variables"}
from browserbase import Browserbase
from playwright.sync_api import sync_playwright

bb = Browserbase()  # reads BROWSERBASE_BASE_URL and BROWSERBASE_API_KEY
session = bb.sessions.create(project_id="any")
with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(session.connect_url)
    page = browser.contexts[0].pages[0]
    page.goto("https://example.com")
    print(page.title())
    browser.close()
bb.sessions.update(session.id, status="REQUEST_RELEASE", project_id="any")
```

## What maps

* `sessions.create`, `retrieve`, `list` (also by status) and `update` with `REQUEST_RELEASE`.
* `connectUrl` is a CDP WebSocket URL with its own token; pass it to `connectOverCDP` as it is.
* `projectId` is accepted with any value; sessions belong to the account of the API key.
* Contexts: `contexts.create`, `retrieve`, `update` and `delete`. A session created with `browserSettings.context`
  (`id`, `persist`) has the context's cookies in its browser when it starts; with `persist` the cookies are saved back
  when you release the session with `REQUEST_RELEASE`. Local storage and session storage are not carried.
* `sessions.uploads.create` puts a file in the session's browser at `/var/lib/browser/uploads/<file name>`.
* `sessions.downloads.list` returns a zip of the files the browser saved to its download directory.
* `downloads.list` (with `sessionId`, and the `createdAfter`, `createdBefore`, `filename`, `mimeType`, `minSize`,
  `maxSize`, `limit`, `offset` filters), `downloads.retrieve`, `downloads.download` and `downloads.delete` work on the
  same files one at a time, each with its SHA-256 `checksum` and MIME type, while the session runs.
* Labels: `labels.create`, `update`, `list` and `delete`; `sessions.setLabels` replaces a session's labels, `labels` on
  `sessions.create` assigns them (missing names are made), and `sessions.retrieve` with `includeLabels` lists them.
* `projects.list`, `retrieve` and `usage`: the project is the account of the API key. `concurrency` is the account's
  browser limit and `browserMinutes` the browser time of the current calendar month as it is billed.
* Navigation policies: `navigationPolicies.create`, `retrieve`, `update`, `list` and `delete`. A session created with
  `browserSettings.riskPolicyId` enforces the policy on the browser's navigations: a `domainOverrides` entry decides its
  domain and subdomains (the most specific entry wins), and every other domain follows `unknownDomainBehavior`. The
  category lists are stored with the policy. `browserSettings.allowedDomains` limits navigations to the listed domains
  and their subdomains. The browser answers a blocked navigation with `net::ERR_BLOCKED_BY_ADMINISTRATOR`.
* Certificates: `certificates.create` (one X.509 certificate, PEM or DER), `retrieve`, `list` and `delete`. A session
  created with `proxySettings.caCertificates` trusts those certificates for TLS.
* Secrets: `secrets.getPublicKey` answers the project's X25519 public key; seal a value with HPKE (RFC 9180 base mode,
  DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-256-GCM) and `secrets.create`, `update`, `retrieve`, `list` and `delete`
  keep it. A value that does not open with the project's key is refused. `functions.secrets.attach`, `list` and `detach`
  link secrets to a function id.
* Webhooks: `webhooks.create` (answers the signing `secret`), `retrieve`, `update`, `list`, `delete` and
  `rotateSecret`. Their event types are Browserbase Functions events.
* Every session is recorded. `sessions.logs.list` returns its DevTools log in Browserbase's `SessionLog` shape: one entry per
  command, page event, network request and console line, named by its CDP method (`Page.navigate`,
  `Network.responseReceived`, `Runtime.consoleAPICalled`, ...), with the request parameters, the answer and epoch-millisecond
  timestamps. `sessions.recording.retrieve` returns rrweb events: a `Meta` and a `FullSnapshot` per screencast frame, which an
  rrweb player replays as the session looked. The same recording is also read with `GET /browsers/{id}/console`, `/network`,
  `/trace` and `/replay` (see [Browsers](https://docs.styne.ai/browsers.md)).

## What is different

* Connect through `session.connectUrl`. A hard-coded `wss://connect.browserbase.com?apiKey=...` line does not reach Styne.
* Options Styne does not serve (proxies, for example) are refused with a clear error instead of being ignored.
* After release the session is gone: `retrieve` returns 404.

Styne's own browser API is described on [browsers](https://docs.styne.ai/browsers.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.