Benchmarked
CodeSandbox
Last updated
Was this helpful?
Was this helpful?
npm install @computesdk/codesandboxCSB_API_KEY=your_codesandbox_api_keyimport { codesandbox } from '@computesdk/codesandbox';
const compute = codesandbox({
apiKey: process.env.CSB_API_KEY,
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// Run a command
const result = await sandbox.runCommand('echo "Hello from CodeSandbox!"');
console.log(result.stdout); // "Hello from CodeSandbox!"
// Clean up
await sandbox.destroy();interface CodesandboxConfig {
/** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */
apiKey?: string;
/** Template to use for new sandboxes */
templateId?: string;
/** Default runtime environment, e.g. 'node', 'python' */
runtime?: string;
/** Execution timeout in milliseconds */
timeout?: number;
}