E2B SDK

Hosted E2B endpoint configuration and method mappings for JavaScript and Python.

Connection

Set E2B_API_URL=https://e2b.shardflux.dev, E2B_DOMAIN=e2b.shardflux.dev and E2B_API_KEY to a Shardflux project API key. The returned sandbox domain supplies envd at https://49983-<sandboxId>.e2b.shardflux.dev and application ports at https://<port>-<sandboxId>.e2b.shardflux.dev. The guide includes JavaScript and Python examples.

Client Tested version
Official npm e2b 2.51.0
Official PyPI e2b 2.61.0
npm @e2b/code-interpreter 2.9.0
PyPI e2b-code-interpreter 2.11.5
npm @e2b/desktop 2.5.0

Method mappings

E2B method Behavior on Shardflux
Create, connect, getInfo, kill Workspace creation/resume, resource view and deletion; sandbox id equals workspace id
List Project workspaces, exact metadata filters, running/paused filters and pagination
Commands, background handles and wait Streamed stdout/stderr, exit codes and command timeouts
File read, write, list and remove Native file tools; byte and text content; recursive removal
Pause and resume Memory, processes and disk preserved; connect resumes
Sandbox timeout Defaults to 300 seconds; positive values up to 24 hours; setTimeout renews from now
Timeout action kill / pause Delete / suspend; action begins within the one-second expiry interval
Lifecycle autoResume false Explicit connect controls resume
Create-time envs Persisted across timeout renewal, pause and reconnect; command envs override individual defaults
PTY create, connect, input, resize and kill Native terminal sessions with streamed output
Code interpreter code-interpreter-v1: Python, JavaScript and TypeScript, stateful contexts and streamed results/errors
Desktop desktop: Xvfb/XFCE, screenshots, mouse/keyboard and browser stream
HTTP and WebSocket application ports New sandboxes allow public previews by default; network.allowPublicTraffic: false requires e2b-traffic-access-token; native port entitlement and quota apply
Snapshot/template builds, E2B metrics, dynamic network rules, watchers, additional interpreter language kernels, reboot resume and autoResume true Explicit protocol error; use the native Shardflux APIs for their corresponding capabilities

Metadata maps to workspace labels. metadata.shardflux_workspace_key selects a stable workspace key; an ordinary create generates a fresh key. Relative file paths resolve under /home/user. Directory listing supports depth 1..32 and returns up to 1000 entries per directory and 10000 per recursive response; larger listings return a resource error. Pause requires a persistent workspace. API-key revocation stops access to its sandbox tools.

New public-traffic behavior applies only to sandboxes created with this support. Existing private sandboxes stay private. Envd and Jupyter code-execution ports always require authentication. Creating an interpreter or desktop sandbox downloads its runtime inside the VM and needs outbound package access. For slow downloads, increase your client request timeout, for example requestTimeoutMs: 240_000. Other interpreter languages require additional kernels.

View this page as Markdown