E2B 发布 e2b-cookbook:E2B SDK 示例代码与指南合集
e2b-dev/e2b-cookbook
E2B 推出 e2b-cookbook,汇集基于 E2B SDK 构建的示例代码与指南,覆盖 OpenAI、Anthropic、Meta、Mistral、Groq 等模型提供方及 LangChain、LangGraph、Pydantic AI、CrewAI、Vercel AI SDK 等框架集成。
Example code and guides for building with E2B SDK.
Read more about E2B on the E2B website and the official E2B documentation.
Examples
Hello World guide
Open-source apps
- E2B AI Analyst - analyze your data & create interactive charts
- E2B Fragments - prompt different LLMS to generate apps with UI
- E2B Surf - computer use AI agent powered by OpenAI
Multi-turn reinforcement learning
- OpenEnv Terminus: inspect, run and repair a report in E2B — first reward without a model or GPU, with optional native TRL training wiring.
LLM providers
| Provider | Topic(s) | Example | Python | TypeScript |
|---|---|---|---|---|
| OpenAI | Agents SDK | Agentic workflows running in E2B sandboxes | Python | - |
| Agents API | Full-stack workbench, one E2B sandbox per chat | Python | - | |
| Agents API | Webhook-managed sandbox lifecycle per session | Python | - | |
| GPT-5.6 | Data analysis and visualization of a CSV | Python | TypeScript | |
| GPT-5.6 | Code interpreter and reasoning on image data | Python | TypeScript | |
| GPT-5.6 | Code interpreter for ML on dataset | Python | TypeScript | |
| Codex CLI | OpenAI Codex, running inside a Sandbox | Python | TypeScript | |
| Computer use | Copy new hires from Excel into OrangeHRM on an E2B desktop with GPT-6 Luna, or let GPT-6 Astra drive the desktop with PyAutoGUI and Playwright code | Python | TypeScript | |
| Anthropic | Claude Opus 5 | Code interpreter | Python | TypeScript |
| Claude Code | Claude Code, running inside a Sandbox | Python | TypeScript | |
| Claude Managed Agents | Self-hosted worker running inside a Sandbox | Python | - | |
| Computer use + browser use | Copy new hires from Excel into OrangeHRM on an E2B desktop | - | TypeScript | |
| Claude Agent SDK + Box Mount | Review a contract from a Box folder mounted in a Sandbox | - | TypeScript | |
| Meta | Muse Spark | Coding agent with E2B as its execution backend | Python | - |
| Mistral | Codestral | Code interpreter | Python | TypeScript |
| Groq | Llama 3 | Code interpreter via function calling | Python | TypeScript |
| Fireworks AI | Qwen2.5-Coder-32B-Instruct | Code interpreter | Python | - |
| Llama 3.1 405B, 70B, 8B | Code interpreter | Python | - | |
| Together AI | Llama 3.1, Qwen 2, Code Llama, DeepSeek Coder | Code interpreter | Python | TypeScript |
| WatsonX AI | IBM Graphite, Llama, Mistral | Code interpreter | Python | TypeScript |
AI frameworks integrations
| Framework | Description | Python | TypeScript |
|---|---|---|---|
| 🦜⛓️ LangChain | LangChain with Code Interpreter | Python | - |
| 🦜🕸️ LangGraph | LangGraph with code interpreter | Python | - |
| Plan-and-execute coding agent: one sandbox across graph steps, checkpoints and a human-in-the-loop interrupt | Python | - | |
| Pydantic AI | Pause and resume a coding agent in the same E2B sandbox | Python | - |
| Pydantic AI + Temporal | Recover a crashed worker with the same sandbox ID and preserved project files | Python | - |
| DSPy RLMs | Remote CPython and SQLite with host-side sub-model tools | Python | - |
| CrewAI | CrewAI agent with sandboxed Python execution | Python | - |
| Hermes Agent | Learn an incident-triage skill in one sandbox and apply it in a fresh session | Python | - |
| ▲ Vercel AI SDK | Next.js + AI SDK + Code Interpreter | - | TypeScript |
| ▲ Vercel AI SDK | AI SDK sandbox provider: sandboxed tools via restricted sessions, and harness coding agents (Claude Code, Codex) running inside E2B | - | TypeScript |
| ▲ Vercel eve | Feedback analyst agent whose sandbox backend is E2B, publishing an HTML report from the sandbox | - | TypeScript |
| Flue | Feedback analyst agent running entirely inside an E2B sandbox, publishing an HTML report from the sandbox | - | TypeScript |
| Pi | Pi builds its own E2B code-interpreter extension in a sandbox, then uses it to analyze data | - | TypeScript |
| Pi + @e2b/pi | Pi runs on your machine while its tools run in an E2B sandbox: it builds a site, shares a public preview URL, and /e2b pull brings the files back |
- | TypeScript |
| AgentKit | AgentKit Coding Agent | - | TypeScript |
| Sandbox Agent SDK | Run Sandbox Agent inside E2B and connect with the SDK | - | TypeScript |
| OpenCode E2B workspaces | Warp a live OpenCode session from your laptop into an E2B sandbox and back | - | TypeScript |
| Stirrup | The lightweight framework for building agents | Python | - |
Reinforcement learning
- Code rewards for TRL GRPO with E2B — first code rewards without a GPU, then train on JSON-processing tasks with sandboxed Python execution.
Remote execution integrations
| Integration | Description | Python | TypeScript |
|---|---|---|---|
| Crabbox | Warm one E2B sandbox, sync local changes, and rerun a test suite on the same lease | Python | - |
Model Context Protocol (MCP)
| Example | Description | TypeScript |
|---|---|---|
| MCP Client | Basic MCP client connection to E2B sandbox | TypeScript |
| MCP Custom Server | Connect to custom filesystem MCP server from GitHub | TypeScript |
| MCP Custom Template | Create custom E2B template with pre-installed MCP servers | TypeScript |
| MCP Research Agent | Research agent using arXiv and DuckDuckGo MCP servers | TypeScript |
| MCP Claude Code | Claude Code with MCP integration | TypeScript |
| MCP Browserbase | Web automation agent using Browserbase MCP server | TypeScript |
| MCP Groq Exa (deprecated) | AI research using Groq with Exa MCP server | TypeScript |
Example use cases
- Upload dataset and analyze it with Llama 3.3 - Python
- Scrape Airbnb and analyze data with Claude Opus 5 and Firecrawl - TypeScript
- Visualize website topics with Claude Sonnet 5 and Firecrawl - Python
- Next.js app with LLM + Code Interpreter and streaming - TypeScript
- How to run a Docker container in E2B - Python/TypeScript
- Tailcat: encrypted links between sandboxes, and between a sandbox and your laptop - Python/TypeScript
- How to run Playwright in E2B - TypeScript
- Test an app running in a sandbox with a Notte cloud browser, from Playwright over CDP and from the Notte CLI inside the sandbox - Python
- Anchor cloud browser: run code in an E2B sandbox and drive Chromium in Anchor Cloud - TypeScript
- Map custom subdomains to your sandboxes - TypeScript
- Delete old paused sandboxes by age and metadata - Python/Shell
- Feedback analyst agent on Flue, publishing an HTML report from a sandbox - TypeScript
- Warm an E2B sandbox and rerun tests after adding a local regression case - Python
- Teach Hermes an incident-triage playbook and reuse it in a fresh session - Python
Running the examples as a test suite
Every example is exercised nightly against live E2B by tests/run-examples.ts: each
one is uploaded into a fresh sandbox, installed with its own toolchain (npm, uv,
Poetry, or nbconvert for notebooks) and run. An example passes if it exits 0.
npm install npm test # all of them npm test -- hello-world # substring filter, one or a few
You need an E2B_API_KEY plus whichever provider key the examples you are running
use - see .env.example. hello-world-js and hello-world-python need only the E2B
key, so they are the ones to try first.
What counts as a failure. The suite checks the sandbox, not the model. A provider rate limit or an exhausted quota counts as OK, because the sandbox still built, installed and ran; non-deterministic model behaviour - no chart produced, a malformed tool call, generated code raising inside the sandbox - is reported as skipped. Real failures are the things that are actually broken: missing templates, dependency resolution, wrong entrypoints, auth, retired model ids, sandbox timeouts.
Some examples are deliberately not covered - they need a provider key this repo does
not hold, a long-lived server the runner cannot assert on, or an upstream fix. Each
exclusion is listed with its reason at the top of tests/run-examples.ts, so a gap is
never silent.
来源:GitHub · github.com

