Skip to main content

1. Get Your API Key

Sign up at app.opensandbox.ai and grab your API key from the dashboard.

2. Install the SDK

npm install opensandbox

3. Set Your API Key

export OPENSANDBOX_API_KEY="your-api-key"

4. Create a Sandbox

import { Sandbox } from 'opensandbox';

const sandbox = await Sandbox.create({
  template: 'base',
  timeout: 300,
});

console.log(`Sandbox created: ${sandbox.sandboxId}`);

5. Run a Command

const result = await sandbox.commands.run('echo "Hello, World!"');

console.log(result.stdout);   // Hello, World!
console.log(result.exitCode); // 0

6. Read and Write Files

// Write a file
await sandbox.files.write('/tmp/hello.txt', 'Hello from OpenSandbox!');

// Read it back
const content = await sandbox.files.read('/tmp/hello.txt');
console.log(content); // Hello from OpenSandbox!

// List a directory
const entries = await sandbox.files.list('/tmp');
entries.forEach(e => console.log(`${e.isDir ? 'd' : 'f'} ${e.name}`));

7. Clean Up

await sandbox.kill();

Next Steps