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

# Browserbase SDK

> Point the Browserbase SDK at querying.ai Browser, then create a session, connect Playwright over CDP, open the live view and end the session.

The Browserbase Python and TypeScript SDKs work with querying.ai Browser. Set the SDK's base URL to `https://api.querying.ai/browser` and its API key to your querying.ai `vt_` key. Features, limits, concurrency and prices are on the [Browser API](https://docs.querying.ai/browser/overview.md) page.

## 1. Set your API key

```bash theme={"theme":"css-variables"}
export QUERYING_API_KEY="vt_..."
```

## 2. Create a session and drive it

`projects.list()` returns the project of your key. Pass its `id` as `projectId` when you create and release sessions.

```python Python theme={"theme":"css-variables"}
import os

from browserbase import Browserbase
from playwright.sync_api import sync_playwright

bb = Browserbase(
    api_key=os.environ["QUERYING_API_KEY"],
    base_url="https://api.querying.ai/browser",
)

project = bb.projects.list()[0]
session = bb.sessions.create(project_id=project.id)

try:
    with sync_playwright() as p:
        cdp = p.chromium.connect_over_cdp(session.connect_url)
        context = cdp.contexts[0] if cdp.contexts else cdp.new_context()
        page = context.pages[0] if context.pages else context.new_page()
        page.goto("https://example.com")
        print(page.title())
        print("Live view:", bb.sessions.debug(session.id).debugger_fullscreen_url)
        cdp.close()
finally:
    bb.sessions.update(session.id, project_id=project.id, status="REQUEST_RELEASE")
```

```typescript TypeScript theme={"theme":"css-variables"}
import Browserbase from "@browserbasehq/sdk";
import { chromium } from "playwright-core";

const bb = new Browserbase({
  apiKey: process.env.QUERYING_API_KEY,
  baseURL: "https://api.querying.ai/browser",
});

const [project] = await bb.projects.list();
const session = await bb.sessions.create({ projectId: project.id });

try {
  const cdp = await chromium.connectOverCDP(session.connectUrl);
  const context = cdp.contexts()[0] ?? (await cdp.newContext());
  const page = context.pages()[0] ?? (await context.newPage());
  await page.goto("https://example.com");
  console.log(await page.title());
  console.log("Live view:", (await bb.sessions.debug(session.id)).debuggerFullscreenUrl);
  await cdp.close();
} finally {
  await bb.sessions.update(session.id, { projectId: project.id, status: "REQUEST_RELEASE" });
}
```

* `connectUrl` carries a token for this session, so Playwright connects with no API key. Puppeteer connects with `puppeteer.connect({ browserWSEndpoint: session.connectUrl })`.
* `sessions.debug` returns `debuggerUrl` and `debuggerFullscreenUrl` for the session, and the same pair for each open tab in `pages`. Open either URL in a browser tab to watch the session and take control.
* `REQUEST_RELEASE` ends the session and stops its charges. A session also ends when its `timeout` runs out (5 minutes by default, up to 21,600 seconds).
* Sessions solve captchas (`solveCaptchas`) and record the session (`recordSession`) by default. Recordings, logs, downloads and uploads are available through the SDK's `sessions` methods.
* A session runs headful and is charged at the Browserbase session rate, 1.38 credits per minute. See [Billing](https://docs.querying.ai/browser/overview.md#billing).

Next: [Kernel SDK](https://docs.querying.ai/browser/kernel-sdk.md), [Credits and limits](https://docs.querying.ai/concepts/credits-and-limits.md).


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