Sandboxes
Run untrusted or generated code in isolated containers.
npx extraorbital add sandboxA sandbox resource is a place to run code you do not want on your own servers: an agent's generated code, a user's script, a build. You get a token for the official Modal SDK; your code starts sandboxes, runs commands in them and reads their output directly. Nothing goes through ExtraOrbital.
- 01 / Run the commandGet the service
- 02 / Read your .envUse its credentials
- 03 / Connect your appCall the SDK or API
Limits
| Limit | Free · Prototype | Paid |
|---|---|---|
| Sandbox resources | 10 | No plan count cap |
| Compute | From the $5.00 account allowance | $0.1419 / core-hour, $0.024 / GiB-hour |
| Bandwidth | From the $5.00 account allowance | $0.04 / GiB of egress |
| Spend | Idle environments are free | Shared team credit or budget |
Free allowances are shared across the account. Provider limits still apply on paid plans.
Use it
import { ModalClient } from "modal";
const modal = new ModalClient();
const app = await modal.apps.fromName("my-app", { createIfMissing: true });
const sandbox = await modal.sandboxes.create(app, modal.images.fromRegistry("python:3.12-slim"));
const run = await sandbox.exec(["python", "-c", "print(2 + 2)"]);
console.log(await run.stdout.readText());
await sandbox.terminate();The token runs code that you pay for: keep it server-side. Each machine and each deploy target gets a credential of its own.
Environment variables
The CLI writes these to .env or an existing .env.local. The Modal SDKs (TypeScript, Python
and Go) read them as they are.
| Variable | Purpose |
|---|---|
MODAL_TOKEN_ID | Identifies the credential |
MODAL_TOKEN_SECRET | Authenticates it; keep it private |
MODAL_ENVIRONMENT | The resource's environment, where every sandbox and app of the resource runs |
Specifics
Budget
Set a spending ceiling per calendar month (UTC) with maxBudgetCents. Past it, running sandboxes
stop and new ones are refused until the next month or a higher ceiling. Spend is read a few
minutes late, so a resource can pass its ceiling by what it spends in that time.
Read-only credentials
A read credential lists and reads what runs in the environment and cannot start anything.
GPUs and public URLs
GPUs are off by default. Web endpoints need Modal's proxy authentication: an environment refuses unauthenticated web endpoints. Use sandboxes for code you run, not to host public sites.
Extra environments
A resource is one environment. An environment created with a resource's credential is removed within a minute, and what ran in it is billed to that resource. Add another resource for another environment.
Freeze
Freezing a resource stops every sandbox and app in it and refuses its credentials within a few seconds. Unfreezing gives the same credentials back; deploy stopped apps again.
Pricing
| Usage | Paid rate |
|---|---|
| Compute | $0.1419 / core-hour, $0.024 / GiB-hour |
| Bandwidth | $0.04 / GiB of egress |
| Spend | Idle environments are free |
See pricing for team subscription fees, allowances, and billing terms. Plans and billing ↗