E2B — Secure Sandboxes for AI Code Execution
Open-source cloud sandboxes for AI agents to execute code safely. Isolated Linux environments with filesystem, networking, and process control. 11.5K+ stars.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 49c40861-0582-4894-a6ab-5841858eb6d7 --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
E2B provides open-source, secure cloud sandboxes for AI agents to execute code safely. Each sandbox is an isolated Linux environment with its own filesystem, networking, and process control, spun up in roughly 150 milliseconds. The primary use case is letting LLM-powered agents run generated code without risking the host system or leaking sensitive data.
It is designed for developers building AI coding assistants, data analysis agents, or any application where an LLM needs to run untrusted code in a controlled environment.
How it saves time or tokens
Without E2B, developers build custom Docker-based sandboxing, handle timeout management, and deal with resource limits manually. E2B abstracts all of this behind a Python or TypeScript SDK. Sandboxes start in under a second and clean up automatically. The code interpreter SDK provides a pre-configured Python environment with common data science libraries already installed, removing setup overhead for analytics use cases.
How to use
- Install the SDK and get an API key.
pip install e2b-code-interpreter
- Run code in a sandbox.
from e2b_code_interpreter import Sandbox
with Sandbox() as sandbox:
execution = sandbox.run_code("print('Hello from sandbox!')")
print(execution.text)
- Get your API key at e2b.dev and set it as
E2B_API_KEYin your environment.
Example
Running a data analysis task:
from e2b_code_interpreter import Sandbox
code = '''
import pandas as pd
import numpy as np
df = pd.DataFrame({
'product': ['A', 'B', 'C'] * 100,
'revenue': np.random.uniform(100, 1000, 300)
})
print(df.groupby('product')['revenue'].agg(['mean', 'sum']).round(2))
'''
with Sandbox() as sandbox:
result = sandbox.run_code(code)
print(result.text)
The sandbox has pandas, numpy, matplotlib, and other common libraries pre-installed.
Related on TokRepo
- AI agent tools -- Frameworks and infrastructure for building autonomous AI agents.
- Coding tools -- Developer tools that integrate with AI workflows.
Common pitfalls
- Sandbox instances have resource limits (CPU, memory, execution time). Long-running computations may be terminated. Check the plan limits on e2b.dev.
- The free tier has a limited number of sandbox hours per month. Monitor usage to avoid unexpected throttling.
- Network access from sandboxes is enabled by default. If your use case requires full isolation, configure the sandbox to disable outbound networking.
常见问题
Yes. The E2B SDK and sandbox runtime are open source under the Apache 2.0 license. The cloud infrastructure that runs the sandboxes is a managed service. You can also self-host the sandbox runtime using the open-source components.
E2B sandboxes start in approximately 150 milliseconds. This is fast enough for interactive use cases where an AI agent needs to execute code and return results within a conversation turn.
The code interpreter sandbox comes with Python pre-installed. You can also create custom sandbox templates with any language runtime -- Node.js, Go, Rust, or anything that runs on Linux. Custom templates are defined via Dockerfiles.
Each sandbox runs in an isolated microVM with its own kernel, filesystem, and network namespace. There is no shared state between sandboxes. If a sandbox executes malicious code, it cannot affect other sandboxes or the host.
Yes. E2B provides integrations for LangChain, CrewAI, and OpenAI function calling. The SDK returns structured output that agent frameworks can parse and use as tool results.
引用来源 (3)
- E2B GitHub— Open-source secure cloud sandboxes with isolated Linux environments
- E2B Documentation— Sandboxes start in approximately 150ms using microVMs
- E2B SDK README— Integrations with LangChain, CrewAI, and OpenAI
TokRepo 相关
来源与感谢
Created by E2B. Licensed under Apache 2.0. e2b-dev/e2b — 11,500+ GitHub stars
讨论
相关资产
E2B — Cloud Sandboxes for AI Code Execution
Secure cloud sandboxes that let AI agents run code, install packages, and use the filesystem. Spin up in 150ms. Used by Vercel, Langchain, and CrewAI.
Daytona — Secure Sandboxes for AI Code Execution
Elastic infrastructure for running AI-generated code safely. SDKs for Python, TypeScript, Go. By Daytona. 71K+ GitHub stars.
E2B — Secure Sandboxes for AI Code
E2B runs AI-generated code in isolated cloud sandboxes. Install the Python/JS SDK, set `E2B_API_KEY`, then execute commands safely inside a sandbox.
microsandbox — Secure Local Sandboxes for AI Agents
microsandbox provides lightweight, programmable sandboxes that let AI agents execute code safely on your own machine, with strong isolation and support for multiple runtimes.