Dev & Engineering code-interpretersandboxtypescriptpythonllm-integrationmcps

E2B Cookbook: AI Agent Code Interpreter Examples

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

FollowAgents review · FARS-2.1
Not recommended
36/ 100 5-point scale 1.8 / 5
1 2 3 4 5 6
1Trust6 / 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.

2Reliability6 / 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.

3Adaptability9 / 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.

4Convention5 / 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.

5Effectiveness7 / 13 · 2.7/5

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

6Verifiability3 / 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.

Evidence confidence: Low Reviewed Aug 09, 2026 Reviewed revision 7d5ea3bbd810
The upstream repository has new commits since this review. The score still applies to the reviewed revision shown and may not cover the latest changes.
Safety controls not found in source: confirmation before acting, dependency security, rollback or recovery path
Before you use it
  • 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.
Review evidence [1][2][3][4][5][6]
See the full review method →

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.

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 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.

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.

Related agents