Open source · self-hosted
curl -fsSL https://carton.sh/install | shimport { Carton } from "carton"; const carton = new Carton(); const sandbox = await carton.sandboxes.create({ source: { type: "image", image: "python@sha256:…" }, placement: { target: "e2b" }, // the only line that changes }); const exec = await sandbox.exec(["python", "agent.py"]); console.log(exec.stdout); await sandbox.destroy();
$ carton create python:3.12 --name agent { "id": "sbx_01JD…", "name": "agent", "target": "e2b", … } // picked by your route $ carton exec agent -- python agent.py agent ready, 3 tools loaded $ carton destroy agent
POST /v1/sandboxes Idempotency-Key: 4f1c… { "source": { "type": "image", "image": "python@sha256:…" }, "placement": { "target": "e2b" } } 201 { "id": "sbx_01JD…", "target": "e2b", … } POST /v1/sandboxes/sbx_01JD…/executions Idempotency-Key: 9a2e… { "argv": ["python", "agent.py"] } 201 { "id": "exec_01JD…", "phase": "running", … } DELETE /v1/sandboxes/sbx_01JD… 204
One API in. Every sandbox provider out.
Your agents call carton from whatever they speak. carton picks a provider, holds the key, and keeps track of the sandbox, wherever it lands.
Let carton pick the provider
List your targets and the order to try them in. Your agent asks for a sandbox, and carton places it on the first target that fits.
targets:
e2b-main: { adapter: e2b, credential: secret:E2B_API_KEY }
daytona: { adapter: daytona, credential: secret:DAYTONA_API_KEY }
local: { adapter: docker, host: agent:local }
routes:
default: [e2b-main, daytona, local]A route step can sort by your order, by estimated hourly price or by spreading load across hosts. Set max_price_usd_per_hour and carton skips any offering above it. Pin a sandbox to one target when you need to.
Fall back when a provider is down
If a create fails before the sandbox starts, carton tries the next target on the route and puts the failing one in cooldown. After the cooldown, carton sends one probe request before it trusts that target again.
A create that times out is harder: the provider may have started a machine you can’t see. carton looks for it on the original target before trying anywhere else, and returns the error if it can’t tell. One request can’t leave you paying for two sandboxes.
$ carton resolve python:3.12 --size mediumcarton resolve prints the candidates, the one carton would pick and why it skipped the rest. It calls no provider.
Safe for agents that retry
- Retries return the same sandbox
- Every POST takes an
Idempotency-Key. An agent that times out and sends the create again gets the first sandbox back. - Errors say whether to retry
- The HTTP API and
carton --jsonreturn one error object with aretryableflag, on every provider. - Unsupported calls fail up front
- Each adapter declares what its provider can do. Ask for something it can’t and you get
unsupported_capabilitybefore your agent depends on it. - Units in every field name
max_lifetime_seconds,idle_timeout_seconds,exec_timeout_ms.
Your own machines are providers too
Run carton agent on a workstation, a CI runner or a GPU box and it becomes a target next to your hosted accounts. Develop against Docker on your own machine, then change the route instead of your code.
carton records each target’s isolation boundary, so minimum_isolation: vm in your policy keeps untrusted code off container targets.
Bring your devcontainer.json
version: 1
environment:
devcontainer: .devcontainer/devcontainer.json
checks:
- name: node
run: node --version
$ carton upcarton up builds your devcontainer, Dockerfile or image once, prepares it on each target and creates a sandbox that reports ready when your checks pass. Keys carton can’t honour, like privileged or mounts, fail before anything builds.
Keep provider keys out of your agents
carton holds your provider keys. Agents and CI jobs get carton tokens that you scope and revoke without touching the provider account.
Every sandbox gets a lifetime and an idle deadline from your policy, and carton destroys it when one passes. carton ls shows what’s running across every target.
Providers
carton reaches each provider through an adapter.
Hosted
- E2B
- Modal
- Daytona
- Vercel Sandbox
- Runloop
- Northflank
- Morph
- Blaxel
- Cloudflare
- CodeSandbox
Your machines
- Docker
- Podman
- Apple container
- Firecracker
- nono
- bubblewrap
Need another one? The adapter kit handles polling, retries and error mapping, so an adapter is mostly the provider’s own API calls.
Host it yourself, or let us
Self-hosted
Free and open source. One binary for the server, the CLI and the agent. Your keys stay on your infrastructure.
Install cartoncarton Cloud
The same server, run by us. You bring your provider keys and we send you a sign-in link.
Questions
Is carton a sandbox provider?
No. carton runs on top of the providers you already pay for, and on your own machines. It gives them one API, keeps track of what is running and holds the keys.
How is this different from a sandbox SDK wrapper?
carton is a server. It holds the keys, routes and falls back between providers, and tracks every sandbox, so your agents and CI jobs share one inventory and one policy. A client library runs inside each process and can’t do that.
Do providers have to support carton?
No. carton calls each provider’s existing API through an adapter.
What happens when a provider can’t do something?
Every adapter declares its provider’s capabilities. Calling one it doesn’t have returns unsupported_capability, and carton never emulates the feature.
Can a running sandbox move to another provider?
No. carton picks the provider when it creates a sandbox. You can copy files between sandboxes, but running processes and memory stay where they are.
Where do my provider keys live?
In carton’s secret store on your server. Agents and CI jobs get carton tokens, which you can scope and revoke without touching the provider account.
Is it safe to run untrusted code on my own machines?
carton records the isolation boundary of every target: vm, gvisor, container or namespaces. Your policy decides which code may run where, for example minimum_isolation: vm.