E2B

The canonical reference adapter — richest capability set, with a code interpreter, snapshots, native ports, and pause/resume. Backed by @e2b/code-interpreter.

Installation

@e2b/code-interpreter is an optional peer dependency of sbox-sdk, loaded lazily on first use — install it alongside the SDK so the adapter's import resolves at runtime.

pnpm add sbox-sdk @e2b/code-interpreter

Usage

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

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

const sandbox = await client.create({ template: "python-3.12", ttlMs: 60_000 });

// E2B has a code interpreter, so `sandbox.code` is defined:
const exec = await sandbox.code.runCode("import matplotlib; print('ok')");
console.log(exec.logs.stdout);

E2B is the richest adapter and the reference implementation other adapters are measured against. template maps to an E2B template id / alias (e.g. "python-3.12" or a custom-built template).

Authentication

A single API key.

Authentication variables for the e2b adapter.
OptionEnv varRequiredDescription
apiKeyE2B_API_KEYrequiredYour E2B API key.
domainoptionalSelf-hosted E2B domain, if not the default cloud.

Options

Prop

Type

Capabilities

CapabilityLevelNotes
list / pause / setTimeoutnative
stopunsupportedE2B has no stop-without-destroy
background / streaming / killProcessnative
filesWatch / filesUploadnative
codeInterpreter / statefulKernelnativesandbox.code is defined
exposePortnativepreview via subdomain
snapshotnative
forkunsupported
metricsnative
egressControl / ssh / proxiedFetchunsupporteduse raw() for E2B-only features

preservesMemoryOnPause is true; previewModel is subdomain.

On this page