Python SDK

View as Markdown

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

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

Create a client

1from chaser_sdk import ChaserClient
2
3client = ChaserClient(api_key="sk_...", account="personal")

Sessions

1# Create a sandbox session
2session = client.sessions.create({
3 "session_type": "sandbox",
4 "workspace": "my-project",
5})
6
7client.sessions.wait_until_ready(session["id"])
8
9# Create a browser session
10browser = client.sessions.create({
11 "session_type": "browser",
12 "ephemeral": True,
13})

Command execution

1# Run in an existing session
2result = client.exec.in_session(session["id"], {
3 "command": "npm ci && npm test",
4 "cwd": "/workspace",
5})
6
7# Auto-provisioned ephemeral sandbox
8result = client.exec.run({
9 "ephemeral": True,
10 "image": "node:20-bookworm",
11 "command": "python3 -c 'print(42)'",
12})

Workspaces

1workspace = client.workspaces.create({
2 "name": "frontend-app",
3 "session_type": "sandbox",
4 "image": "ghcr.io/example/dev:latest",
5})

Files

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

Browser CDP

1# Get the WebSocket URL
2ws_url = client.browser.cdp_websocket_url(browser["id"])
3
4# With the cdp extra: open a connection
5cdp = client.browser.connect(browser["id"])
6print(cdp.send("Browser.getVersion"))
7cdp.close()

Organization context

1org_client = client.with_account("Acme Engineering")
2workspaces = 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
  • The SDK covers the core Chaser API surface. It does not include CHASM assistant management.