AI/TLDR

E2B

Run AI-generated code in secure, isolated cloud sandboxes

Code Sandboxes & IsolationOpen source
Language
Python
License
Apache-2.0
Coverage
1 story
$npm i e2b # JavaScript / TypeScript

Overview

E2B is open-source infrastructure that lets you run AI-generated code in secure, isolated sandboxes in the cloud. Each sandbox is a separate environment, so code produced by a language model can run safely without putting your own systems at risk.

You start and control sandboxes from your own application using the E2B JavaScript or Python SDK. Inside a sandbox you can run shell commands and, with the Code Interpreter SDK, execute code directly and read back the result. E2B can be used as a hosted service with an API key, or self-hosted on your own cloud.

What it does

  • Secure, isolated cloud sandboxes for running untrusted, AI-generated code
  • Official SDKs for both JavaScript/TypeScript and Python
  • Run shell commands inside a sandbox and read back stdout
  • Code Interpreter SDK to execute code with runCode() / run_code() and get the result
  • Self-hosting option using Terraform on AWS or Google Cloud (GCP)
  • Cookbook with examples for different LLMs and AI frameworks

Getting started

Install the SDK, set your E2B API key, then create a sandbox and run commands inside it. For executing code and reading the result, add the Code Interpreter SDK.

Install the SDK

Install the E2B SDK for your language using npm or pip.

bashbash
npm i e2b        # JavaScript / TypeScript
pip install e2b  # Python

Get and set your API key

Sign up at e2b.dev, grab your API key from the dashboard, and set it as an environment variable.

bashbash
E2B_API_KEY=e2b_***

Start a sandbox and run a command

Create a sandbox and run a shell command inside it, then read the output.

tsts
import Sandbox from 'e2b'

const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo "Hello from E2B!"')
console.log(result.stdout) // Hello from E2B!

Execute code with the Code Interpreter SDK

To run code and read back the result, install the Code Interpreter SDK and use runCode() / run_code().

bashbash
npm i @e2b/code-interpreter     # JavaScript/TypeScript
pip install e2b-code-interpreter  # Python

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Safely running code that a language model generates, without exposing your own machine
  • Building AI agents and code interpreters that need to execute and check code on the fly
  • Giving data-analysis or coding assistants a clean, throwaway environment for each task
  • Self-hosting sandbox infrastructure on AWS or GCP for full control over where code runs

How E2B compares

E2B alongside other open-source code sandboxes & isolation tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Daytona★ 71.7kDaytona is an open-source runtime that spins up isolated sandboxes in under 90ms so agents can safely run and persist AI-generated code.
NVIDIA NemoClaw★ 22.5kNVIDIA's reference stack for running OpenClaw, Hermes and LangChain Deep Agents Code inside OpenShell sandboxes, adding managed inference, network policy, snapshots and CLI lifecycle control.
OpenSandbox★ 15.4kOpenSandbox gives AI agents a safe place to run code and commands, with one unified API across Docker and Kubernetes runtimes and SDKs in five languages.
E2B★ 13.8kRun AI-generated code in secure, isolated cloud sandboxes
Astrid★ 10.3kA portable Rust runtime that executes software as sandboxed WebAssembly capsules, where every file, network, process and tool call is gated by a signed, revocable, per-principal capability instead of ambient authority.
Cloudflare Computer★ 9.2kA virtual filesystem inside a Durable Object that gives an agent one execution surface across Workers isolates and full Linux containers.
smolvm★ 6.1kA cross-platform CLI that boots sub-second Linux microVMs from a declarative Smolfile, so untrusted or agent-generated code runs behind a hypervisor boundary.
micropython-wasm★ 174Runs untrusted Python inside a WASI MicroPython module via Wasmtime, with memory caps, a CPU fuel budget, a wall-clock timeout and no network access.