ComputeSDK provides a consistent TypeScript interface for executing code in remote sandboxes. Whether you're using E2B for data science, Modal for GPU workloads, or Vercel for serverless functions - ComputeSDK provides one unified API.
Perfect for:
- π€ AI code execution agents
- π Data science platforms
- π Educational coding environments
- π§ͺ Testing & CI/CD systems
- π§ Developer tools
npm install computesdk @computesdk/e2bConfigure a provider and use the SDK:
import { compute } from 'computesdk';
import { e2b } from '@computesdk/e2b';
compute.setConfig({
provider: e2b({ apiKey: process.env.E2B_API_KEY }),
});
const sandbox = await compute.sandbox.create();
const result = await sandbox.runCommand('python -c "print(\'Hello World!\')"');
console.log(result.stdout); // "Hello World!"
await sandbox.destroy();- π Multi-provider support - E2B, Modal, Daytona, Vercel, and more
- π Filesystem operations - Read, write, create directories across providers
- π₯οΈ Command execution - Run shell commands in sandboxes
- π§΅ Terminals - Interactive (PTY) and exec-mode command tracking
- π‘οΈ Type-safe - Full TypeScript support with comprehensive error handling
- π§ Extensible - Easy to add custom providers via @computesdk/provider
Install provider packages and pass instances into compute.setConfig:
| Provider | Environment Variables | Use Cases |
|---|---|---|
| Archil | ARCHIL_API_KEY |
Disk-attached command execution |
| Beam | BEAM_TOKEN, BEAM_WORKSPACE_ID |
Serverless cloud sandboxes |
| Blaxel | BL_API_KEY, BL_WORKSPACE |
Agent sandboxes with custom images |
| Cloud Run | CLOUD_RUN_SANDBOX_URL, CLOUD_RUN_SANDBOX_SECRET |
Google Cloud Run sandboxes |
| Cloudflare | CLOUDFLARE_SANDBOX_URL, CLOUDFLARE_SANDBOX_API_KEY |
Edge computing |
| CodeSandbox | CSB_API_KEY |
Collaborative development |
| CreateOS | CREATEOS_SANDBOX_API_KEY, CREATEOS_SANDBOX_BASE_URL |
VM sandboxes with pause/resume/fork snapshots |
| Daytona | DAYTONA_API_KEY |
Development workspaces |
| Declaw | DECLAW_API_KEY |
Isolated cloud sandboxes |
| E2B | E2B_API_KEY |
Data science, Python/Node.js, interactive terminals |
| HopX | HOPX_API_KEY |
Fast ephemeral sandboxes |
| Isorun | ISORUN_API_KEY |
Code execution with snapshot support |
| Lightning | LIGHTNING_API_KEY |
Cloud sandboxes for command execution and filesystem access |
| Modal | MODAL_TOKEN_ID, MODAL_TOKEN_SECRET |
GPU computing, ML inference |
| Northflank | NORTHFLANK_TOKEN, NORTHFLANK_PROJECT_ID |
Cloud sandboxes with preview URLs |
| Runloop | RUNLOOP_API_KEY |
Code execution, automation |
| Superserve | SUPERSERVE_API_KEY |
Firecracker microVM sandboxes |
| Tensorlake | TENSORLAKE_API_KEY |
Stateful MicroVM sandboxes |
| Upstash | UPSTASH_BOX_API_KEY |
Ephemeral and persistent sandboxes |
| Vercel | VERCEL_TOKEN or VERCEL_OIDC_TOKEN |
Serverless functions |
Pass a provider instance directly to setConfig():
import { compute } from 'computesdk';
import { e2b } from '@computesdk/e2b';
compute.setConfig({
provider: e2b({ apiKey: process.env.E2B_API_KEY }),
});
const sandbox = await compute.sandbox.create();Configure multiple providers for resilience and routing:
import { compute } from 'computesdk';
import { e2b } from '@computesdk/e2b';
import { modal } from '@computesdk/modal';
compute.setConfig({
providers: [
e2b({ apiKey: process.env.E2B_API_KEY }),
modal({
tokenId: process.env.MODAL_TOKEN_ID,
tokenSecret: process.env.MODAL_TOKEN_SECRET,
}),
],
providerStrategy: 'priority', // or 'round-robin'
fallbackOnError: true,
});
// Uses configured strategy
const sandbox = await compute.sandbox.create();
// Force a specific provider for one call
const modalSandbox = await compute.sandbox.create({ provider: 'modal' });import { compute } from 'computesdk';
import { e2b } from '@computesdk/e2b';
import { modal } from '@computesdk/modal';
// Use E2B for data science
compute.setConfig({
provider: e2b({ apiKey: process.env.E2B_API_KEY }),
});
const e2bSandbox = await compute.sandbox.create();
await e2bSandbox.runCommand('python -c "import pandas as pd"');
await e2bSandbox.destroy();
// Switch to Modal for GPU workloads
compute.setConfig({
provider: modal({
tokenId: process.env.MODAL_TOKEN_ID,
tokenSecret: process.env.MODAL_TOKEN_SECRET,
}),
});
const modalSandbox = await compute.sandbox.create();
await modalSandbox.runCommand('python -c "import torch; print(torch.cuda.is_available())"');
await modalSandbox.destroy();// Create sandbox
const sandbox = await compute.sandbox.create();
// Create with options
const sandbox = await compute.sandbox.create({
runtime: 'python',
timeout: 300000,
metadata: { userId: '123' }
});
// Get existing sandbox
const sandbox = await compute.sandbox.getById('sandbox-id');
// List sandboxes
const sandboxes = await compute.sandbox.list();
// Destroy sandbox
await sandbox.destroy();// Execute Python code
const result = await sandbox.runCommand('python -c "print(\'Hello\')"');
console.log(result.stdout);
console.log(result.exitCode);
// Run shell commands
const cmd = await sandbox.runCommand('npm install express');
console.log(cmd.stdout);
console.log(cmd.exitCode);// Write file
await sandbox.filesystem.writeFile('/tmp/hello.py', 'print("Hello")');
// Read file
const content = await sandbox.filesystem.readFile('/tmp/hello.py');
// Create directory
await sandbox.filesystem.mkdir('/tmp/data');
// List directory
const files = await sandbox.filesystem.readdir('/tmp');
// Check if exists
const exists = await sandbox.filesystem.exists('/tmp/hello.py');
// Remove
await sandbox.filesystem.remove('/tmp/hello.py');import { compute } from 'computesdk';
const sandbox = await compute.sandbox.create({ runtime: 'python' });
// Create project structure
await sandbox.filesystem.mkdir('/analysis');
await sandbox.filesystem.mkdir('/analysis/data');
// Write input data
const csvData = `name,age,city
Alice,25,New York
Bob,30,San Francisco`;
await sandbox.filesystem.writeFile('/analysis/data/people.csv', csvData);
// Write the analysis script
await sandbox.filesystem.writeFile('/analysis/analyze.py', `
import json
import pandas as pd
df = pd.read_csv('/analysis/data/people.csv')
print(f"Average age: {df['age'].mean()}")
results = {'average_age': df['age'].mean()}
with open('/analysis/results.json', 'w') as f:
json.dump(results, f)
`);
// Run it
const result = await sandbox.runCommand('python /analysis/analyze.py');
console.log(result.stdout);
// Read results
const results = await sandbox.filesystem.readFile('/analysis/results.json');
console.log('Results:', JSON.parse(results));
await sandbox.destroy();Install the provider packages you need and pass their instances into compute.setConfig:
npm install @computesdk/archil # Archil provider
npm install @computesdk/beam # Beam provider
npm install @computesdk/blaxel # Blaxel provider
npm install @computesdk/cloud-run # Google Cloud Run provider
npm install @computesdk/cloudflare # Cloudflare provider
npm install @computesdk/codesandbox # CodeSandbox provider
npm install @computesdk/createos-sandbox # CreateOS VM sandbox provider
npm install @computesdk/daytona # Daytona provider
npm install @computesdk/declaw # Declaw provider
npm install @computesdk/e2b # E2B provider
npm install @computesdk/hopx # HopX provider
npm install @computesdk/isorun # Isorun provider
npm install @computesdk/lightning # Lightning AI provider
npm install @computesdk/modal # Modal provider
npm install @computesdk/northflank # Northflank provider
npm install @computesdk/runloop # Runloop provider
npm install @computesdk/superserve # Superserve provider
npm install @computesdk/tensorlake # Tensorlake provider
npm install @computesdk/upstash # Upstash provider
npm install @computesdk/vercel # Vercel providerYou can also use a provider's callable form directly, bypassing compute.setConfig:
import { e2b } from '@computesdk/e2b';
const e2bCompute = e2b({ apiKey: process.env.E2B_API_KEY });
const sandbox = await e2bCompute.sandbox.create();See individual provider READMEs for details:
- @computesdk/archil - Disk-attached command-execution sandboxes
- @computesdk/beam - Serverless cloud sandboxes
- @computesdk/blaxel - Agent sandboxes with custom images
- @computesdk/cloud-run - Google Cloud Run sandboxes
- @computesdk/cloudflare - Edge computing sandboxes
- @computesdk/codesandbox - Collaborative development
- @computesdk/createos-sandbox - NodeOps VM sandboxes, with pause/resume/fork snapshots and a native-handle escape hatch
- @computesdk/daytona - Development workspaces
- @computesdk/declaw - Isolated cloud sandboxes
- @computesdk/e2b - Data science, Python/Node.js, terminals
- @computesdk/hopx - Fast ephemeral sandboxes
- @computesdk/isorun - Code execution with snapshot support
- @computesdk/lightning - Lightning AI cloud sandboxes for command execution and filesystem access
- @computesdk/modal - GPU computing, ML inference
- @computesdk/northflank - Cloud sandboxes with preview URLs
- @computesdk/runloop - Code execution, automation
- @computesdk/superserve - Firecracker microVM sandboxes
- @computesdk/tensorlake - Stateful MicroVM sandboxes for agentic applications, with snapshot support
- @computesdk/upstash - Ephemeral and persistent sandboxes
- @computesdk/vercel - Serverless functions
Want to add support for a new compute provider? See @computesdk/provider for the provider framework:
import { defineProvider } from '@computesdk/provider';
export const myProvider = defineProvider({
name: 'my-provider',
defaultMode: 'direct',
methods: {
sandbox: {
create: async (config, options) => {
// Your implementation
},
// ... other methods
}
}
});- π Full Documentation - Complete guides and API reference
- π Getting Started - Quick setup guide
- π― Providers - Provider-specific documentation
Full TypeScript support with comprehensive type definitions:
import type {
Sandbox,
SandboxInfo,
CodeResult,
CommandResult,
CreateSandboxOptions
} from 'computesdk';ComputeSDK is open source and welcomes contributions!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- π¬ GitHub Discussions - Ask questions and share ideas
- π GitHub Issues - Report bugs and request features
MIT License - see the LICENSE file for details.
Built with β€οΈ by the ComputeSDK team