Skip to main content

Quick Start

Get a sandbox running in under five minutes.

1. Get your API key​

Join the waitlist. We'll email you an API key when your spot is ready.

2. Install the SDK​

npm install @codecapsules/sandbox

Requires Node.js 18 or later.

3. Set your API key​

export CODECAPSULES_API_KEY=your_api_key_here

Both SDKs read CODECAPSULES_API_KEY automatically. You can also pass it explicitly; see the API reference for each SDK.

4. Run your first command​

import { Sandbox } from '@codecapsules/sandbox';

await Sandbox.using(async (sb) => {
const r = await sb.exec('python --version');
console.log(r.stdout); // "Python 3.12.3\n"
console.log(r.exitCode); // 0
});
// sandbox deleted automatically

5. Install packages and run a script​

import { Sandbox } from '@codecapsules/sandbox';
import { readFileSync } from 'fs';

await Sandbox.using(async (sb) => {
// Install a dependency
await sb.exec('pip install httpx');

// Upload a script
await sb.upload('/workspace/fetch.py', readFileSync('./fetch.py'));

// Run it
const r = await sb.exec('python /workspace/fetch.py');
console.log(r.stdout);

// Download the output
const output = await sb.download('/workspace/result.json');
console.log(JSON.parse(Buffer.from(output).toString()));
});

Next steps​