Run untrusted code
Execute an arbitrary Python snippet in a disposable, resource-capped container — and prove it's isolated.
The canonical sandbox use case: you have code you didn't write — an LLM generated it, or a user submitted it — and you need to run it without trusting it. Each snippet gets its own throwaway container with a hard CPU and memory cap, a wall-clock timeout, and a filesystem that shares nothing with the host or any other sandbox.
Edit the snippet, hit Run workflow, and watch it happen against a live sandbox.
Not connected
createSandboxwriteFileexecdeleteSandbox~30s
Connect to a sandbox server above to run this.
What just happened
- Create —
client.sandbox({ image: "node:22", resources: { cpu, memory } })spun up a fresh container. Resources are required; the server rejects an unbounded sandbox. - Write —
sb.writeFile("/work/snippet.py", …)put your code inside it.sb.readFileread it straight back. - Run —
sb.exec("timeout 20 python3 snippet.py")streamed stdout as it was produced. Atimeoutexit code of124means the guard fired. - Isolation — a different hostname and a filesystem that doesn't contain the host's files. Nothing the snippet does escapes the container.
- Destroy —
sb.close()deletes the container. The safety-net auto-expiry would have done it anyway.
For the batch version — many snippets, failures captured as data instead of crashing the run — see the Untrusted Code Execution cookbook.