Skip to content

Latest commit

 

History

History
94 lines (73 loc) · 2.06 KB

File metadata and controls

94 lines (73 loc) · 2.06 KB
description Set up the Upstash provider for ComputeSDK, configure your API key, and create default or ephemeral boxes to run commands.
layout
width title description tableOfContents outline pagination metadata tags actions
default
visible
true
visible
visible
true
visible
true
visible
true
visible
true
visible
true
visible
true
tags
tag primary
benchmarked
true

Upstash

{% embed url="https://www.computesdk.com/benchmarks/sandboxes/upstash/" %}

Upstash provider for ComputeSDK

Installation & Setup

npm install @computesdk/upstash

Add your Upstash credentials to a .env file:

UPSTASH_BOX_API_KEY=your_upstash_box_api_key

Usage

import { upstash } from '@computesdk/upstash';

const compute = upstash({
  apiKey: process.env.UPSTASH_BOX_API_KEY,
});

// Create sandbox
const sandbox = await compute.sandbox.create();

// Run a command
const result = await sandbox.runCommand('echo "Hello from Upstash!"');
console.log(result.stdout); // "Hello from Upstash!"

// Clean up
await sandbox.destroy();

Box Types

Upstash supports two box variants:

  • Default Box — Full sandbox with filesystem, shell, snapshots, and preview URLs. Best for persistent or long-running work.
  • Ephemeral Box (optional) — Lightweight, instant-ready box with code execution and filesystem only. No preview URLs. Best for short-lived, one-off tasks.

For more details, see the Upstash Box documentation.

// Default box
const sandbox = await compute.sandbox.create();

// Ephemeral box
const sandbox = await compute.sandbox.create({ ephemeral: true });

Configuration Options

interface UpstashConfig {
  /** Upstash Box API key - if not provided, will use UPSTASH_BOX_API_KEY env var */
  apiKey?: string;
  /** Default runtime environment (e.g. 'node', 'python') */
  runtime?: string;
  /** Execution timeout in milliseconds (default: 600000) */
  timeout?: number;
}