Quickstart Guide
Get your first VoidRun sandbox up and running in minutes. This guide walks you through installation, authentication, and basic operations.Prerequisites
Before you begin, make sure you have:- A VoidRun API key (get one from the VoidRun Dashboard)
- Node.js 18+ or Python 3.9+ installed (for SDK usage)
curlinstalled (for REST API usage)
Step 1: Install the SDK
Choose your preferred language:npm install @voidrun/sdk
pip install voidrun
# Install the VoidRun CLI
npm install -g @voidrun/cli
# Or download directly
curl -fsSL https://voidrun.com/install.sh | sh
# No installation needed - use curl directly
# Ensure you have curl installed
curl --version
Step 2: Configure Authentication
Set your API key as an environment variable:export VR_API_KEY="your-api-key-here"
export VR_API_KEY="your-api-key-here"
# Alternatively: export API_KEY="your-api-key-here"
export VR_API_KEY="your-api-key-here"
export VR_API_KEY="your-api-key-here"
You can also pass the API key directly when initializing the SDK client. See the examples below.
Step 3: Create Your First Sandbox
Create an isolated MicroVM environment. The examples use thecode system image (Alpine-based, with Python and Node: see System images). You can use max (Debian), docker-lite (lighter Alpine Docker), or docker (heavier Debian Docker) instead when your workload requires them.
import { VoidRun } from '@voidrun/sdk';
// Initialize with environment variable
const vr = new VoidRun({});
// Or pass API key explicitly
// const vr = new VoidRun({ apiKey: 'your-api-key' });
// Create a sandbox
const sandbox = await vr.createSandbox({
name: 'my-first-sandbox',
cpu: 2,
mem: 2048,
image: 'code'
});
console.log(`Sandbox created: ${sandbox.id}`);
console.log(`Status: ${sandbox.status}`);
from voidrun import VoidRun
import os
# Initialize with environment variable
vr = VoidRun()
# Or pass API key explicitly
# vr = VoidRun(api_key="your-api-key")
# Create a sandbox
sandbox = vr.create_sandbox(
name="my-first-sandbox",
cpu=2,
mem=2048,
image="code"
)
print(f"Sandbox created: {sandbox.id}")
print(f"Status: {sandbox.status}")
# Create a sandbox with default settings
voidrun create --name my-first-sandbox
# Create with custom configuration
voidrun create \
--name my-first-sandbox \
--cpu 2 \
--mem 2048 \
--template code
curl -X POST https://api.void-run.com/api/sandboxes \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-first-sandbox",
"cpu": 2,
"mem": 2048,
"image": "code"
}'
Step 4: Execute Commands
Run commands inside your sandbox:// Execute a simple command
const result = await sandbox.exec({
command: 'echo "Hello from VoidRun!"'
});
console.log(result.data?.stdout); // "Hello from VoidRun!"
console.log(result.data?.exitCode); // 0
// Execute with streaming output
await sandbox.execStream(
{ command: 'npm install && npm run build' },
{
onStdout: (data) => console.log('stdout:', data),
onStderr: (data) => console.error('stderr:', data),
onExit: ({ exitCode }) => console.log('Exited with code:', exitCode)
}
);
# Execute a simple command
result = sandbox.exec('echo "Hello from VoidRun!"')
print(result.data.stdout) # "Hello from VoidRun!"
print(result.data.exit_code) # 0
# Execute with streaming output
def on_stdout(data):
print(f"stdout: {data}")
def on_stderr(data):
print(f"stderr: {data}")
sandbox.exec_stream(
'pip install requests && python -c "import requests; print(requests.__version__)"',
on_stdout=on_stdout,
on_stderr=on_stderr
)
# Execute a command
voidrun exec <sandbox-id> --command 'echo "Hello from VoidRun!"'
# Execute with streaming output
voidrun exec <sandbox-id> --command 'npm install && npm run build' --stream
# Execute a command
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "echo \"Hello from VoidRun!\""}'
# Stream command output (SSE endpoint)
curl -N "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec-stream" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command": "npm install && npm run build"}'
Step 5: Work with Files
Upload, download, and manage files in your sandbox:// Create and write to a file
await sandbox.fs.createFile('/app/hello.txt');
await sandbox.fs.uploadFile('/app/hello.txt', 'Hello, VoidRun!');
// Read file contents
const content = await sandbox.fs.downloadFile('/app/hello.txt');
console.log(content.toString()); // "Hello, VoidRun!"
// List files in a directory
const files = await sandbox.fs.listFiles('/app');
console.log(files.data?.files);
// Copy and move files
await sandbox.fs.copyFile('/app/hello.txt', '/app/hello-copy.txt');
await sandbox.fs.moveFile('/app/hello-copy.txt', '/tmp/hello.txt');
// Delete a file
await sandbox.fs.deleteFile('/tmp/hello.txt');
# Create and write to a file
sandbox.fs.create_file("/app/hello.txt")
sandbox.fs.upload_file("/app/hello.txt", "Hello, VoidRun!")
# Read file contents
content = sandbox.fs.download_file("/app/hello.txt")
print(content.decode("utf-8")) # "Hello, VoidRun!"
# List files in a directory
listing = sandbox.fs.list_files("/app")
print([f.name for f in (listing.data.files or [])])
# Copy and move files
sandbox.fs.copy_file("/app/hello.txt", "/app/hello-copy.txt")
sandbox.fs.move_file("/app/hello-copy.txt", "/tmp/hello.txt")
# Delete a file
sandbox.fs.delete_file("/tmp/hello.txt")
# Upload a file
voidrun fs upload <sandbox-id> --source ./local-file.txt --dest /app/hello.txt
# Download a file
voidrun fs download <sandbox-id> --source /app/hello.txt --dest ./downloaded.txt
# List files
voidrun fs list <sandbox-id> --path /app
# Delete a file
voidrun fs delete <sandbox-id> --path /app/hello.txt
# Upload a file
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/fs/upload" \
-H "X-API-Key: $VR_API_KEY" \
-F "file=@./local-file.txt" \
-F "path=/app/hello.txt"
# Download a file
curl -X GET "https://api.void-run.com/api/sandboxes/<sandbox-id>/fs/download?path=/app/hello.txt" \
-H "X-API-Key: $VR_API_KEY" \
-o downloaded.txt
# List files
curl -X GET "https://api.void-run.com/api/sandboxes/<sandbox-id>/fs/list?path=/app" \
-H "X-API-Key: $VR_API_KEY"
Step 6: Run Code with the Interpreter
Execute code in multiple languages using the built-in code interpreter:// Run Python code
const pyResult = await sandbox.runCode(`
import math
print(f"Pi is approximately {math.pi:.4f}")
`, { language: 'python' });
console.log(pyResult.stdout);
// Run JavaScript code
const jsResult = await sandbox.runCode(`
const numbers = [1, 2, 3, 4, 5];
const sum = numbers.reduce((a, b) => a + b, 0);
console.log(\`Sum: \${sum}\`);
`, { language: 'javascript' });
console.log(jsResult.stdout);
// Run Bash commands
const bashResult = await sandbox.runCode(`
for i in {1..5}; do
echo "Count: $i"
done
`, { language: 'bash' });
console.log(bashResult.stdout);
# Run Python code
result = sandbox.run_code("""
import math
print(f"Pi is approximately {math.pi:.4f}")
""", language="python")
print(result.stdout)
# Run JavaScript code
result = sandbox.run_code("""
const numbers = [1, 2, 3, 4, 5];
const sum = numbers.reduce((a, b) => a + b, 0);
console.log(`Sum: ${sum}`);
""", language="javascript")
print(result.stdout)
# Run Bash commands
result = sandbox.run_code("""
for i in {1..5}; do
echo "Count: $i"
done
""", language="bash")
print(result.stdout)
# Run Python code
voidrun run-code <sandbox-id> --language python --code 'print("Hello from Python!")'
# Run JavaScript code
voidrun run-code <sandbox-id> --language javascript --code 'console.log("Hello from JS!")'
# Run from file
voidrun run-code <sandbox-id> --language python --file ./script.py
# Run code via exec endpoint
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"command": "python3 -c \"print(\\\"Hello from Python!\\\")\""
}'
Step 7: Manage Sandbox Lifecycle
Control your sandbox state:// List all sandboxes
const { sandboxes, meta } = await vr.listSandboxes();
console.log(`Total sandboxes: ${meta.total}`);
// Get a specific sandbox
const existing = await vr.getSandbox('sandbox-id');
// Sleep a running sandbox (snapshot to disk, release compute)
await sandbox.sleep();
// Wake a snapshotted sandbox back to running
await sandbox.wake();
// Delete a sandbox when done
await sandbox.remove();
# List all sandboxes
listed = vr.list_sandboxes()
print(f"Total sandboxes: {len(listed.sandboxes)}")
# Get a specific sandbox
sandbox = vr.get_sandbox("sandbox-id")
# Sleep a running sandbox (snapshot to disk, release compute)
sandbox.sleep()
# Wake a snapshotted sandbox back to running
sandbox.wake()
# Delete a sandbox when done
sandbox.remove()
# List all sandboxes
voidrun list
# Get sandbox details
voidrun get <sandbox-id>
# Sleep a sandbox
voidrun sleep <sandbox-id>
# Wake a sandbox
voidrun wake <sandbox-id>
# Delete a sandbox
voidrun delete <sandbox-id>
# List all sandboxes
curl -X GET "https://api.void-run.com/api/sandboxes" \
-H "X-API-Key: $VR_API_KEY"
# Get sandbox details
curl -X GET "https://api.void-run.com/api/sandboxes/<sandbox-id>" \
-H "X-API-Key: $VR_API_KEY"
# Sleep a sandbox
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/sleep" \
-H "X-API-Key: $VR_API_KEY"
# Wake a sandbox
curl -X POST "https://api.void-run.com/api/sandboxes/<sandbox-id>/wake" \
-H "X-API-Key: $VR_API_KEY"
# Delete a sandbox
curl -X DELETE "https://api.void-run.com/api/sandboxes/<sandbox-id>" \
-H "X-API-Key: $VR_API_KEY"
Complete Example
Here’s a complete example that demonstrates the full workflow:import { VoidRun } from '@voidrun/sdk';
async function main() {
// Initialize client
const vr = new VoidRun({ apiKey: process.env.VR_API_KEY });
// Create sandbox
const sandbox = await vr.createSandbox({
name: 'quickstart-demo',
cpu: 2,
mem: 2048,
image: 'code'
});
console.log(`Created sandbox: ${sandbox.id}`);
try {
// Upload a file
await sandbox.fs.uploadFile('/tmp/data.txt', 'Hello, VoidRun!');
// Execute a command
const result = await sandbox.exec({ command: 'cat /tmp/data.txt' });
console.log('File contents:', result.data?.stdout);
// Run Python code
const codeResult = await sandbox.runCode(`
with open('/tmp/data.txt', 'r') as f:
content = f.read()
print(f"Read from file: {content}")
`, { language: 'python' });
console.log('Python output:', codeResult.stdout);
} finally {
// Clean up
await sandbox.remove();
console.log('Sandbox deleted');
}
}
main().catch(console.error);
import os
from voidrun import VoidRun
def main():
# Initialize client
vr = VoidRun(api_key=os.environ.get("VR_API_KEY"))
# Create sandbox
sandbox = vr.create_sandbox(
name="quickstart-demo",
cpu=2,
mem=2048,
image="code"
)
print(f"Created sandbox: {sandbox.id}")
try:
# Upload a file
sandbox.fs.upload_file("/tmp/data.txt", "Hello, VoidRun!")
# Execute a command
result = sandbox.exec("cat /tmp/data.txt")
print("File contents:", result.data.stdout)
# Run Python code
code_result = sandbox.run_code("""
with open('/tmp/data.txt', 'r') as f:
content = f.read()
print(f"Read from file: {content}")
""", language="python")
print("Python output:", code_result.stdout)
finally:
# Clean up
sandbox.remove()
print("Sandbox deleted")
if __name__ == "__main__":
main()
#!/bin/bash
# Create sandbox
SANDBOX_ID=$(voidrun create --name quickstart-demo --cpu 2 --mem 2048 --template code --json | jq -r '.id')
echo "Created sandbox: $SANDBOX_ID"
# Upload a file
echo "Hello, VoidRun!" | voidrun fs upload $SANDBOX_ID --dest /tmp/data.txt
# Execute a command
voidrun exec $SANDBOX_ID --command "cat /tmp/data.txt"
# Run Python code
voidrun run-code $SANDBOX_ID --language python --code "
with open('/tmp/data.txt', 'r') as f:
content = f.read()
print(f'Read from file: {content}')
"
# Clean up
voidrun delete $SANDBOX_ID
echo "Sandbox deleted"
#!/bin/bash
VR_API_KEY="your-api-key"
BASE_URL="https://api.void-run.com/api"
# Create sandbox
SANDBOX_ID=$(curl -s -X POST "$BASE_URL/sandboxes" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"quickstart-demo","cpu":2,"mem":2048}' | jq -r '.data.id')
echo "Created sandbox: $SANDBOX_ID"
# Upload a file
curl -s -X POST "$BASE_URL/sandboxes/$SANDBOX_ID/fs/upload" \
-H "X-API-Key: $VR_API_KEY" \
-F "file=@-;filename=data.txt" \
-F "path=/tmp/data.txt" <<< "Hello, VoidRun!"
# Execute a command
curl -s -X POST "$BASE_URL/sandboxes/$SANDBOX_ID/exec" \
-H "X-API-Key: $VR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"command":"cat /tmp/data.txt"}' | jq '.data.stdout'
# Clean up
curl -s -X DELETE "$BASE_URL/sandboxes/$SANDBOX_ID" \
-H "X-API-Key: $VR_API_KEY"
echo "Sandbox deleted"
What’s Next?
Always clean up sandboxes when you’re done. Idle sandboxes auto-sleep (snapshot on disk) and wake on the next request, but they remain billable for storage until explicitly deleted.
Examples
Full walkthroughs: interpreter, CI, ETL, background jobs, PTY, file watch, cleanup.
Core Concepts
Learn about sandbox lifecycle, auto-sleep, and wake behavior.
Code Execution
Deep dive into command execution and code interpreter features.
Custom Images
Create and use custom Docker images for your sandboxes.
Networking
Configure internet access and VPN connectivity.

