需先注册 E2B 并设置 E2B_API_KEY 环境变量才能创建沙箱;执行代码需额外安装 e2b-code-interpreter 或 @e2b/code-interpreter;桌面操作需单独安装 e2b-desktop 或 @e2b/desktop
E2B
e2b-devApache-2.0活跃维护为 AI Agent 提供安全隔离的云端沙箱环境,内置真实工具和代码解释器,让 Agent 能安全执行代码、操作文件而不影响宿主系统。
Open-source, secure environment with real-world tools for enterprise-grade agents.
pip install e2b
npm i e2bREADME 未说明本地硬件或显存要求,沙箱运行在云端;自托管支持 AWS、GCP、Azure 及通用 Linux 机器
在云端安全隔离沙箱里运行 AI 生成代码的开源基础设施,提供 JS 和 Python SDK
为 AI Agent 提供安全隔离的云端沙箱环境,内置真实工具和代码解释器,让 Agent 能安全执行代码、操作文件而不影响宿主系统。
核心能力
- 用 SDK 创建并控制云端隔离沙箱执行命令
- 提供 Code Interpreter SDK 直接运行代码片段
- Desktop SDK 支持鼠标键盘截图与桌面流
- 自托管基于 Terraform 部署 E2B runtime
容易踩的坑
- @e2b/[email protected]2026-11-04 · 2026-11-04 16:41 UTC
查看更新说明
Minor Changes
- a8155c4: Add
stricttopause()(defaultfalse). Withstrict: true/strict=Truea pause is refused withServiceBusyError/ServiceBusyExceptionwhile the sandbox's guest agent does not respond, and the sandbox keeps running. Without it the API's default applies: the memory snapshot is taken anyway and marked. Sandbox info exposes the mark asenvdUnresponsiveAtPause/envd_unresponsive_at_pause, and resuming such a sandbox withoutonResume: 'reboot'/on_resume="reboot"now throwsGuestUnresponsiveError/GuestUnresponsiveException.
- a8155c4: Add
- @e2b/[email protected]2026-11-04 · 2026-11-04 16:41 UTC
查看更新说明
Patch Changes
- Updated dependencies [a8155c4]
- @e2b/[email protected]
- Updated dependencies [a8155c4]
Minor Changes
- a8155c4: Add
stricttopause()(defaultfalse). Withstrict: true/strict=Truea pause is refused withServiceBusyError/ServiceBusyExceptionwhile the sandbox's guest agent does not respond, and the sandbox keeps running. Without it the API's default applies: the memory snapshot is taken anyway and marked. Sandbox info exposes the mark asenvdUnresponsiveAtPause/envd_unresponsive_at_pause, and resuming such a sandbox withoutonResume: 'reboot'/on_resume="reboot"now throwsGuestUnresponsiveError/GuestUnresponsiveException.
- a8155c4: Add
- [email protected]2026-11-03 · 2026-11-03 19:43 UTC
查看更新说明
Patch Changes
- 08f05bb: Fix
TypeError: fetch failed/NGHTTP2_ENHANCE_YOUR_CALMon concurrentfiles.write()calls. Node's HTTP/2 client queues each request body in full against a 10 MB per-session memory budget and resets the stream whose response arrives while it is exhausted; since undici 8 every envd request of a process shares one session, so parallel or large uploads reset each other and the reads next to them.files.write()uploads now go over HTTP/1.1 on a pool of their own (one request per connection, no shared budget;E2B_ENVD_UPLOAD_CONNECTIONS, default 50), and an envd dispatcher whose HTTP/2 session Node reports as out of memory is retired and replaced instead of failing every later request. Nothing is retried: a failed write may already have been applied. - 1ad3f76: Template builds hash
copy()files in 1 MB chunks instead of reading each file fully into memory, cutting peak memory for large files. Hashes are unchanged, so existing build caches stay valid.
- 08f05bb: Fix
- @e2b/[email protected]2026-11-03 · 2026-11-03 19:43 UTC
查看更新说明
Patch Changes
- 48d24ac: - Fixed
Sandbox.files.read/AsyncSandbox.files.readfailing at random for files over ~500 KB (and always for a few MB) withhttpx.ReadError ... too_many_data_frames. File downloads now go over HTTP/1.1 regardless ofhttp_version, as h2 closed HTTP/2 connections after receiving 100 empty DATA frames, which the sandbox proxy sends throughout file responses. - 1ad3f76: Template builds hash
copy()files in 1 MB chunks instead of reading each file fully into memory, cutting peak memory for large files. Hashes are unchanged, so existing build caches stay valid.
- 48d24ac: - Fixed
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
What is E2B?
E2B is an open-source infrastructure that allows you to run AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our JavaScript SDK or Python SDK.
Run your first Sandbox
1. Install SDK
JavaScript / TypeScript
npm i e2b
Python
pip install e2b
2. Get your E2B API key
E2B_API_KEY=e2b_***
3. 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!
4. Code execution with Code Interpreter
If you need to execute code with runCode()/run_code(), install the Code Interpreter SDK (JavaScript / Python):
npm i @e2b/code-interpreter # JavaScript/TypeScript
pip install e2b-code-interpreter # Python
import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
const execution = await sandbox.runCode('x = 1; x += 1; x')
console.log(execution.text) // outputs 2
5. Computer use with Desktop
For mouse, keyboard, screenshot, application, and desktop streaming APIs, install the Desktop SDK (JavaScript / Python):
npm i @e2b/desktop # JavaScript/TypeScript
pip install e2b-desktop # Python
import { Sandbox } from '@e2b/desktop'
const desktop = await Sandbox.create()
await desktop.launch('google-chrome')
const screenshot = await desktop.screenshot()
6. Check docs
Visit E2B documentation.
7. E2B cookbook
Visit our Cookbook to get inspired by examples with different LLMs and AI frameworks.
Self-hosting
Read the embed deployment guide to learn how to set up the E2B runtime on your own. The infrastructure is deployed using Terraform.
Supported cloud providers:
- 🟢 AWS
- 🟢 Google Cloud (GCP)
- 🟢 Azure
- 🟢 General Linux machine (via Embed)