E2B Cookbook: AI Agent Code Interpreter Examples
Examples and guides for running code interpreters in secure E2B sandboxes with various LLM providers and frameworks.
- Source repo
- e2b-dev/e2b-cookbook
- Stars
- ★ 1.4k
- Last updated
- 7d ago
- FARS reviewed
- Nov 08, 2026
- Primary language
- TypeScript
- FA score
- 52/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformOpenAI API · Claude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- Developers who want to quickly add code interpreter capabilities to OpenAI or Anthropic models can use the Python or TypeScript examples to implement sandboxed code execution in minutes.
- Not a fit if
- Readers wanting zero-config runs; most examples need several provider API keys.
- Teams needing production-grade, well-tested code; these are demo examples with average maintenance.
- Website
- docs.e2b.dev ↗ set on GitHub
- Maintenance
- Commits in the last 30 dayslast commit 2026-11-26+0.7 ★/day over 7 days
- Source review
- 52/100 · Major gaps
What does this agent do, and when should you use it?
E2B Cookbook is a collection of example code and guides maintained by e2b-dev for building AI agents with the E2B SDK (https://github.com/e2b-dev/e2b). It includes code interpreter integrations for multiple LLM providers such as OpenAI, Anthropic, Mistral, Groq, Fireworks AI, Together AI, and WatsonX, as well as integrations with AI frameworks like LangChain, LangGraph, CrewAI, Autogen, Vercel AI SDK, and more. The repository also provides various Model Context Protocol (MCP) examples, including MCP client, custom server, research agent, and more. All examples are available in both Python and TypeScript, covering end-to-end use cases like dataset upload and analysis, website scraping and analysis, running Docker containers, and Playwright automation. This repository serves as a practical guide to quickly get started with executing AI-generated code in secure sandboxes.
The repository contains a series of runnable example programs demonstrating how to integrate E2B sandboxes as code execution environments with mainstream LLMs and AI frameworks. Each example typically follows a flow: set up an LLM client (e.g., OpenAI, Anthropic), create an E2B sandbox instance using the E2B SDK's Sandbox class, send a user request to the LLM, receive a code snippet from the LLM, execute the code in the sandbox, and return the result. For instance, in the OpenAI example, GPT-4o processes image data and executes code for reasoning; in the Claude example, Claude 3 Opus implements a code interpreter. More complex integrations include using LangChain and LangGraph for tool calling, CrewAI agents for execution, and MCP server connections. All examples provide clear instructions for installing dependencies, setting environment variables (like API keys), and running scripts.
- Developers who want to quickly add code interpreter capabilities to OpenAI or Anthropic models can use the Python or TypeScript examples to implement sandboxed code execution in minutes.
- AI engineers building agents with LangChain or LangGraph who need secure code execution can reuse the LangChain integration example from this repository.
- Data scientists wanting LLMs to run Python code directly for CSV analysis or machine learning tasks can use the OpenAI or Together AI examples as a starting point.
- Frontend developers building Next.js applications that require streaming code interpretation output can refer to the Next.js + AI SDK example.
- Agent developers needing to interact with MCP servers can learn from the MCP client and server examples to quickly implement tool calls.
- Those looking to run Playwright or Docker automation within E2B sandboxes can check the dedicated examples in this repository.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Environment variables
OPENAI_API_KEYANTHROPIC_API_KEYE2B_API_KEY
How do you install or deploy this agent?
Installation steps vary per example, but generally: 1. Clone the repository: git clone https://github.com/e2b-dev/e2b-cookbook.git; 2. Enter the example directory, e.g., cd examples/hello-world-js; 3. Install dependencies with npm install or pip install depending on the language; 4. Set environment variables such as OPENAI_API_KEY or ANTHROPIC_API_KEY, and E2B_API_KEY if running sandboxes locally.
How do you use this agent?
Before running an example, ensure the required API keys are set. For Node.js examples, run node main.js or similar; for Python examples, run python main.py. For instance, in the hello-world-js directory, run npm start or node index.js. Exact commands are specified in each example's README or code comments.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
What are this agent's strengths and limitations?
- Provides examples for a wide range of major LLM providers (OpenAI, Anthropic, Mistral, Groq, etc.), offering diverse choices.
- All examples are available in both Python and TypeScript, catering to different technology stacks.
- Includes practical end-to-end use cases such as dataset upload analysis, website scraping analysis, and Playwright automation, which can be used as starting points for projects.
- Deep integration with E2B sandboxes ensures secure and isolated code execution.
- Depends on the E2B SDK and sandbox service, which may incur additional costs or require an E2B account.
- Examples are primarily oriented towards the E2B ecosystem; migrating to other sandbox platforms requires code modifications.
- Some examples require multiple API keys (e.g., OpenAI, Anthropic, Firecrawl), increasing configuration overhead.
- No built-in tests or CI, and the maintenance level of examples is average.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| E2B Cookbook: AI Agent Code Interpreter Examples This agent | 52 · Major gaps | CLIFree + model costs | ★ 1.4k | 7d ago | TypeScript | OpenAI API · Claude API |
| Capsule Sandbox Runtime | 54 · Major gaps | CLIFree | ★ 303 | 1mo ago | Rust | — |
| Sandbox SDK | 63 · Some gaps | Library / SDKFree + model costs | ★ 122 | 1d ago | TypeScript | — |
| Daytona: Secure Elastic Infrastructure for AI Code | 45 · Major gaps | Library / SDKFreemium | ★ 71k | 4mo ago | — | — |
How does FollowAgents rate this agent?
Why each dimension lost points
The README identifies the repository as E2B SDK examples and guides and lists many providers and integrations, making some intended uses visible. The supplied material does not show permission configuration, per-example data flows, sensitive-data protections, user confirmation, or recovery for ordinary external actions, so those scores remain low. The sample tests show stopping a lease and cleaning a temporary fixture on failure, but only within a narrow example. The README links E2B documentation and some external projects, supporting a stronger attribution score. No license file or verified publisher information is supplied; publisher identity itself is not penalized.
The README describes a nightly example test suite, filtering, required keys, and the distinction between infrastructure failures and skipped model behavior. The supplied workflows also show offline checks for particular examples. Since the evidence covers only a subset of the examples, it cannot establish consistency across the collection or long-term dependency availability. Failure reporting is described mainly at the suite level, with little evidence of per-example error handling, so scores are limited.
The README organizes many Python and TypeScript examples by provider, framework, remote execution, MCP, and use case, with concrete descriptions; scenario coverage is strong. It also documents some capability boundaries through test exclusions and failure definitions. This is a collection of examples rather than one Agent with explicit trigger conditions, and environment guidance is mostly limited to setup tools and keys.
The README has a clear categorized index and links, and provides test commands, key prerequisites, failure definitions, and some exclusion reasons. The package manifest lists versions and dependencies. The supplied evidence has no license, systematic changelog, named maintenance responsibility, or complete per-example installation notes, so those criteria do not receive high scores. Example names generally convey language and topic, but the sample is insufficient to establish repository-wide naming stability.
Examples across languages, providers, and frameworks give developers useful starting points, while links and test commands help them navigate and use the collection. The use-case descriptions are concise and understandable. The supplied material does not show outputs for every example or assess cost and benefit; the test suite primarily checks sandbox build and execution rather than model output quality, so these scores are moderate.
The README gives checkable details about test commands, required keys, pass criteria, and skip conditions; sample tests and workflows corroborate a small number of cases. Most linked examples are not included in the packet, limiting cross-checks between documentation and source. The README distinguishes suite behavior from model results, supporting separation of facts and limitations, but the evidence does not justify a stronger corroboration score.
- This assessment uses only the supplied static material. Linked example files not included in the packet remain unknown and cannot be judged for safety or quality.
- The README says the test suite requires E2B_API_KEY and, for some examples, provider keys. Examples use external model and sandbox services, and the supplied material does not explain per-example data sent or operational consequences.
- The packet does not provide a license, named maintenance responsibility, or comprehensive per-example installation and recovery guidance.
FAQ
Do I need to pay to use these examples?
How do I get an E2B API key?
Can I develop locally with these examples?
If I don't want to use E2B, are these examples still useful?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.