E2B Compatibility & Protocol Differences
This reference summarizes compatibility and behavioral differences between official E2B SDKs and CubePod Gateway (cubepod-gateway) for the interfaces reviewed below. It is not a complete inventory of the upstream E2B API or SDK surface.
CubePod implements core E2B REST and Connect-RPC endpoints to allow teams using official E2B client SDKs to redirect traffic to a self-hosted CubePod instance. However, CubePod is not an identical replica of hosted E2B Cloud: it is built on a persistent dual-volume Kata Containers MicroVM architecture with distinct lifecycle semantics, a two-volume storage model, and extension APIs.
Architectural Layers
Section titled “Architectural Layers”To understand compatibility, you must distinguish between three distinct architectural layers. They should never be conflated:
+---------------------------------------------------------------------------------------+| Layer 1: Official E2B SDK Drop-in || Unmodified upstream packages ('e2b', 'e2b-code-interpreter', '@e2b/code-interpreter') || Pointed via E2B_DOMAIN or E2B_API_URL + E2B_SANDBOX_URL + E2B_API_KEY |+---------------------------------------------------------------------------------------+ | v+---------------------------------------------------------------------------------------+| Layer 3: Protocol & Gateway Wire Translation || 'cubepod-gateway' (:8080) REST routes & Connect-RPC handlers || Translates /sandboxes, /process.Process/*, /filesystem.Filesystem/*, /templates |+---------------------------------------------------------------------------------------+ ^ |+---------------------------------------------------------------------------------------+| Layer 2: CubePod Native SDKs (Functionally Similar Superset) || Native packages named 'cubepod' ('sdks/python/', 'sdks/typescript/', 'pkg/client') || NOT drop-in for 'from e2b import Sandbox'; expose fork, reset-rootfs, panels, secrets |+---------------------------------------------------------------------------------------+- Layer 1: Official E2B SDK Drop-in:
This refers strictly to using the official upstream Python packages (
e2b,e2b-code-interpreter) or npm packages (@e2b/code-interpreter,e2b) without modification, pointing them to CubePod using environment variables. This is the only layer that qualifies as “official SDK compatibility”. - Layer 2: CubePod Native SDKs (Functional Overlap & Superset):
The
cubepodclient libraries (sdks/python/andsdks/typescript/, alongside the Go client inpkg/clientand CLI incmd/cubepod) provide an idiomatic interface with namespaces (.commands,.files,.code) inspired by modern sandbox ergonomics. However, they are native clients, not drop-in aliases forfrom e2b import Sandbox. They target native/sandboxes/{id}/*endpoints and expose CubePod-exclusive enterprise features (fork,reset-rootfs,archive-sync,secretBindings, desktop/panel proxies). - Layer 3: Gateway Protocol Route Presence:
The registration of a route on
cubepod-gateway(HTTP REST or Connect-RPC inpkg/gateway/server.goandpkg/gateway/connectrpc.go) confirms protocol translation exists in code. However, protocol presence alone does not guarantee that every upstream SDK method or version works seamlessly under all runtime conditions.
Pointing Official E2B SDKs at CubePod
Section titled “Pointing Official E2B SDKs at CubePod”Official E2B SDKs can be directed to cubepod-gateway through standard environment variables:
Production HTTPS with Wildcard DNS Ingress
Section titled “Production HTTPS with Wildcard DNS Ingress”When cubepod-gateway sits behind an ingress controller with wildcard DNS (*.<E2B_DOMAIN>):
export E2B_DOMAIN="cubepod.example.com"export E2B_API_KEY="cpod_live_secret"The upstream E2B SDK automatically sends control-plane requests to api.<E2B_DOMAIN> (or the root domain) and routes sandbox port traffic to <port>-<sandboxID>.<E2B_DOMAIN>. cubepod-gateway matches the Host header against ^([0-9]+)-([a-zA-Z0-9_-]+)\.(.*)$ to route port traffic directly to the sandbox MicroVM.
Direct HTTP / Local Gateway
Section titled “Direct HTTP / Local Gateway”When developing locally without TLS or wildcard DNS (such as against http://127.0.0.1:8080):
export E2B_API_URL="http://127.0.0.1:8080"export E2B_SANDBOX_URL="http://127.0.0.1:8080"export E2B_API_KEY="cpod_test_api_key"Setting both E2B_API_URL and E2B_SANDBOX_URL forces the SDK to send both control-plane and data-plane calls directly to the specified gateway address. This is the configuration used by test/e2b-compat/.
Compatibility Matrix
Section titled “Compatibility Matrix”Status Legend
Section titled “Status Legend”- Compatible: Official Python SDK tests in
test/e2b-compat/cover the listed basic scenarios for this method. That is not a claim that every parameter or edge case is implemented or tested, and it does not mean those tests were executed as part of writing this page. - Partial: A handler or protocol path exists, but there are known omissions, semantic differences, or required feature flags.
- Untested: A code path or route may exist, or an official SDK helper may not need a dedicated CubePod route, but this repository has no automated coverage of that official SDK method.
- Unsupported: No corresponding CubePod handler, route, or equivalent protocol support was found, and the upstream surface is not merely an SDK wrapper around another covered API.
Version-constraint cells such as e2b>=2.0.0 are dependency floors declared by test/e2b-compat/run_tests.sh (the template suite also asserts that the installed package major version is >= 2). They are not a complete set of versions that have been measured, and they are not a live-test result from this documentation change.
1. Sandbox Lifecycle
Section titled “1. Sandbox Lifecycle”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
Sandbox.create(...) [Python] |
POST /sandboxesPOST /v2/sandboxes |
Compatible | pkg/gateway/sandboxes.go:handleCreateSandboxtest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.pytest/e2b-compat/test_concurrent_sandboxes_isolation.py |
e2b>=2.0.0 (dependency floor only) |
Populates mandatory E2B response fields (sandboxID, templateID, clientID, envdVersion, state, startedAt, endAt, cpuCount, memoryMB, diskSizeMB). Claims standby pod from PodWarmPool if available. Accepts optional CubePod extension fields. |
Sandbox.create(...) [JS/TS] (Verified in v0.6.0) |
POST /sandboxesPOST /v2/sandboxes |
Compatible | pkg/gateway/sandboxes.go:handleCreateSandboxtest/e2b-compat-ts/src/e2b_compat.test.ts |
e2b@^2.64.0 (@e2b/code-interpreter untested) |
Core e2b JS/TS lifecycle, commands.run, files, getMetrics, Volumes, Secrets, network rules, and Templates verified via make test-e2b-compat-ts. |
Sandbox.get_info(...) |
GET /sandboxes/{id} |
Compatible | pkg/gateway/sandboxes.go:handleGetSandboxtest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Returns sandbox status (running / paused), resource metadata, and lease expiration. |
Sandbox.list() |
GET /v2/sandboxesGET /sandboxes |
Compatible | pkg/gateway/sandboxes.go:handleListSandboxesV2test/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Returns active sandboxes with lowercase state on /v2/sandboxes. |
sandbox.kill() / delete |
DELETE /sandboxes/{id} |
Compatible | pkg/gateway/sandboxes.go:handleDeleteSandboxtest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.py |
e2b>=2.0.0 (dependency floor only) |
Releases compute pod. Ephemeral sandboxes reclaim their temporary storage on delete; named persistent workspaces are retained unless deletion is requested. |
sandbox.set_timeout(...) / refreshes |
POST /sandboxes/{id}/refreshesPOST /sandboxes/{id}/timeout |
Compatible | pkg/gateway/sandboxes.go:handleRefreshSandboxtest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.pypkg/gateway/e2b_conformance_test.go |
e2b>=2.0.0 (dependency floor only) |
Renews sandbox TTL and resets the idle reaper timer. |
Sandbox.connect(...) |
POST /v2/sandboxes/{id}/connectPOST /sandboxes/{id}/connect |
Compatible | pkg/gateway/sandboxes.go:handleConnectSandboxtest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Reconnects to running sandbox or transparently resumes a paused sandbox (without preserving in-memory processes). |
sbx.get_metrics(...) / Sandbox.get_metrics(...) (Added in v0.6.0) |
GET /sandboxes/{sandboxID}/metricsGET /sandboxes/metrics |
Partial | pkg/gateway/sandbox_metrics.gocrates/podd/src/metrics.rstest/e2b-compat/test_official_e2b_extended.pytest/e2b-compat-ts/src/e2b_compat.test.ts |
e2b>=2.0.0, e2b@^2.64.0, Go -race, Rust unit tests |
Returns SandboxMetric snapshots (timestamp, timestampUnix, cpuCount, cpuUsedPct, memUsed, memTotal, memCache, diskUsed, diskTotal) with optional start/end range filtering (autoResume=false reads cached samples without waking paused sandboxes). Instance get_metrics / getMetrics is verified in both official Python and JS/TS CI suites. |
2. Commands & Process Execution
Section titled “2. Commands & Process Execution”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
sandbox.commands.run(...) (sync) |
POST /sandboxes/{id}/commandsPOST /sandboxes/{id}/commands/runConnect-RPC /process.Process/Start |
Compatible | pkg/gateway/commands.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.py |
e2b>=2.0.0 (dependency floor only) |
Executes inside guest via podd as unprivileged UID/GID 1000:1000 (cubeplex) with working directory /workspace. Returns stdout, stderr, and exitCode. Foreground execution only. |
sandbox.commands.run(..., background=True) |
POST /sandboxes/{id}/commands (background: true)Connect-RPC /process.Process/Start |
Compatible | pkg/gateway/commands.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Spawns detached process group in guest and returns a handle with pid. |
Output streaming & callbacks (on_stdout, on_stderr) |
GET /sandboxes/{id}/commands/{cmdId}/logsGET /sandboxes/{id}/commands/{cmdId}/streamConnect-RPC /process.Process/Connect |
Compatible | pkg/gateway/commands.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Streams incremental command output to on_stdout / on_stderr callbacks. |
sandbox.commands.kill(pid) |
POST /sandboxes/{id}/commands/{cmdId}/killConnect-RPC /process.Process/SendSignal |
Compatible | pkg/gateway/commands.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Terminates the background process group and returns True when stopped. |
sandbox.pty / Interactive Terminal |
Connect-RPC /process.Process/* (pty: true):Start, Connect, SendInput,StreamInput, Update, SendSignal |
Partial | pkg/gateway/connectrpc.gocrates/podd/src/commands.rstest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
User impact: Interactive PTY spawn, stdin, resize, signals, and 64 KiB reconnect replay work, but closing stdin half-duplex (CloseStdin) is not supported and returns 501 Not Implemented. |
3. Filesystem Operations
Section titled “3. Filesystem Operations”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
sandbox.files.write(path, data) |
PUT /sandboxes/{id}/filesPUT /filesConnect-RPC /filesystem.Filesystem/Write |
Compatible | pkg/gateway/files.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.pytest/e2b-compat/test_concurrent_sandboxes_isolation.py |
e2b>=2.0.0 (dependency floor only) |
Writes a file and can create parent directories. Gateway/podd path checks in pkg/gateway/files.go are intended to reject .. segments; test/e2b-compat covers writes under /workspace (text and binary) and does not enumerate traversal cases. Uploaded files default to 1000:1000 ownership. |
sandbox.files.read(path) |
GET /sandboxes/{id}/filesGET /filesConnect-RPC /filesystem.Filesystem/Read |
Compatible | pkg/gateway/files.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_sync.pytest/e2b-compat/test_official_e2b_async.pytest/e2b-compat/test_concurrent_sandboxes_isolation.py |
e2b>=2.0.0 (dependency floor only) |
Reads raw file bytes (text and binary format="bytes") from guest /workspace or RootFS. |
sandbox.files.list(path) |
GET /sandboxes/{id}/files/listGET /files/listConnect-RPC /filesystem.Filesystem/*:List, ListDir |
Compatible | pkg/gateway/files.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Returns directory entries with metadata (name, size, isDir, permissions). |
sandbox.files.remove(path) |
DELETE /sandboxes/{id}/filesDELETE /filesConnect-RPC /filesystem.Filesystem/Remove |
Compatible | pkg/gateway/files.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Recursively removes file or directory inside guest. |
sandbox.files.make_dir(path) |
Connect-RPC /filesystem.Filesystem/MakeDir |
Compatible | pkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Creates directory recursively (0755, owned by 1000:1000). |
sandbox.files.watch_dir(path) |
Connect-RPC /filesystem.Filesystem/*:WatchDir, CreateWatcher,GetWatcherEvents, RemoveWatcher |
Compatible | pkg/gateway/watch.gopkg/gateway/connectrpc.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Streams and polls live filesystem create/write/remove events. |
4. Code Interpreter (e2b-code-interpreter)
Section titled “4. Code Interpreter (e2b-code-interpreter)”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
sandbox.run_code(code) [Python REPL] |
POST /sandboxes/{id}/code/executePOST /sandboxes/{id}/executePOST /execute |
Compatible | pkg/gateway/server.go:handleCodeExecutecrates/podd/src/interpreter.rstest/e2b-compat/test_official_code_interpreter.pytest/e2b-compat/test_multimodal_data_science.pytest/e2b-compat/test_streaming_realtime.pytest/e2b-compat/test_timeout_and_zombie_kill.py |
e2b-code-interpreter>=2.0.0 (dependency floor only) |
Executes Python snippets inside podd with persistent memory across runs. Streams NDJSON events with stdout, stderr, rich MIME result (text, png base64 charts, html, json), and runtime error tracebacks. Real-time on_stdout callbacks are verified in test_streaming_realtime.py, multimodal outputs in test_multimodal_data_science.py, and timeout kill in test_timeout_and_zombie_kill.py. |
Multi-Language Kernels (bash, js, ts, r, java) |
POST /sandboxes/{id}/code/execute |
Partial | crates/podd/src/interpreter.rscrates/podd/src/tests.rs |
Unit tests in crates/podd |
In-guest podd daemon natively implements 6 stateful REPL kernels. The official Python e2b-code-interpreter SDK primarily tests Python. |
Contexts Management (/contexts) |
In-guest podd (:49983) |
Partial | crates/podd/src/main.rs:147crates/podd/src/tests.rs |
Unit tests in crates/podd |
In-guest podd handles POST /contexts, GET /contexts, DELETE /contexts/{id}, and POST /contexts/{id}/restart. Protocol difference: Gateway does not register /sandboxes/{id}/code/contexts as a public REST route. Instead, clients pass context_id in the JSON body to POST /sandboxes/{id}/code/execute or call podd directly. |
5. Template Catalog & Custom Builds (E2BTemplateAPI)
Section titled “5. Template Catalog & Custom Builds (E2BTemplateAPI)”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
Template.list() |
GET /templatesGET /v2/templates |
Partial | pkg/gateway/templates.gotest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
User impact: Requires the template API feature to be enabled on the gateway; otherwise GET /templates returns a legacy non-E2B format. |
Template.build(...) |
POST /templatesPOST /v2/templatesPOST /v3/templatesPOST /v2/templates/{id}/builds/{buildID} |
Partial | pkg/gateway/templates.gopkg/controller/builder.gotest/e2b-compat/test_official_e2b_templates.py |
e2b>=2.0.0 |
User impact: Requires template build features to be enabled (otherwise returns 501). Builds do not capture VM memory snapshots (startCmd runs fresh on every boot), and COPY/WORKDIR instructions targeting /workspace are rejected with HTTP 400. |
| Build status & logs | GET /templates/{id}/builds/{buildID}/statusGET /templates/{id}/builds/{buildID}/logs |
Compatible | pkg/gateway/templates.gotest/e2b-compat/test_official_e2b_templates.py |
e2b>=2.0.0 |
Returns build status (building, ready, error) and build logs. |
Template.exists(alias) / Tags & Aliases |
GET /templates/aliases/{alias}GET /templates/{id}/tagsPOST /templates/tagsDELETE /templates/tags |
Partial | pkg/gateway/templates.gotest/e2b-compat/test_official_e2b_templates.pytest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
User impact: Template.exists(alias), assign_tags, get_tags, and remove_tags work when the template API is enabled; extended tag query endpoints (/tags/count, /tags/exists, /tags/groups, /tags/tag-assignments) are not implemented. |
6. Port Ingress & Host Routing
Section titled “6. Port Ingress & Host Routing”| Official E2B Interface | CubePod Gateway Route / Protocol | Status | Evidence / Implementation Pointer | Repo test declaration / version constraint | Behavioral Differences & Limitations |
|---|---|---|---|---|---|
sandbox.get_host(port) |
GET /sandboxes/{id}/endpoints/{port} |
Compatible | pkg/gateway/server.go:handleGetEndpointtest/e2b-compat/test_official_e2b_extended.py |
e2b>=2.0.0 |
Returns <port>-<sandboxID>.<domain> for accessing exposed sandbox ports. |
| Subdomain Ingress Routing | Host: <port>-<sandboxID>.<domain> |
Compatible | pkg/gateway/server.go:hostRouterpkg/gateway/server_test.go |
Go unit/integration tests | Routes <port>-<sandboxID>.<domain> traffic to the sandbox and automatically resumes paused sandboxes when traffic arrives. |
7. Untested or Partial Ecosystem Surfaces
Section titled “7. Untested or Partial Ecosystem Surfaces”| Upstream E2B Surface | Status | User-Facing Limitations & Guidance |
|---|---|---|
Official JS/TS SDK (e2b, @e2b/code-interpreter) |
Partial | User impact: Changed in v0.6.0. Upstream e2b npm package (Sandbox.create, commands.run, getInfo, getMetrics, filesystem, pause/connect, Volumes, Secrets/Secret.fill, network rules, Templates) is verified in make test-e2b-compat-ts; @e2b/code-interpreter is not yet covered by automated CI tests. |
| Agent Framework Integrations (LangChain, LlamaIndex, AutoGen, CrewAI, OpenHands, Smolagents) | Untested | No end-to-end integration tests run these third-party frameworks directly. |
Official E2B Volumes API (POST /volumes, POST /volumes/rotate-key, /volumecontent/{id}/*, volumeMounts) |
Partial | User impact: Volume CRUD and content upload/download work with e2b>=2.0.0, though vol.write_file() / vol.read_file() require passing api_url explicitly against self-hosted gateways (otherwise the upstream SDK targets e2b.app). Changed in v0.8.0: Setting Helm volumes.rwxStorageClassName automatically activates the shared RWX PVC and enables K8sVolumeMounts on Kubernetes (otherwise returns 501 Not Implemented). Added in v0.7.0 / renamed in v0.8.0: Envelope encryption of volume tokens (CUBEPOD_VOLUMES_KEK / CUBEPOD_VOLUMES_KMS_URL), tenant API-key rotation (POST /volumes/rotate-key), per-tenant storage byte quotas (CUBEPOD_VOLUMES_MAX_TENANT_BYTES), and RWX capacity metrics/alerts (deploy/monitoring/volumes-alerts.yaml). |
Official E2B Secrets API (POST /secrets, GET /secrets, POST /secrets/{id}, DELETE /secrets/{id}, Secret.fill(), network.rules) |
Partial | User impact: Write-only secret CRUD and Secret.fill(name) (${e2b.secrets.<name>}) are verified in test_official_secret_crud_and_fill (test/e2b-compat/test_official_e2b_extended.py), alongside Secret.fill / fillSecret parity in CubePod’s native Python and TypeScript SDKs. Changed in v0.6.0: KubeSecretBackend (secrets.backend: "k8s") + background sync + on-demand Vault re-hydration support multi-replica Kubernetes HA gateways over strict mTLS. Local Docker sandboxes still do not run the egress sidecar, so outbound header injection applies in Kubernetes egress mode only. |
Sandbox Lifecycle Events & Webhooks (POST/GET /webhooks, PATCH/DELETE /webhooks/{id}, GET /events, GET /sandboxes/{id}/events) |
Partial | User impact: Added in v0.6.0. Emits E2B v1 lifecycle events (created, paused, resumed, updated, forked, killed) signed with e2b-signature, with pause_mode: "filesystem" and resume_mode: "reboot", including asynchronous idle-reaper transitions detected by SyncPodBoxesOnce. In v0.6.0, webhook registrations and bounded event history are stored in-memory and persisted locally on disk when CUBEPOD_EVENTS_DIR (or CUBEPOD_STATE/gateway persistence PVC) is configured; multi-replica Kubernetes SandboxWebhook CRD + secretRef HA persistence is deferred to v0.7.0. |
Official E2B sandbox.git helper |
Untested | Upstream docs describe sandbox.git as a deprecated SDK helper bound to the command runner (Git is constructed with a Commands object), not a dedicated HTTP git API. No test/e2b-compat case calls sandbox.git. Running git through sandbox.commands.run() is a shell-command path and does not demonstrate official helper compatibility (clone options, credential helpers, dangerously_authenticate, structured status/branch APIs, and similar). |
Key Behavioral & Architectural Differences
Section titled “Key Behavioral & Architectural Differences”1. Pause & Resume vs. Memory Snapshots
Section titled “1. Pause & Resume vs. Memory Snapshots”A fundamental architectural difference between hosted E2B and CubePod is how sandboxes are suspended:
- Upstream E2B Cloud: Official E2B documentation states that pausing saves both the filesystem state and guest memory (RAM), preserving running background processes and in-memory variables across resumes.
- CubePod: Implements cloud-native Kubernetes compute scale-to-zero. When paused (
POST /sandboxes/{id}/pause), the compute Pod is terminated, but both persistent CSI raw block volumes are retained:rootfs-pvc: Attaches the OverlayFSupperdirused for RootFS-level package and OS changes.workspace-pvc: Stores the persistent/workspacefilesystem.
- Consequence upon Resume (
connector inbound traffic):- CubePod starts a new compute Pod and reattaches the retained
rootfsandworkspaceblock volumes. Resume latency is deployment- and storage-dependent and is not a measured SLA on this page. - Filesystem changes that were persisted on those volumes are still present after reattach; this page does not claim bit-identical preservation of every in-guest state.
- Guest RAM and processes that existed only in the previous compute Pod are not restored. Daemons needed after resume must be defined in the template
startCmdor started again by the agent.
- CubePod starts a new compute Pod and reattaches the retained
2. Template Builds & /workspace Rejection
Section titled “2. Template Builds & /workspace Rejection”When using Template.build() under --e2b-template-api=true:
- CubePod builds a standard OCI container image using rootless BuildKit (in Kubernetes) or the local Docker daemon.
- It does not produce a pre-paused VM memory snapshot;
startCmdexecutes freshly every time a new sandbox is spawned from the template. - Crucial Invariant: Any Dockerfile
COPYorWORKDIRdirective that targets/workspaceis explicitly rejected with HTTP400 Bad Request. Because/workspaceis mounted from an independent persistent block PVC (workspace-pvc) at runtime, files baked into the image under/workspacewould be permanently hidden beneath the volume mount. Place template files in/opt/,/usr/local/, or custom system paths.
3. Code Context Management (/contexts)
Section titled “3. Code Context Management (/contexts)”In hosted E2B, code interpreter contexts may be managed via dedicated context endpoints.
- In CubePod, stateful execution contexts for 6 languages (
python,bash,javascript,typescript,r,java) are managed directly inside the in-guest Rust daemonpodd(:49983). cubepod-gatewaydoes not register/sandboxes/{id}/code/contextsas a separate public route.- To execute code within a specific stateful context, pass
context_idinside the request body ofPOST /sandboxes/{id}/code/execute(orPOST /sandboxes/{id}/execute). The gateway forwards the context identifier directly topodd.
4. Error Response Envelopes & Exception Mapping
Section titled “4. Error Response Envelopes & Exception Mapping”Error serialization across cubepod-gateway differs by subsystem:
- Template API Handlers (
pkg/gateway/templates.go): Return JSON objects viawriteError:{"code": 404,"message": "template not found"} - Connect-RPC Handlers (
pkg/gateway/connectrpc.go): Return Connect-RPC JSON envelopes viawriteConnectError:{"code": "not_found","message": "sandbox not found"} - Standard REST Sandbox Handlers (
pkg/gateway/sandboxes.go): Return plain-text error bodies via standard Gohttp.Error:sandbox not found
Because different error envelopes are emitted depending on the subsystem, upstream SDK exception parsing (e.g., catching specific E2B Python exception classes) may not map identically to hosted E2B across all error conditions.
CubePod Superset Capabilities (Extensions)
Section titled “CubePod Superset Capabilities (Extensions)”CubePod provides enterprise capabilities that do not exist in standard E2B. These are exposed through CubePod’s native SDKs (sdks/python/, sdks/typescript/, Go client in pkg/client, and CLI in cmd/cubepod) and REST superset endpoints:
- Persistent Writable RootFS & Non-Destructive Reset:
POST /sandboxes/{id}/reset-rootfsincrementsspec.rootfsGenerationand allocates a new OSupperdirPVC. This operation does not replace the sandbox’sworkspace-pvc. - Copy-on-Write Sandbox Forking:
POST /sandboxes/{id}/forkquiesces guest filesystems viaFIFREEZE, takes a storage-level CoW clone of bothrootfsandworkspaceblock volumes, and executesFITHAW, creating an independent child sandbox. Duration depends on the volume backend and is not a measured SLA on this page. - Zero-Trust Egress Credential Substitution (
cpodref_): PasssecretBindingswhen creating a sandbox. The sandbox runtime only ever sees opaque placeholders (such ascpodref_openai_key), which are swapped for real upstream API tokens strictly at thecubepod-egresssidecar proxy over mTLS. - Streaming Workspace Synchronization (
archive-sync):POST /sandboxes/{id}/files/archive-syncstreams.tar/.tar.gzdirectory trees into the sandbox. Archive unpacking inpkg/gateway/files.goincludes checks intended to reject..path segments; this page does not treat that as a fully audited security guarantee. The API is meant for bulk sync instead of one HTTP request per file. - On-Demand Desktops & Authenticated Panel Proxies:
POST /sandboxes/{id}/desktop/startlazily initializesXvfb, Chromium CDP,noVNC, andttyd, returning HMAC-signed/panel/{token}/URLs for live browser viewing and terminal interaction.
Migration Checklist
Section titled “Migration Checklist”When transitioning from hosted E2B to self-hosted CubePod:
- Verify Environment Variables:
Ensure
E2B_DOMAIN(with wildcard DNS) or bothE2B_API_URLandE2B_SANDBOX_URLare exported before importing the official SDK. - Check Template Feature Flags (both binaries define
--e2b-template-api/--feature-gate=E2BTemplateAPI=trueand--template-buildincmd/cubepod-gateway/main.goandcmd/cubepod-controller/main.go):- Enable
--e2b-template-api=true(or the equivalent feature gate) on cubepod-gateway to register the E2B template HTTP routes. - Enable
--template-build=trueon cubepod-gateway as well; otherwise build-related routes (context upload, logs, start build) return HTTP 501 before any forwarding. - In Kubernetes, also enable
--template-build=trueon cubepod-controller, which runs the BuildKit or Docker build pipeline. The controller also accepts--e2b-template-api. - In local/single-process mode (no Kubernetes client and no
--controller-url), the gateway’s in-process reconciler usesLocalDockerBuilder; a separate controller is not required.
- Enable
- Audit
/workspacePaths in Templates: Review any Dockerfiles used inTemplate.build()to confirm they do notCOPYfiles into/workspace. - Account for Process Lifecycles across Pauses:
Do not rely on in-memory daemon processes surviving a sandbox pause. Structure agent tasks so persistent state is written to
/workspaceor RootFS. - Run the Compatibility Test Harness:
Maintainers can validate their gateway deployment against the official Python SDK test suite:
Terminal window make test-e2b-compat
Next Steps
Section titled “Next Steps”- Explore the complete REST and streaming contract in the API Overview.
- Test endpoints directly in the Interactive OpenAPI Explorer.
- Learn about native enterprise SDKs in the Python SDK Guide and TypeScript SDK Guide.
- Review Kubernetes deployment and storage configuration in Kubernetes & Helm Deployment.