Skip to main content

Python client for a hosted boxkite control-plane (sandbox creation, exec, files, LangChain tools).

Project description

boxkite-client

PyPI

A Python client for a hosted boxkite control-plane — create sandboxes, run commands, edit files, over HTTP. Not the boxkite package itself (boxkite-sandbox, which embeds SandboxManager against your own Kubernetes cluster) — use this to talk to someone else's running control-plane, hosted or self-hosted, over its API.

Install

pip install boxkite-client
pip install boxkite-client[langchain]  # for create_sandbox_tools

Quickstart

from boxkite_client import BoxkiteClient

client = BoxkiteClient(base_url="https://your-control-plane.example.com", api_key="bxk_live_...")

with client.sandbox(label="demo") as sb:
    result = sb.exec("python3 -c 'print(1 + 1)'")
    print(result["stdout"])  # "2\n"

    sb.file_create("notes.txt", "hello from boxkite-client\n")
    print(sb.view("notes.txt")["content"])
# sandbox is destroyed automatically here, even if an exception was raised above

Also available: AsyncBoxkiteClient (same shapes, async/await), file/directory search (ls/glob/grep), long-running background processes (start_process/get_process_output/stop_process), signed preview URLs for exposing a port, an audit-log feed (get_log/watch), interactive human takeover over a raw WebSocket, desktop (GUI) takeover over the same raw-WebSocket pattern, secret management (create_secret/list_secrets/delete_secret, for use via create_sandbox(secret_names=[...])), and a create_sandbox_tools() LangChain factory. Full reference with examples for all of these: docs/API.md.

Error handling

Every non-2xx response raises BoxkiteApiError (.status_code, .code, .message). A network-level failure raises BoxkiteConnectionError. Both subclass BoxkiteError.

from boxkite_client import BoxkiteApiError

try:
    client.exec(sandbox["id"], "echo hi")
except BoxkiteApiError as exc:
    if exc.code == "concurrent_sandbox_limit_reached":
        ...  # back off, destroy an old session, etc.

Retries

Automatic retry is off by default. Pass a RetryConfig to enable it; RetryConfig() carries sensible defaults (2 retries, exponential backoff with full jitter, Retry-After honored):

from boxkite_client import BoxkiteClient, RetryConfig

client = BoxkiteClient(base_url="...", api_key="...", retry=RetryConfig())

Only idempotent verbs (GET/HEAD/PUT/DELETE/OPTIONS) are retried, and only on a connection failure or a transient status (429, 500, 502, 503, 504) — a non-idempotent POST (create-sandbox/secret/webhook) is never retried, so this can't double-create a resource. AsyncBoxkiteClient takes the same retry= argument and awaits its backoff. Every field of RetryConfig is tunable if the defaults don't fit.

Development

pip install -e ".[dev,langchain]"
pytest tests/

Tests mock the control-plane with httpx.MockTransport — no real deployment needed.

Related tools

Moving an in-progress local Claude Code/Codex CLI/opencode session (full conversation history, not just a diff) into a fresh boxkite sandbox is handled by the separate boxkite-handoff CLI, built on this SDK — see ../docs/handoff-adapters.md and ../handoff-cli/README.md. Not yet published to PyPI.

See the root README for what boxkite is and the full self-hosting story.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boxkite_client-0.2.1.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boxkite_client-0.2.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file boxkite_client-0.2.1.tar.gz.

File metadata

  • Download URL: boxkite_client-0.2.1.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for boxkite_client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5e3a276393b67a77d0d3d58afd550eb42263632e7c75343f232c19db0230dbfb
MD5 ffb2ad501abbce91fc18e4888378629a
BLAKE2b-256 c73cee5167bedc10236c59c035ce88feb6ca0a2b13be2bfbee653fb681c695ea

See more details on using hashes here.

File details

Details for the file boxkite_client-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: boxkite_client-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for boxkite_client-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e51200ed409587144f38456ef73df7b010019c084b884c0b34dc434c93376d96
MD5 2ab977d0b7a6c29dfdfdef4225e5e103
BLAKE2b-256 bd0b4b79576f6cb0b1e2e4211847bbbe68f7672116595935668b7adf31dac831

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page