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
3d ago
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.

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.

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.

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 36 · Major gaps CLIFree + model costs ★ 1.4k 3d ago TypeScript OpenAI API · Claude API
Daytona: Secure Elastic Infrastructure for AI Code 44 · Major gaps Library / SDKFreemium ★ 72k 3mo ago — —
Build Your Own OpenClaw 21 · Major gaps CLIFree + model costs ★ 1.9k 3mo ago Python —
Claude Code From Scratch 60 · Some gaps CLIFree + model costs ★ 2.8k 3mo ago Python OpenAI API · Claude API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
36/ 100 5-point scale 1.8 / 5
Trust 6/29
Reliability 6/14
Adaptability 9/18
Convention 5/18
Effectiveness 7/13
Verifiability 3/8
Why each dimension lost points
Trust6 / 29 · 1.0/5

Evidence shows: example code uses environment variables for API keys, no hardcoding; tests simulate missing key errors; CrewAI example isolates credential storage path in tests. However, no user confirmation mechanism, data flow transparency, sensitive data handling policy, dependency security audit, rollback mechanism, or clear source attribution found. Deductions: lack of user confirmation, data flow transparency, sensitive data handling, dependency security, rollback, and source attribution.

Reliability6 / 14 · 2.1/5

Evidence shows: README and test file structure are consistent, test scripts cover multiple examples, but no detailed failure messages provided. Deductions: dependency availability not explicit, failure messages only record exit codes without user-friendly error descriptions.

Adaptability9 / 18 · 2.5/5

Evidence shows: README lists examples for various LLM providers and frameworks, covering different scenarios; but capability boundaries and trigger conditions not clearly defined. Deductions: capability boundaries and trigger precision not explicitly stated.

Convention5 / 18 · 1.4/5

Evidence shows: README provides clear example index and installation instructions, but lacks license, changelog, known limitations, and maintenance responsibility. Deductions: license, changelog, known limitations, and maintenance responsibility missing.

Effectiveness7 / 13 · 2.7/5

Evidence shows: example code is runnable and provides practical value; but no cost-benefit analysis. Deductions: cost-benefit not assessed.

Verifiability3 / 8 · 1.9/5

Evidence shows: README claims align with example code, but no external verification or separation of facts and inferences. Deductions: lack of external corroboration and fact-inference separation.

Risks and how to mitigate them
  • Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
  • Not found in source: dependency securityPin versions and run a dependency audit (npm audit, pip-audit) before installing; prefer running it in a container.
  • Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
  • The repository does not provide license information; confirm licensing terms before use.
  • Example code relies on external API keys; ensure secure storage to avoid leakage.
  • Test scripts create and destroy sandboxes, which may incur costs; monitor usage.
Evidence confidence: Low Reviewed Aug 09, 2026 Reviewed revision 7d5ea3bbd810 New commits since this review; the score may not cover them
See the full review method →

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.
View on GitHub ↗ Install ↓

Related agents