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

# Create Browserbase Session

<Note>
  **Internal Service** — This is not an HTTP endpoint. It's called by the browser-session route.
</Note>

## Purpose

Creates a new Browserbase session via their API and returns the live view URL.

## Function Signature

```python theme={null}
async def _create_browserbase_session(
    api_key: str, 
    project_id: str, 
    region: str, 
    viewport: Optional[dict] = None
) -> dict
```

## Parameters

| Parameter    | Type   | Description                                                     |
| ------------ | ------ | --------------------------------------------------------------- |
| `api_key`    | `str`  | Browserbase API key                                             |
| `project_id` | `str`  | Browserbase project ID                                          |
| `region`     | `str`  | AWS region (us-west-2, us-east-1, eu-central-1, ap-southeast-1) |
| `viewport`   | `dict` | Optional viewport dimensions                                    |

## Returns

```python theme={null}
{
    "session_id": "sess_abc123...",
    "connect_url": "wss://connect.browserbase.com?...",
    "live_url": "https://www.browserbase.com/devtools/..."
}
```

## API Calls

1. **Create Session** - `POST /v1/sessions`
2. **Get Debug URL** - `GET /v1/sessions/{id}/debug`

## Session Options

```python theme={null}
{
    "projectId": project_id,
    "region": region,
    "keepAlive": True,  # Keeps session alive after disconnect
    "browserSettings": {
        "viewport": {"width": 1280, "height": 720}
    }
}
```

## Code Location

```
src/website/browser_session/routes.py
# Lines 115-189: _create_browserbase_session()
```
