E2B README

The project's README from github.com/e2b-dev/E2B. As one markdown file: README.md.

E2B Logo E2B Logo

Last 1 month downloads for the Python SDK Last 1 month downloads for the JavaScript SDK

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 self-hosting guide to learn how to set up the E2B infrastructure on your own. The infrastructure is deployed using Terraform.

Supported cloud providers:

E2B (e2b-dev/E2B)

Searching Database…

14.4K ·GitHub
这是什么?E2B 是开源基础设施,可以让你在安全、隔离的云端沙箱中运行 AI 生成的代码,使智能体能够安全地执行不可信的代码。
这是一个库还是云服务?两者都是:它是一项沙箱云服务,可以通过 JavaScript/TypeScript 或 Python SDK 进行控制;你也可以自行部署整套基础设施。
怎样运行我的第一个沙箱?安装 SDK,注册获取 E2B API 密钥,将其设置为环境变量,然后在 JS/TS 或 Python 代码中启动沙箱并运行命令。
使用沙箱是否需要 E2B API 密钥?需要。在启动任何沙箱之前,你都需要先在 E2B 注册并获取 API 密钥。
我可以自行部署 E2B,而不使用云服务吗?可以。有一份自部署指南,使用 Terraform 部署基础设施,但目前只完全支持 AWS 和 GCP,Azure 和通用 Linux 机器尚未支持。
E2B 面向哪些人?面向开发 AI 智能体或副驾驶的开发者,这些应用需要安全地执行由大语言模型生成的代码,例如代码解释器或 AI 编程助手。
这是桌面应用还是云平台?这是一个云平台,通过你自己的 JS/Python 代码调用 SDK 来访问,不涉及任何桌面应用。
Code Interpreter SDK 是做什么用的?这是一个附加 SDK,可以通过简单的 runCode()/run_code() 调用在沙箱内执行代码,适用于类似笔记本的智能体工作流。
Desktop SDK 是什么?它为沙箱增加了计算机使用能力,包括鼠标、键盘、截图、应用程序控制以及桌面流式传输 API。
有没有可以学习的示例项目?有。E2B Cookbook 提供了将 E2B 沙箱与不同大语言模型和 AI 框架结合使用的示例。
哪些云服务商支持托管的 E2B 服务?托管的 E2B 云服务本身开箱即用;自部署选项则专门支持通过 Terraform 在 AWS 和 GCP 上部署。
Creator
e2b-dev
Size
127.1 MB
Stars
14.4K
Age
3y
Commits · 90 Days