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.
npm i e2b # JavaScript / TypeScript
pip install e2b # PythonGet and set your API key
Sign up at e2b.dev, grab your API key from the dashboard, and set it as an environment variable.
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.
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().
npm i @e2b/code-interpreter # JavaScript/TypeScript
pip install e2b-code-interpreter # PythonCommands 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 gpu & compute clouds tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Daytona | ★ 72.2k | Daytona is an open-source runtime that spins up isolated sandboxes in under 90ms so agents can safely run and persist AI-generated code. |
| Ray | ★ 43.2k | A distributed computing framework that scales Python and ML workloads for training, tuning, data processing, and serving. |
| Prefect | ★ 23.3k | A Python-native workflow orchestration tool for scheduling, running, and monitoring data and ML pipelines. |
| Dagster | ★ 15.8k | A data and ML pipeline orchestrator with a declarative asset model, built-in lineage, and observability. |
| Kubeflow | ★ 15.8k | A Kubernetes toolkit that brings together pipelines, notebooks, and training operators for running ML workflows at scale. |
| E2B | ★ 13k | Run AI-generated code in secure, isolated cloud sandboxes |
| OpenSandbox | ★ 12k | OpenSandbox 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. |
| SkyPilot | ★ 10.3k | A framework that runs AI jobs across clouds and Kubernetes, automatically finding and provisioning the cheapest available GPUs. |