E2B
E2B is an open-source infrastructure for running AI-generated code in secure, isolated cloud sandboxes. It provides JavaScript and Python SDKs to start and control sandboxes, solving the problem of safely executing untrusted code. It is for developers building AI applications that need to run code or interact with computer environments.
✨ Key features
- Secure isolated cloud sandboxes for AI-generated code
- JavaScript and Python SDKs for sandbox control
- Run shell commands in sandboxes
- Code interpreter for executing code snippets
- Desktop SDK for computer use (mouse, keyboard, screenshots)
- Self-hosting with Terraform on AWS and GCP
🎯 Use cases
- Execute AI-generated code safely in the cloud
- Run code snippets with a code interpreter
- Automate computer tasks like launching apps and taking screenshots
- Build AI agents that need isolated execution environments
📦 Installation
🧰 Requirements: Requires an E2B API key (sign up at e2b.dev) and either Node.js for JavaScript SDK or Python for Python SDK.
Install SDK
JavaScript / TypeScript
npm i e2b
Python
pip install e2b
For Code Interpreter:
npm i @e2b/code-interpreter
pip install e2b-code-interpreter
For Desktop:
npm i @e2b/desktop
pip install e2b-desktop
🚀 Usage
Start a sandbox and run commands
JavaScript / TypeScript
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!
Python
from e2b import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run('echo "Hello from E2B!"')
print(result.stdout) # Hello from E2B!
⚠️ Good to know
Self-hosting supports AWS and GCP, but not Azure or general Linux machines as of the README.
❓ FAQ
How do I get an API key?
Sign up at e2b.dev and get your API key from the dashboard, then set it as the environment variable E2B_API_KEY.
Can I run code snippets directly?
Yes, install the Code Interpreter SDK and use runCode() (JS) or run_code() (Python) to execute code.
Can I control a desktop environment?
Yes, install the Desktop SDK to use mouse, keyboard, screenshots, and launch applications.
Can I self-host E2B?
Yes, follow the self-hosting guide to deploy the infrastructure using Terraform on AWS or GCP.
📊 Repository
🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.