Daytona
Daytona provider for ComputeSDK - Execute code in Daytona development workspaces.
Installation
Section titled “Installation”npm install @computesdk/daytonaWith ComputeSDK
Section titled “With ComputeSDK”import { createCompute } from 'computesdk';
import { daytona } from '@computesdk/daytona';
// Set as default provider
const compute = createCompute({
provider: daytona({ apiKey: process.env.DAYTONA_API_KEY }),
apiKey: process.env.COMPUTESDK_API_KEY
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// Get instance
const instance = sandbox.getInstance();
// Execute code
const result = await sandbox.runCode('print("Hello from Daytona!")');
console.log(result.stdout); // "Hello from Daytona!"
// Clean up
await compute.sandbox.destroy(sandbox.sandboxId);Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”export DAYTONA_API_KEY=your_api_key_hereConfiguration Options
Section titled “Configuration Options”interface DaytonaConfig {
/** Daytona API key - if not provided, will use DAYTONA_API_KEY env var */
apiKey?: string;
/** Default runtime environment */
runtime?: 'node' | 'python';
/** Execution timeout in milliseconds */
timeout?: number;
}Runtime Detection
Section titled “Runtime Detection”The provider automatically detects the runtime based on code patterns:
Python indicators:
printstatementsimportstatementsdeffunction definitions- Python-specific syntax (
f",__, etc.)
Default: Node.js for all other cases
SDK Reference Links:
Section titled “SDK Reference Links:”- Code Execution - Execute code snippets in various runtimes
- Command Execution - Run shell commands and scripts
- Filesystem Operations - Read, write, and manage files in sandboxes
- Sandbox Management - Create, list, and destroy sandboxes
- Error Handling - Handle command failures and runtime errors
- Web Framework Integration - Integrate with Express, Next.js, and other frameworks