E2B Cookbook: AI Agent Code Interpreter Examples

Examples and guides for running code interpreters in secure E2B sandboxes with various LLM providers and frameworks.

Stars
★ 1.4k
Last updated
7d ago
FARS reviewed
Nov 08, 2026
Primary language
TypeScript

At a glance

How it runs
CLILibrary / SDK
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
Node.jsPythonShell / CLINetwork accessLocal filesystem
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

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.

  1. 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.
  2. AI engineers building agents with LangChain or LangGraph who need secure code execution can reuse the LangChain integration example from this repository.
  3. 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.
  4. Frontend developers building Next.js applications that require streaming code interpretation output can refer to the Next.js + AI SDK example.
  5. Agent developers needing to interact with MCP servers can learn from the MCP client and server examples to quickly implement tool calls.
  6. 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_KEY ANTHROPIC_API_KEY E2B_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)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

What are this agent's strengths and limitations?

Pros
  • 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.
Limitations
  • 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?

FollowAgents source review · FARS-2.1
Major gaps
52/ 100 5-point scale 2.6 / 5
Trust 12/29
Reliability 5/14
Adaptability 12/18
Convention 10/18
Effectiveness 9/13
Verifiability 4/8
Why each dimension lost points
Trust12 / 29 · 2.1/5

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.

Reliability5 / 14 · 1.8/5

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.

Adaptability12 / 18 · 3.3/5

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.

Convention10 / 18 · 2.8/5

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.

Effectiveness9 / 13 · 3.5/5

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.

Verifiability4 / 8 · 2.5/5

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.

Risks and how to mitigate them
  • 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.
Evidence confidence: Low Reviewed Nov 08, 2026 Reviewed revision 7e450fdcaa3f New commits since this review; the score may not cover them
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/e2b-cookbook.svg)](https://followagents.com/en/agents/e2b-cookbook)
<a href="https://followagents.com/en/agents/e2b-cookbook"><img src="https://followagents.com/badge/e2b-cookbook.svg" alt="FARS review"></a>

FAQ

Do I need to pay to use these examples?
E2B offers a free tier for sandbox usage, but large-scale usage may incur costs. LLM API calls will also generate charges.
How do I get an E2B API key?
Sign up at e2b.dev, obtain your API key from the dashboard, and set it in the environment variable E2B_API_KEY.
Can I develop locally with these examples?
Yes, examples can be run locally, but you need to install Node.js or Python and configure the necessary API keys.
If I don't want to use E2B, are these examples still useful?
The code logic (e.g., LLM calls) may still be a reference, but the sandbox part depends on E2B, which would need to be replaced with another execution environment.
Was this page helpful?
View on GitHub ↗ Install ↓

Related concepts