Skip to content
GitHub

Namespace

Namespace provider for ComputeSDK - Deploy and manage containerized sandboxes on Namespace’s cloud infrastructure.

npm install @computesdk/namespace

Add your Namespace credentials to a .env file:

NSC_TOKEN=your_namespace_nsc_token
import { namespace } from '@computesdk/namespace';

const compute = namespace({
  token: process.env.NSC_TOKEN,
});

// Create a new sandbox
const sandbox = await compute.sandbox.create();
console.log(`Sandbox created: ${sandbox.sandboxId}`);

// Get sandbox info
const info = await sandbox.getInfo();
console.log(`Sandbox status: ${info.status}`);

// Clean up when done
await sandbox.destroy();

You can customize the compute resources allocated to your sandboxes:

const compute = namespace({
  token: process.env.NSC_TOKEN,
  virtualCpu: 4,
  memoryMegabytes: 8192,
});

const sandbox = await compute.sandbox.create();
OptionEnvironment VariableRequiredDescription
tokenNSC_TOKENYesYour Namespace API token
virtualCpu-NoNumber of virtual CPU cores (default: 2)
memoryMegabytes-NoMemory allocation in MB (default: 4096)
machineArch-NoMachine architecture (default: ‘amd64’)
os-NoOperating system (default: ‘linux’)
interface NamespaceConfig {
  /** Namespace API token - if not provided, uses NSC_TOKEN env var */
  token?: string;
  /** Virtual CPU cores for the instance (default: 2) */
  virtualCpu?: number;
  /** Memory in megabytes for the instance (default: 4096) */
  memoryMegabytes?: number;
  /** Machine architecture (default: 'amd64') */
  machineArch?: string;
  /** Operating system (default: 'linux') */
  os?: string;
}