Skip to main content
Five steps get you a running box: create it, start it, run something inside, read the output, tear it down. Every language below does exactly that.

Prerequisites

  • Hardware virtualization on this machine — KVM on Linux, Apple Silicon on macOS, WSL2 on Windows. If you do not have it, the box will not start; take the BoxLite Cloud track instead, which needs none.
  • The toolchain for your language: Python 3.9+, Node.js 18+, Rust 1.88+, Go 1.24+ with CGO, or a C11 compiler.
Platform matrix, offline installs, and the CLI are on Installation.

Install

Your first box

Run it:
Each language prints its own shape. Python and Node.js, run on an Apple Silicon Mac:

What keeps the box alive

Worth knowing before you build anything longer than the script above, because it decides when a box disappears. Every box runs one main command — the image’s ENTRYPOINT + CMD, or whatever you pass as entrypoint / cmd. It runs as PID 1 inside the box, and the box stops when it exits. python:alpine above has a long-running main command, which is why exec works. Two consequences:
  • Set cmd to something short-lived and the box stops as soon as it finishes. A later exec is refused until you start() again.
  • A crashed main command stops the box, and nothing restarts it. There is no restart policy.
Which means there are two ways to run work, and they behave differently:
The main command covers the full rules, and Exit codes covers how to read what the main command exited with.

The scope that owns the box

This applies in every language, and it is the first thing that surprises people. A box is tied to the scope that owns it. In Python and Node the async with / await using block owns it, and the box is destroyed when that block exits — including when an exception unwinds it. In Rust, Go, and C the box lives until you remove it explicitly, so a program that exits early leaves it running. Two consequences:
  • Do not return a box handle out of the block that created it. The box is already gone by the time the caller sees it.
  • In Rust, Go, and C, tear down in the error path too. A defer, a Drop, or an explicit cleanup label — otherwise a crashed program leaves a box behind, and on Cloud a leftover box keeps costing you money. See What a box costs.

Next: running untrusted code

SimpleBox runs commands you wrote. For code an LLM produced, CodeBox is the type you want — it adds a language-aware execution surface on top of the same isolation. CodeBox is available in Python and Node.js. In Rust, Go, and C, run untrusted code through SimpleBox and the exec API. See Run code in a sandbox for the full treatment.

Parameters and returns

The per-language signatures, types, and return shapes live in the SDK reference:

Python

Node.js

Rust

Go

C

CLI

Troubleshooting

Cannot find native binding on Apple Silicon

The wrapper package and its platform-specific native packages are versioned independently, and @boxlite-ai/boxlite-darwin-arm64 is published up to 0.9.7 while the wrapper is at 0.10.0. Installing the wrapper at latest on an arm64 Mac therefore leaves it with no binding to load:
The install itself reports success — the failure only appears on first import. Pin both to a version that has a matching binding:
Check what is available for your platform before choosing a version:
Pinning alone is not enough if you also installed the Python SDK. All BoxLite SDKs share one database at ~/.boxlite/db/boxlite.db, and a newer SDK upgrades its schema in place. Installing boxlite 0.10.0 for Python takes that database to schema v10; the pinned Node 0.9.7 expects v8 and aborts on startup:
This is a process abort, not an exception — a try/catch around your code does not catch it.Give the pinned Node process its own data directory:

Everything else

Next steps

Box types

SimpleBox, CodeBox, BrowserBox, ComputerBox — which type for which job.

Agent tools

Run code, drive a PTY, a browser, or a desktop from your agent.

Architecture

What actually happens when you call exec.

BoxLite Cloud

The same SDK against a hosted runtime — no local virtualization.