Benchmarked
Lightning
Last updated
Was this helpful?
Was this helpful?
npm install @computesdk/lightningLIGHTNING_API_KEY=your_api_key_here
# Optional: override the Lightning Cloud base URL
LIGHTNING_CLOUD_URL=https://lightning.aiimport { lightning } from '@computesdk/lightning';
const compute = lightning({
apiKey: process.env.LIGHTNING_API_KEY,
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// Run a command
const result = await sandbox.runCommand('echo "Hello from Lightning!"');
console.log(result.stdout); // "Hello from Lightning!"
// Clean up
await sandbox.destroy();interface LightningConfig {
/** Lightning AI API key - falls back to LIGHTNING_SANDBOX_API_KEY, then LIGHTNING_API_KEY env vars. */
apiKey?: string;
/** Lightning Cloud base URL - falls back to LIGHTNING_CLOUD_URL, then production. */
baseUrl?: string;
/** Instance type for new sandboxes (e.g. "cpu-1", "cpu-2", ... "cpu-16"). Defaults to "cpu-1". */
instanceType?: string;
/** Curated runtime image for new sandboxes (e.g. "node24", "python313"). */
runtime?: string;
/** Whether new sandboxes persist filesystem state across stops via auto-snapshots. */
persistent?: boolean;
/** Request spot capacity for new sandboxes. */
spot?: boolean;
/** Ports to expose on new sandboxes when none are supplied per-create. */
ports?: number[];
/** Maximum sandbox lifetime in milliseconds before auto-stop. */
timeout?: number;
}