Create a code sandbox
create_sandboxStart an isolated Firecracker microVM sandbox (ready in about 1 s; Linux with Python 3.12 + pip, Node.js 22 + npm, bash, git and curl; internet egress allowed so pip/npm install and git clone work; no inbound ports, SMTP blocked). mode: "ephemeral" (default — billed per second, minimum 60 s, auto-deleted after idle_timeout s of inactivity, default 300, max lifetime ttl up to 24 h) or "persistent" (billed per started hour, a month costs at most 730 h minus 25%; survives host maintenance; max ttl 30 days). tariff (default small): micro 0.25 vCPU/512 MB RAM/3 GB disk $0.0165/h · small 0.5 vCPU/1 GB RAM/5 GB disk $0.033/h · standard 1 vCPU/2 GB RAM/10 GB disk $0.066/h · plus 2 vCPU/4 GB RAM/15 GB disk $0.132/h · pro 4 vCPU/8 GB RAM/20 GB disk $0.264/h · max 8 vCPU/16 GB RAM/40 GB disk $0.528/h (pick plus or bigger for heavy pip installs such as torch, builds or data work). Headless browsers (Chromium via Playwright/Puppeteer) need standard or bigger — micro/small do not have enough RAM. If the host is busy the call fails with 503 capacity (Retry-After) — retry or choose a smaller tariff. Charged from the same prepaid balance as VPS (no subscription). Empty balance → 402 insufficient_balance (top up with topup_balance). If the balance runs out later, persistent sandboxes are paused (memory+disk snapshot, not billed) and resume automatically after a top-up; paused snapshots are deleted after 14 days. The response has state: "running" and ready: true once you can exec (usually immediately); if it says starting, call get_sandbox after 1-2 s. Always kill_sandbox when done. Requires: token + balance (a new account's first sandbox gets a free $1 trial credit once the account email is confirmed with a 6-digit code — 402 with trial=email_unverified until then: the human confirms it in the dashboard, or POST /auth/email/verification/send, then /confirm {code}; no top-up needed; until the first real top-up: micro or small, ephemeral, up to 2 at once, each deleted after 20 min (the $1 credit itself lasts 14 days) → 403 trial_tariff / trial_persistent, 429 trial_limit). Typical errors: 402 insufficient_balance → topup_balance; 503 capacity → retry or smaller tariff.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Environment variables for every command and code run in this sandbox, e.g. {"OPENAI_API_KEY": "sk-..."}. Stored encrypted; responses show only the names (env_keys). Up to 64 variables, 64 KB in total. | |
| ttl | No | Maximum lifetime in seconds (ephemeral up to 86400, persistent up to 2592000). | |
| mode | No | ||
| tariff | No | Tariff: micro | small | standard | plus | pro | max (see sandbox_pricing). | |
| idle_timeout | No | Seconds of inactivity before an ephemeral sandbox is deleted (default 300, max 3600). 0 = none (persistent only). |