E2B

e2b-devApache-2.0活跃维护

为 AI Agent 提供安全隔离的云端沙箱环境,内置真实工具和代码解释器,让 Agent 能安全执行代码、操作文件而不影响宿主系统。

Open-source, secure environment with real-world tools for enterprise-grade agents.

[email protected]发布于 2026-11-04 16:41 UTC14,790star +27 / 7 天1,161fork同步于 2026-11-10 05:27 UTC

怎么上手

由 README 提炼,执行前请确认
pip install e2b
npm i e2b
硬件要求按 README 说明

README 未说明本地硬件或显存要求,沙箱运行在云端;自托管支持 AWS、GCP、Azure 及通用 Linux 机器

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

在云端安全隔离沙箱里运行 AI 生成代码的开源基础设施,提供 JS 和 Python SDK

为 AI Agent 提供安全隔离的云端沙箱环境,内置真实工具和代码解释器,让 Agent 能安全执行代码、操作文件而不影响宿主系统。

核心能力

  • 用 SDK 创建并控制云端隔离沙箱执行命令
  • 提供 Code Interpreter SDK 直接运行代码片段
  • Desktop SDK 支持鼠标键盘截图与桌面流
  • 自托管基于 Terraform 部署 E2B runtime

容易踩的坑

需先注册 E2B 并设置 E2B_API_KEY 环境变量才能创建沙箱;执行代码需额外安装 e2b-code-interpreter 或 @e2b/code-interpreter;桌面操作需单独安装 e2b-desktop 或 @e2b/desktop

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本[email protected]
  1. @e2b/[email protected]2026-11-04 · 2026-11-04 16:41 UTC
    查看更新说明

    Minor Changes

    • a8155c4: Add strict to pause() (default false). With strict: true / strict=True a pause is refused with ServiceBusyError / ServiceBusyException while 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 as envdUnresponsiveAtPause / envd_unresponsive_at_pause, and resuming such a sandbox without onResume: 'reboot' / on_resume="reboot" now throws GuestUnresponsiveError / GuestUnresponsiveException.
  2. @e2b/[email protected]2026-11-04 · 2026-11-04 16:41 UTC
    查看更新说明

    Patch Changes

  3. [email protected]最新正式版2026-11-04 · 2026-11-04 16:41 UTC

    Minor Changes

    • a8155c4: Add strict to pause() (default false). With strict: true / strict=True a pause is refused with ServiceBusyError / ServiceBusyException while 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 as envdUnresponsiveAtPause / envd_unresponsive_at_pause, and resuming such a sandbox without onResume: 'reboot' / on_resume="reboot" now throws GuestUnresponsiveError / GuestUnresponsiveException.
  4. [email protected]2026-11-03 · 2026-11-03 19:43 UTC
    查看更新说明

    Patch Changes

    • 08f05bb: Fix TypeError: fetch failed / NGHTTP2_ENHANCE_YOUR_CALM on concurrent files.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.
  5. @e2b/[email protected]2026-11-03 · 2026-11-03 19:43 UTC
    查看更新说明

    Patch Changes

    • 48d24ac: - Fixed Sandbox.files.read / AsyncSandbox.files.read failing at random for files over ~500 KB (and always for a few MB) with httpx.ReadError ... too_many_data_frames. File downloads now go over HTTP/1.1 regardless of http_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.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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

    1. Sign up to E2B here.
    2. Get your API key here.
    3. Set environment variable with your 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)