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.
Install
Your first box
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’sENTRYPOINT + 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
cmdto something short-lived and the box stops as soon as it finishes. A laterexecis refused until youstart()again. - A crashed main command stops the box, and nothing restarts it. There is no restart policy.
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 theasync 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, aDrop, 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
Schema version mismatch aborts the process
All BoxLite SDKs share one database at ~/.boxlite/db/boxlite.db, and a newer SDK upgrades its schema in place. An older SDK then finds a schema it does not know and stops — a Python SDK that took the database to schema v10 leaves a Node SDK expecting v8 unable to start:
try/catch around your code does not catch it.
Install the same version of every SDK you use. When you need two versions side by side, give the older 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.

