# 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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash npm install @e2b/code-interpreter ``` ```typescript import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create() const result = await sandbox.runCode('print(1 + 1)') console.log(result.text) // "2" await sandbox.kill() ``` ## What is E2B? E2B provides secure, isolated cloud sandboxes for AI agents to execute code. Each sandbox is a micro-VM that spins up in ~150ms with a full Linux environment — perfect for code interpreters, data analysis agents, and AI-generated code execution. **Answer-Ready**: E2B provides secure cloud sandboxes (micro-VMs) that spin up in 150ms for AI agents to execute code, install packages, and access filesystems safely. ## Core Features ### 1. Code Interpreter SDK ```python from e2b_code_interpreter import Sandbox sandbox = Sandbox() # Run Python with automatic package installation execution = sandbox.run_code( "import pandas as pd\\n" "import matplotlib.pyplot as plt\\n" "df = pd.DataFrame({\'x\': [1,2,3], \'y\': [4,5,6]})\\n" "df.plot()\\n" "plt.savefig(\'chart.png\')\\n" "print(df.describe())" ) print(execution.text) # stdout print(execution.results) # rich outputs (charts, tables) ``` ### 2. Custom Sandbox Templates ```dockerfile # e2b.Dockerfile FROM e2b/base RUN pip install numpy pandas scikit-learn RUN npm install -g typescript ``` ```bash e2b template build --name "data-science" ``` ### 3. Filesystem Access ```python # Upload files sandbox.files.write("/home/user/data.csv", csv_content) # Download results content = sandbox.files.read("/home/user/output.json") # List files files = sandbox.files.list("/home/user/") ``` ### 4. Long-Running Sandboxes ```python # Keep alive for up to 24 hours sandbox = Sandbox(timeout=3600) # 1 hour # Pause and resume sandbox_id = sandbox.pause() # ... later ... sandbox = Sandbox.resume(sandbox_id) ``` ### 5. Framework Integrations ```python # OpenAI Assistants from e2b_code_interpreter import Sandbox # Use as code_interpreter tool handler # Vercel AI SDK # Built-in e2b sandbox support # LangChain from langchain_e2b import E2BCodeInterpreterTool ``` ## Use Cases | Use Case | Example | |----------|---------| | Code Interpreter | ChatGPT-like code execution | | Data Analysis | Run pandas/matplotlib in sandbox | | CI/CD | Test AI-generated code safely | | Education | Student code execution | ## FAQ **Q: How secure are the sandboxes?** A: Each sandbox is an isolated Firecracker micro-VM with no network access to other sandboxes. **Q: Pricing?** A: Free tier with 100 sandbox hours/month. Pay-as-you-go after that. **Q: Supported languages?** A: Any language that runs on Linux — Python, Node.js, Go, Rust, etc. ## Source & Thanks - GitHub: [e2b-dev/e2b](https://github.com/e2b-dev/e2b) (10k+ stars) - Docs: [e2b.dev/docs](https://e2b.dev/docs) ## 快速使用 ```bash npm install @e2b/code-interpreter ``` 三行代码启动安全云沙箱,让 AI 代理执行代码。 ## 什么是 E2B? E2B 提供安全隔离的云沙箱(微虚拟机),150ms 启动,为 AI 代理提供完整 Linux 环境执行代码。 **一句话总结**:E2B 提供 150ms 启动的安全云沙箱,让 AI 代理安全执行代码、安装包和访问文件系统。 ## 核心功能 ### 1. 代码解释器 SDK 运行 Python/JS 代码,自动安装依赖。 ### 2. 自定义模板 用 Dockerfile 预装工具和包。 ### 3. 文件系统 上传下载文件,完整文件操作。 ### 4. 长时间运行 支持暂停/恢复,最长 24 小时。 ## 常见问题 **Q: 安全吗?** A: 每个沙箱是隔离的 Firecracker 微虚拟机。 **Q: 定价?** A: 每月 100 沙箱小时免费,超出按量付费。 ## 来源与致谢 - GitHub: [e2b-dev/e2b](https://github.com/e2b-dev/e2b) (10k+ stars) --- Source: https://tokrepo.com/en/workflows/652da886-2a64-4ee0-8a19-e72d1742fe7f Author: Skill Factory