Official TypeScript and Python clients for the public BoxCompute API.
Both SDKs use API keys and the customer-facing https://api.boxcompute.ai/api/v2
contract. They never connect to BoxCompute's private sandbox control plane.
Hosted BoxCompute is currently invite-only. Book a 15-minute call with Farhan to request an invite, then create an API key in the BoxCompute app.
npm install @boxcompute/sdkimport { BoxCompute } from "@boxcompute/sdk";
const boxcompute = new BoxCompute({ apiKey: process.env.BOXCOMPUTE_API_KEY! });
const [existingWorkspace] = await boxcompute.workspaces.list();
const workspace = existingWorkspace ?? await boxcompute.workspaces.create({
name: "SDK quickstart",
idempotencyKey: "sdk-quickstart-workspace-v1",
});
const sandbox = await boxcompute.sandboxes.create({ workspaceId: workspace.id });
try {
const result = await boxcompute.sandboxes.execute(sandbox.id, {
argv: ["python3", "-c", "print(sum(range(100000)))"],
});
console.log(result.stdout);
} finally {
await boxcompute.sandboxes.delete(sandbox.id);
}See the TypeScript package guide.
pip install boxcomputeimport os
from boxcompute import BoxCompute
with BoxCompute(api_key=os.environ["BOXCOMPUTE_API_KEY"]) as boxcompute:
workspaces = boxcompute.workspaces.list()
workspace = workspaces[0] if workspaces else boxcompute.workspaces.create(
name="SDK quickstart",
idempotency_key="sdk-quickstart-workspace-v1",
)
sandbox = boxcompute.sandboxes.create(workspace_id=workspace.id)
try:
result = boxcompute.sandboxes.execute(
sandbox.id,
argv=["python3", "-c", "print(sum(range(100000)))"],
)
print(result.stdout, end="")
finally:
boxcompute.sandboxes.delete(sandbox.id)See the Python package guide.
See the API overview for the complete cross-language surface, plus the guides for authentication and idempotent retries.
Use boxcompute.billing.get() in TypeScript or Python to read remaining
credit, all-time settled AI/compute spending, reservations and running estimates.
Use boxcompute.billing.transactions() for paginated wallet entries. Both
require usage:read. Amounts are integer micro-USD (1_000_000 = $1);
balance.availableMicros (Python: available_micros) is null when running
compute estimates cannot be read. See the API overview
for filtering and pagination.
openapi/boxcompute-v2.json is the versioned SDK contract. TypeScript types and
Python models are generated from this snapshot. CI rejects generated-code drift.
The npm and PyPI packages have independent versions and trusted-publishing
workflows. Releases are immutable and can only be published from main through
their protected GitHub environments.
See the changelog for package versions, security updates, and consumer actions.
Repository and registry administrators should follow the release setup before publishing the first versions.
npm ci
npm run generate
npm run check:openapi
npm run typecheck
npm test
python -m venv .venv
.venv/bin/pip install -e 'packages/python[test]'
.venv/bin/python scripts/generate-python-models.py
.venv/bin/ruff format --check packages/python/src packages/python/tests scripts/generate-python-models.py
.venv/bin/ruff check packages/python
.venv/bin/mypy packages/python/src
.venv/bin/pytest packages/python/testsSet BOXCOMPUTE_OPENAPI_SOURCE to a local OpenAPI file when syncing from a
web-agent checkout; otherwise npm run sync:openapi downloads the deployed
contract.
Keep API keys in a secret manager or environment variable and use these SDKs
from trusted server-side code. Do not embed bc_live_... keys in browser or
mobile application bundles. See SECURITY.md for reporting.