For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.chaser.sh/docs/developer-tools/llms.txt. For full documentation content, see https://docs.chaser.sh/docs/developer-tools/llms-full.txt.

# Python SDK

The official Python SDK provides access to the Chaser API for session management, workspaces, command execution, file operations, browser CDP, accounts, billing, webhooks, audit, and jobs.

## Install

```bash
pip install chaser-sdk

# Optional: CDP WebSocket support
pip install "chaser-sdk[cdp]"
```

## Create a client

```python
from chaser_sdk import ChaserClient

client = ChaserClient(api_key="sk_...", account="personal")
```

## Sessions

```python
# Create a sandbox session
session = client.sessions.create(
    session_type="sandbox",
    workspace="my-project",
)

client.sessions.wait_until_ready(session["id"])

# Create a browser session
browser = client.sessions.create(
    session_type="browser",
    ephemeral=True,
)
```

Keyword arguments are the preferred style. The legacy payload-dict form still works for backward compatibility.

## Command execution

```python
# Run in an existing session
result = client.exec.in_session(
    session["id"],
    command="npm ci && npm test",
    cwd="/workspace",
)

# Auto-provisioned ephemeral sandbox
result = client.exec.run(
    ephemeral=True,
    image="node:20-bookworm",
    command="python3 -c 'print(42)'",
)
```

## Workspaces

```python
workspace = client.workspaces.create(
    name="frontend-app",
    session_type="sandbox",
    image="ghcr.io/example/dev:latest",
)
```

## Proxy selection

```python
session = client.sessions.create(
    session_type="sandbox",
    ephemeral=True,
    proxy="socks5h://user:pass@proxy.example.com:1080",
)
```

## Files

```python
client.files.upload_text(session["id"], "/workspace/hello.txt", "hello")
text = client.files.download_text(session["id"], "/workspace/hello.txt")
```

## Browser CDP

```python
# Get the WebSocket URL
ws_url = client.browser.cdp_websocket_url(browser["id"])

# With the cdp extra: open a connection
cdp = client.browser.connect(browser["id"])
print(cdp.send("Browser.getVersion"))
cdp.close()
```

## Organization context

```python
org_client = client.with_account("Acme Engineering")
workspaces = org_client.workspaces.list()
```

## Notes

- The SDK is stdlib-first -- basic usage requires no extra dependencies
- `pip install "chaser-sdk[cdp]"` adds WebSocket CDP support
- Use the root-level `proxy` field when creating proxied sessions
- The SDK covers the core Chaser API surface. It does not include CHASM assistant management.