Sandbox.create({ runtime, timeout, resources }) | Sandbox.create(template="base", timeout=<seconds>). base carries Python 3, Node 22, git, curl and wget, with 4 vCPU and 8 GiB memory; timeout is in seconds (Vercel’s is in milliseconds) |
source: { type: "git", url } | sbx.commands.run("git clone <url> /home/user/app") |
sandbox.runCommand("npm", ["install"], { cwd, env, sudo }) | sbx.commands.run("npm install", cwd=..., envs={...}, user="root"); the result has stdout, stderr and exit_code |
runCommand({ detached: true }) | sbx.commands.run(cmd, background=True) |
sandbox.writeFiles([{ path, content }]), readFile, mkDir | sbx.files.write(path, content), sbx.files.read(path), sbx.files.make_dir(path) |
ports: [3000] and sandbox.domain(3000) | No port list to declare. sbx.get_host(3000) answers 3000-<id>.styne.ai; the URL https://3000-<id>.styne.ai opens without a token |
sandbox.snapshot() | POST /sandboxes/{id}/snapshots with {"name": "<name>"} (snapshots) |
source: { type: "snapshot", snapshotId } | POST /sandboxes with {"snapshot": "<name>"} instead of templateID; a sandbox from a snapshot starts in 0.07 to 0.26 seconds |
snapshot.delete() | DELETE /snapshots/{name} answers 204 |
sandbox.stop() | sbx.kill() ends the sandbox; sbx.pause() keeps its state and Sandbox.connect(id) resumes it |
sandbox.extendTimeout(ms) | sbx.set_timeout(<seconds>) |
Sandbox.get({ name }), Sandbox.list({ tags }) | Sandbox.connect(id); send metadata (a map of strings) on create and list by it |
networkPolicy | network.allowOut and network.denyOut on create, and allowInternetAccess: false to close the internet (Switch from E2B) |