Run Cloud
Run Cloud provides fast Firecracker microVM sandboxes for AI agents, CI, and untrusted code execution.
Installation & Setup
npm install computesdk @computesdk/run-cloudCreate an API key in the Run Cloud dashboard, then export it:
export RUN_CLOUD_API_KEY=rc_live_your_keyRUN_CLOUD_API_TOKEN is supported as an alias. RUN_CLOUD_API_URL optionally targets a custom Run Cloud deployment.
Usage
import { compute } from 'computesdk';
import { runCloud } from '@computesdk/run-cloud';
compute.setConfig({
provider: runCloud({
apiKey: process.env.RUN_CLOUD_API_KEY,
cpu: 2,
memory: 4096,
disk: 40,
}),
});
const sandbox = await compute.sandbox.create({
templateId: 'runcloud/agent-base',
name: 'agent-task',
});
const result = await sandbox.runCommand('node --version');
console.log(result.stdout);
await sandbox.filesystem.writeFile('/tmp/result.txt', result.stdout);
const snapshot = await compute.snapshot.create(sandbox.sandboxId, {
name: 'after-setup',
});
await sandbox.destroy();
const restored = await compute.sandbox.create({
snapshotId: snapshot.id,
});Configuration Options
cpu accepts fractional vCPUs, memory uses MiB, and disk uses GiB. timeout and commandTimeout use milliseconds; idlePauseSeconds and tunnelTtlSeconds use seconds.
Fresh creates accept per-create templateId or image, cpu, memory, disk, idlePauseSeconds, timeoutSeconds, region, name, orgId, and idempotencyKey overrides. Snapshot restores accept cpu, memory, disk, timeoutSeconds, region, and name overrides; options the restore API cannot apply are rejected instead of being silently ignored.
Sandbox-level environment variables are not yet persisted by Run Cloud. Pass command-scoped variables through runCommand:
Supported Operations
create
✅
Fresh image boot or snapshot restore with resource overrides.
getById
✅
Returns null for missing sandboxes.
list
✅
Lists running sandboxes.
destroy
✅
Idempotent when already deleted.
runCommand
✅
Supports cwd, env, timeout, streaming callbacks, and background mode.
getInfo
✅
Refreshes lifecycle and resource metadata.
getUrl
✅
Opens an expiring capability URL without making the sandbox persistent.
Filesystem
✅
Read, write, mkdir, list, exists, and remove.
Snapshots
✅
Create, list, delete, and restore.
Use sandbox.getInstance() to access the official Run Cloud client and native sandbox record.
Tunnel hostnames are random bearer capabilities. Do not write them to public logs. They expire automatically and are removed when the tunnel or sandbox is deleted.
Last updated
Was this helpful?