Getting Started
Create Sandbox

Create Sandbox

Learn how to create and configure sandboxes for your workloads.

Basic Creation

Create a sandbox with default settings:

import SandboxSDK from '@akiralabs/sandbox-sdk';
 
const client = new SandboxSDK({
  apiKey: process.env['AKIRA_API_KEY'],
});
 
const sandbox = await client.sandboxes.create({
  image: 'akiralabs/akira-default-sandbox',
});
 
console.log(`Sandbox ID: ${sandbox.id}`);
console.log(`Status: ${sandbox.status}`);

Configuration Options

Resource Limits

Control CPU and memory allocation:

const sandbox = await client.sandboxes.create({
  image: 'akiralabs/akira-default-sandbox',
  resources: {
    cpus: 2,        // 1-32 CPU cores
    memory: 2048,   // 128-32768 MiB
    storage: 10,    // 1-1000 GB
  },
});

Environment Variables

Pass environment variables to your sandbox:

const sandbox = await client.sandboxes.create({
  image: 'akiralabs/akira-default-sandbox',
  env_vars: {
    NODE_ENV: 'production',
    DATABASE_URL: 'postgres://...',
    API_KEY: 'secret',
  },
});

Custom Images

The default sandbox image provides a general-purpose Linux environment:

ImageDescription
akiralabs/akira-default-sandboxGeneral-purpose Linux environment
const sandbox = await client.sandboxes.create({
  image: 'akiralabs/akira-default-sandbox',
});

REST API

Create a sandbox via REST:

curl -X POST https://api.akiralabs.ai/v1/sandboxes/create \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "akiralabs/akira-default-sandbox",
    "resources": {
      "cpus": 2,
      "memory": 2048,
      "storage": 10
    },
    "env_vars": {
      "NODE_ENV": "production"
    }
  }'

Response:

{
  "id": "sbx_abc123",
  "status": "running",
  "image": "akiralabs/akira-default-sandbox",
  "created_at": "2024-01-15T10:30:00Z"
}

List Sandboxes

View all running sandboxes:

const sandboxes = await client.sandboxes.list();
 
for (const sandbox of sandboxes.data) {
  console.log(`${sandbox.id}: ${sandbox.status}`);
}

Delete Sandbox

Clean up when done:

// Delete a specific sandbox
await client.sandboxes.delete(sandbox.id);
 
// Delete all sandboxes
await client.sandboxes.deleteAll();

Best Practices

Resource Management

Always delete sandboxes when you're done to free up resources and avoid unnecessary costs.

  • Use appropriate resources - Don't over-provision CPU/memory
  • Clean up promptly - Delete sandboxes when work is complete
  • Use snapshots for state persistence - Don't rely on sandbox filesystem for important data

Next Steps