Migrating from E2B, Daytona & Modal
Switch in 10 seconds with 5 drop-in compatibility adapters or run the automated stateset migrate CLI codemod.
Migrating from E2B, Daytona & Modal to StateSet Sandbox
Switch existing E2B, Daytona, or Modal agent and GPU workloads to StateSet Sandbox in under a minute — either with a 1-line drop-in compatibility adapter or a native Next-Gen SDK upgrade that unlocks CoW CSI Hot-Fork Repo Caches, Ephemeral Service Sidecars, Closed-Loop Managed Swarms, Zero-Exposure Secrets, BYOC VPC Runners, and Spot GPU Batch .map().
Try it in your browser (no signup required): - Interactive Playground & Code Migrator — paste E2B, Daytona, or Modal snippets to preview instant drop-in and native migrations, explore Swarm DAGs, and simulate Spot GPU batch savings. - Compare vs E2B, Daytona & Modal — compare StateSet Sandbox across all 10 pillars, cold-start latency, GPU pricing, security isolation, and monthly fleet TCO.
Choose Your Migration Track: Option A vs Option B
| Dimension | Option A: 10-Second 1-Line Drop-In Compat | Option B: Native Next-Gen Upgrade |
|---|---|---|
| Time to first run | ~10 seconds (install adapter + swap 1 import line) | 5–15 minutes (automated via stateset migrate --mode native) |
| Code changes required | Import line only — existing call sites stay intact | Native @stateset/sandbox-sdk / stateset-sandbox APIs |
| CLI codemod command | npx @stateset/sandbox-cli migrate --from auto --mode compat --apply | npx @stateset/sandbox-cli migrate --from auto --mode native --apply |
| Packages (5 compat adapters) | @stateset/e2b-compat, stateset-e2b-compat, @stateset/daytona-compat, stateset-daytona-compat, stateset-modal-compat | @stateset/sandbox-sdk, stateset-sandbox, @stateset/byoc-runner |
| Immediate StateSet upgrades | Zero-exposure Secret.from_name, Pillar 1 repoCacheId / repo_cache_id hot-fork, Pillar 3 services sidecars, Pillar 9 Spot GPU .map() | Everything in Option A plus Managed Swarms, Wave Approval, Time-Travel Replay & Live Takeover, Multi-Harness Routing, Policy-as-Code Gates, Ed25519 SLSA v1.0 Provenance, BYOC VPC Runners |
| Escape hatch | Every adapter exposes .native or .client for incremental native calls | Direct full control-plane access |
| Best for | Validating latency, stability, and cost in production today with zero risk | New services or teams standardizing on StateSet's full 10-pillar platform |
Prerequisites
Create an API key under API Keys and export it in your shell:
export STATESET_API_KEY="YOUR_STATESET_API_KEY"
# Optional: point at a self-hosted or regional StateSet controller
# export STATESET_BASE_URL="https://api.sandbox.stateset.app"Automated CLI Codemod (stateset migrate)
Scan any TypeScript or Python repository, auto-detect E2B, Daytona, or Modal usage, inspect unified diffs first, and apply safe rewrites in either compat or native mode:
# Auto-detect providers and preview unified diffs (dry run)
npx @stateset/sandbox-cli migrate ./src --from auto --diff
# Option A: 1-line drop-in compat mode
npx @stateset/sandbox-cli migrate ./src --from auto --mode compat --apply
# Option B: Native Next-Gen SDK mode
npx @stateset/sandbox-cli migrate ./src --from auto --mode native --apply
# Machine-readable JSON report for CI / PR review
npx @stateset/sandbox-cli migrate ./src --from auto --jsonSupported --from values: auto, e2b, modal, daytona. Supported --mode values: compat, native.
1. E2B to StateSet
CLI Migration
npx @stateset/sandbox-cli migrate ./src --from e2b --diff
npx @stateset/sandbox-cli migrate ./src --from e2b --mode compat --apply
npx @stateset/sandbox-cli migrate ./src --from e2b --mode native --applyTypeScript (@stateset/e2b-compat vs @stateset/sandbox-sdk)
npm install @stateset/e2b-compat # Option A (Drop-in)
# or
npm install @stateset/sandbox-sdk # Option B (Native Next-Gen)Before (E2B):
import { Sandbox } from '@e2b/code-interpreter';
const sandbox = await Sandbox.create({ timeoutMs: 300_000 });
try {
const { stdout } = await sandbox.commands.run('python3 -c "print(6 * 7)"');
await sandbox.files.write('/home/user/notes.txt', stdout);
const execution = await sandbox.runCode('print(21 * 2)');
console.log(execution.logs.stdout.join(''));
} finally {
await sandbox.kill();
}Option A — 1-Line Drop-In Compat (@stateset/e2b-compat):
// Swap the single import line — all existing call sites continue working unchanged:
import { Sandbox } from '@stateset/e2b-compat';/home/user/...file paths automatically map to/workspace/..., andsandbox.nativeexposes the underlying@stateset/sandbox-sdkSandboxwhenever you want to call native APIs likesandbox.native.pause(), snapshots, or tunnels.
Option B — Native Next-Gen (@stateset/sandbox-sdk):
import { Sandbox } from '@stateset/sandbox-sdk';
await using sandbox = await Sandbox.create({
template: 'python-basic',
timeout_seconds: 300,
});
const { stdout } = await sandbox.exec('python3 -c "print(6 * 7)"');
await sandbox.writeFile('/workspace/notes.txt', stdout);
const saved = await sandbox.readFile('/workspace/notes.txt');
console.log(saved.trim()); // 42Python (stateset-e2b-compat vs stateset-sandbox)
pip install stateset-e2b-compat # Option A (Drop-in)
# or
pip install stateset-sandbox # Option B (Native Next-Gen)Before (E2B):
from e2b_code_interpreter import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run('python3 -c "print(6 * 7)"')
sandbox.files.write("/home/user/notes.txt", result.stdout)
execution = sandbox.run_code("print(21 * 2)")
print("".join(execution.logs.stdout))Option A — 1-Line Drop-In Compat (stateset-e2b-compat):
# Swap the single import line (async code uses AsyncSandbox):
from stateset_e2b_compat import SandboxOption B — Native Next-Gen (stateset-sandbox):
from stateset_sandbox import Sandbox
with Sandbox.create(template="python-basic", timeout_seconds=300) as sandbox:
result = sandbox.exec('python3 -c "print(6 * 7)"')
sandbox.write_file("/workspace/notes.txt", result.stdout)
print(sandbox.read_file("/workspace/notes.txt").strip()) # 422. Daytona to StateSet
Both Daytona compatibility adapters (@stateset/daytona-compat and stateset-daytona-compat) accept StateSet's Pillar 1 Hot-Fork Repo Caches (repoCacheId / repo_cache_id) and Pillar 3 Declarative Ephemeral Service Sidecars (services) directly inside daytona.create(...) — giving you millisecond warm forks and ephemeral Postgres, Redis, and Playwright sidecars even in Option A.
CLI Migration
npx @stateset/sandbox-cli migrate ./src --from daytona --diff
npx @stateset/sandbox-cli migrate ./src --from daytona --mode compat --apply
npx @stateset/sandbox-cli migrate ./src --from daytona --mode native --applyTypeScript (@stateset/daytona-compat + Pillar 1 Hot-Fork & Pillar 3 Sidecars)
npm install @stateset/daytona-compatBefore (Daytona):
import { Daytona } from '@daytonaio/sdk';
const daytona = new Daytona();
const sandbox = await daytona.create({
language: 'typescript',
envVars: { NODE_ENV: 'test' },
resources: { cpu: 2, memory: 4 },
autoStopInterval: 15,
});
try {
await sandbox.git.clone('https://github.com/acme/monorepo.git', '/workspace/repo', 'main');
const res = await sandbox.process.executeCommand('npm test', '/workspace/repo');
console.log(res.exitCode, res.result);
const preview = await sandbox.getPreviewLink(3000);
console.log(preview.url);
} finally {
await daytona.delete(sandbox);
}Option A — 1-Line Drop-In Compat + Pillar 1 Hot-Fork & Pillar 3 Sidecars:
import { Daytona } from '@stateset/daytona-compat';
const daytona = new Daytona();
const sandbox = await daytona.create({
language: 'typescript',
// Pillar 1: instant hot-fork from a pre-warmed per-repo CSI cache
repoCacheId: 'rc_01j9example',
// Pillar 3: boot real stateful sidecars alongside your workspace
services: [
'redis',
{ preset: 'postgres', database: 'app_test', seed_sql: 'CREATE TABLE items (id INT);' },
],
envVars: { NODE_ENV: 'test' },
autoStopInterval: 15,
});
try {
console.log('Hot-forked in ms:', sandbox.repoCache?.forkMs);
console.log('Sidecar env vars:', sandbox.serviceEnvVars); // { DATABASE_URL, REDIS_URL }
const res = await sandbox.process.executeCommand('npm test', '/workspace/repo');
console.log(res.exitCode, res.result);
const preview = await sandbox.getPreviewLink(3000);
console.log(preview.url, preview.token);
} finally {
await daytona.delete(sandbox);
}Option B — Native Next-Gen (@stateset/sandbox-sdk):
import { StateSetSandbox } from '@stateset/sandbox-sdk';
const client = new StateSetSandbox({
baseUrl: process.env.STATESET_BASE_URL ?? 'https://api.sandbox.stateset.app',
authToken: process.env.STATESET_API_KEY ?? '',
});
// Pillar 1: hot-fork isolated worker sandboxes from a warm repo cache
const forked = await client.repoCaches.fork('rc_01j9example', { count: 2 });
const sandboxId = forked.forks[0].sandbox_id;
// Pillar 3: attach ephemeral Postgres + Redis sidecars and branch DB
const provisioned = await client.serviceSidecars.provision(sandboxId, [
{ preset: 'redis' },
{ preset: 'postgres', database: 'app_test' },
]);
const pgService = provisioned.services.find((s) => s.preset === 'postgres');
if (pgService) {
await client.serviceSidecars.branchDatabase(sandboxId, pgService.id, {
branch_name: 'worker_checkout_fix',
});
}
const result = await client.execute(sandboxId, {
command: 'npm test',
working_dir: '/workspace/repo',
});
console.log(result.exit_code, result.stdout);Python (stateset-daytona-compat + Pillar 1 Hot-Fork & Pillar 3 Sidecars)
pip install stateset-daytona-compatBefore (Daytona Python):
from daytona_sdk import CreateSandboxParams, Daytona, Resources
daytona = Daytona()
sandbox = daytona.create(
CreateSandboxParams(
language="python",
env_vars={"APP_ENV": "test"},
resources=Resources(cpu=2, memory=4, disk=10),
auto_stop_interval=15,
)
)
res = sandbox.process.exec("pytest -q")
print(res.exit_code, res.result)
daytona.delete(sandbox)Option A — 1-Line Drop-In Compat + Pillar 1 Hot-Fork & Pillar 3 Sidecars:
from stateset_daytona_compat import CreateSandboxParams, Daytona
daytona = Daytona()
with daytona.create(
CreateSandboxParams(
language="python",
# Pillar 1: instant hot-fork from a warm per-repo cache
repo_cache_id="rc_01j9example",
# Pillar 3: declarative Postgres + Redis + Playwright sidecars
services=[
"redis",
{"preset": "postgres", "database": "app_test", "seed_sql": "CREATE TABLE items (id INT);"},
"playwright",
],
env_vars={"APP_ENV": "test"},
)
) as sandbox:
print("Hot-fork ms:", sandbox.repo_cache.fork_ms if sandbox.repo_cache else None)
print("Sidecar env:", sandbox.service_env_vars)
res = sandbox.process.exec("pytest -q")
print(res.exit_code, res.result)Option B — Native Next-Gen (stateset-sandbox):
import os
from stateset_sandbox import StateSetSandbox
client = StateSetSandbox(
base_url=os.environ.get("STATESET_BASE_URL", "https://api.sandbox.stateset.app"),
auth_token=os.environ["STATESET_API_KEY"],
)
forked = client.repo_caches.fork("rc_01j9example", count=2)
sandbox_id = forked.forks[0].sandbox_id
client.services.provision(
sandbox_id,
services=[
{"preset": "redis"},
{"preset": "postgres", "database": "app_test"},
],
)
res = client.execute(sandbox_id, command="pytest -q")
print(res.exit_code, res.stdout)3. Modal to StateSet
stateset-modal-compat maps Modal's @app.function(...), .remote(), .map(), .starmap(), Image, Sandbox, and Secret.from_name(...) directly onto StateSet Pillar 9 serverless Spot GPU client.batch.map(...) and StateSet's zero-exposure organization secret pipeline.
CLI Migration
npx @stateset/sandbox-cli migrate ./src --from modal --diff
npx @stateset/sandbox-cli migrate ./src --from modal --mode compat --apply
npx @stateset/sandbox-cli migrate ./src --from modal --mode native --applyPython (stateset-modal-compat vs Native client.batch.map(...))
pip install stateset-modal-compat # Option A (Drop-in)
# or
pip install stateset-sandbox # Option B (Native Next-Gen)Before (Modal):
import modal
app = modal.App("gpu-eval")
image = modal.Image.debian_slim(python_version="3.11").pip_install("torch", "transformers")
@app.function(
image=image,
gpu="H100",
secrets=[modal.Secret.from_name("hf-token")],
max_containers=32,
timeout=300,
retries=2,
)
def score(prompt: str) -> dict[str, object]:
return {"prompt": prompt, "score": 0.99}
with app.run():
outputs = list(score.map(["prompt-1", "prompt-2", "prompt-3"], order_outputs=True))Option A — 1-Line Drop-In Compat (stateset-modal-compat):
# Swap the single import line:
import stateset_modal_compat as modalWhat happens automatically under the hood:
- Pillar 9 Spot GPU
.map():gpu="H100"normalizes viaGPU_SKU_MAPtocompute_sku="nvidia-h100-80gb",gpu_count=1(also supports"T4","L4","A100","A100-80GB", and multi-GPU suffixes like"H100:4"), with Spot + automatic On-Demand preemption fallback (spot=True,fallback_to_ondemand=True,retry_on_preemption=True). - Zero-exposure
Secret.from_name: Never serializes raw credentials into containerenvdictionaries.Sandbox.create(..., secrets=[modal.Secret.from_name("hf-token")])routes throughclient.inject_secrets(sandbox_id, secrets=["hf-token"]), and@app.functionforwards only audited secret reference names (STATESET_SECRET_REFS).
Option B — Native Next-Gen (stateset-sandbox Pillar 9 Batch .map() + Hard Budget Cap):
import os
import time
from stateset_sandbox import StateSetSandbox
client = StateSetSandbox(
base_url=os.environ.get("STATESET_BASE_URL", "https://api.sandbox.stateset.app"),
auth_token=os.environ["STATESET_API_KEY"],
)
# Fan out across Spot H100 GPUs with automatic On-Demand fallback and hard USD ceiling
job = client.batch.map(
name="gpu-eval",
command="python3 score.py",
items=["prompt-1", "prompt-2", "prompt-3"],
image="python:3.11-slim",
compute_sku="nvidia-h100-80gb",
gpu_count=1,
spot=True,
fallback_to_ondemand=True,
retry_on_preemption=True,
max_concurrency=32,
max_retries=2,
item_timeout_seconds=300,
budget_max_usd=25.0,
)
while job.status in {"queued", "running"}:
time.sleep(2)
job = client.batch.get(job.id)
page = client.batch.results(job.id)
for item in page.items:
print(item.index, item.status, item.capacity_type, item.stdout)Package & Endpoint Reference Summary
| Source Platform | Language | Option A (Drop-In Compat) | Option B (Native SDK) |
|---|---|---|---|
| E2B | TypeScript / Node | @stateset/e2b-compat | @stateset/sandbox-sdk |
| E2B | Python | stateset-e2b-compat | stateset-sandbox |
| Daytona | TypeScript / Node | @stateset/daytona-compat | @stateset/sandbox-sdk |
| Daytona | Python | stateset-daytona-compat | stateset-sandbox |
| Modal | Python | stateset-modal-compat | stateset-sandbox |
| Self-Hosted VPC | Node 20+ (BYOC) | — | @stateset/byoc-runner |
Key Control-Plane Endpoints Used by Next-Gen Upgrades
- Pillar 1 (Repo Caches & Hot-Fork):
POST /api/v1/caches/repos,POST /api/v1/caches/repos/resolve,POST /api/v1/caches/repos/:cacheId/warm,POST /api/v1/caches/repos/:cacheId/fork - Pillar 3 (Ephemeral Service Sidecars):
GET /api/v1/services/presets,POST /api/v1/sandbox/:sandboxId/services,POST /api/v1/sandbox/:sandboxId/services/:serviceId/branch - Pillar 9 (Serverless Batch GPU
.map()):GET /api/v1/batch/gpus,POST /api/v1/batch/map,GET /api/v1/batch/:batchId,GET /api/v1/batch/:batchId/results
Next Steps
- Explore all 10 pillars in the Next-Gen Platform Pillars Guide.
- Connect your AI coding assistant directly via the 130-Tool MCP Server Guide.
- Compare latency, security, and monthly fleet cost in Compare vs E2B, Daytona & Modal.
- Test migrations interactively in the Playground.
Ready to run this in a hardened gVisor sandbox?
Test live in the Playground with zero signup, or create a free workspace with $25 in trial credits.