Client

createSandboxClient is the single entry point — it owns provider selection, idempotency-aware retry and fallback, lifecycle hooks, and disposal.

createSandboxClient(options?)

The single entry point. Pass a provider adapter, or call with no arguments for the zero-config in-memory provider.

import { createSandboxClient } from "sbox-sdk";
import { e2b } from "sbox-sdk/e2b";

const client = createSandboxClient({
  provider: e2b({ apiKey: process.env.E2B_API_KEY! }),
});

Options

OptionTypeDefaultPurpose
providerSandboxProviderin-memoryThe adapter to route to
fallbackSandboxProvider[][]Backup providers — engages only with an idempotencyKey
retryRetryPolicy{ retries: 2 }retries, delayMs, shouldRetry
hooksHooksbeforeCreate, afterCreate, onError
fetchtypeof fetchglobalThis.fetchInjectable transport (test seam)
emulate(keyof CapabilityMap)[]Opt-in lossy emulations
defaultMetadataRecord<string, string>Merged into every create
pluginsSandboxPlugin[][]Augment every sandbox (e.g. the ai(...) plugin)
telemetryboolean | TelemetryOptionsenabledAnonymous usage data. Pass false to opt out

See Retries & fallback for retry, fallback, and hooks in depth.

See Anonymous usage data for what is collected and how to opt out.

SandboxClient

The object returned by createSandboxClient.

MemberSignatureNotes
create(spec?: SandboxSpec, options?: SandboxCreateOptions) => Promise<Sandbox>Idempotency-aware; retries + fallback. options carries per-sandbox plugin overrides (e.g. AI policy)
connect(id: string) => Promise<Sandbox>Reattach to an existing sandbox
list(filter?: ListFilter) => AsyncIterable<SandboxInfo>Throws NotSupported if the provider has no list
providerstringActive provider name (readonly)
capabilitiesCapabilities{ map, flags } read-model (readonly)
dispose() => Promise<void>Release provider resources

SandboxSpec

The shape passed to create(). template is mapped per-adapter — see Templates.

Prop

Type

On this page