opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Run AI-generated code in secure isolated cloud sandboxes
GitHub RepoImpressions3

Project Description

View on GitHub

Running AI-Generated Code Without Losing Sleep Over It

If you've ever wired an LLM up to a code execution tool, you know the feeling. The model writes something clever, you run it, and then you spend the next ten minutes wondering whether it just touched your filesystem, made a network call, or worse. You want the capability without the anxiety. E2B's Code Interpreter is an open-source infrastructure project that lets you run AI-generated code inside secure, isolated sandboxes in the cloud.

What It Does

At its core, E2B provides sandboxes—disposable, isolated cloud environments where code can execute safely, separate from your own machine and infrastructure. You spin one up programmatically, send it code, and get back results. The project ships SDKs for both JavaScript/TypeScript and Python, so you can control sandboxes from whichever language your application already uses.

The Code Interpreter piece is what makes this more than just a generic sandbox. It's built for the kind of interactive, stateful execution that AI agents tend to need: you can run a snippet, keep variables alive between calls, and read the output. The README's own example is about as minimal as it gets—set x = 1, then run x += 1; x and get 2 back. That persistence matters, because it means an agent can build up state across multiple turns instead of starting from scratch every time.

A quick note on the repo itself: the @e2b/code-interpreter and e2b-code-interpreter SDK sources have moved into the E2B monorepo under packages/code-interpreter-js and packages/code-interpreter-python. This repository now keeps the sandbox template and a chart data extractor, so if you're filing SDK issues, that's where they belong.

Why It's Cool

  • The isolation is the whole point. You're not running untrusted code on your own box and hoping for the best. Each sandbox is a separate cloud environment, which is exactly the right mental model when the code being executed was written by a model you don't fully control.

  • Stateful execution, not one-shot scripts. A lot of code execution tools treat each run as a fresh start. E2B keeps the session alive, so variables carry over. For agent workflows—where the model reasons step by step—that's the difference between a useful tool and a frustrating one.

  • Two SDKs, same idea. Whether you're building in TypeScript or Python, the API surface is basically the same shape: create a sandbox, run code, read the output. That symmetry saves you from relearning concepts when you switch stacks.

  • You can bring your own template. The README points to a template guide for building custom Code Interpreter sandbox templates—useful when you need extra packages or a different runtime than the default code-interpreter-v1 provides. That's the escape hatch that keeps the tool from being a black box.

  • There's a cookbook. The E2B Cookbook collects examples with different LLMs and AI frameworks, which is a practical place to look when you're past the hello-world stage and wondering how other people actually wire this stuff up.

How to Try It

Getting started takes about five minutes.

  1. Install the SDK for your language:
npm i @e2b/code-interpreter

or

pip install e2b-code-interpreter
  1. Sign up at E2B and grab an API key from the dashboard. Set it as an environment variable:
E2B_API_KEY=e2b_***
  1. Run some code. In TypeScript:
import { Sandbox } from '@e2b/code-interpreter'

const sbx = await Sandbox.create()
await sbx.runCode('x = 1')

const execution = await sbx.runCode('x+=1; x')
console.log(execution.text)  // outputs 2

Or in Python:

from e2b_code_interpreter import Sandbox

with Sandbox.create() as sandbox:
    sandbox.run_code("x = 1")
    execution = sandbox.run_code("x+=1; x")
    print(execution.text)  # outputs 2
  1. When you need more than the defaults, follow the template guide in the repo to build a custom sandbox with your own packages and runtime.

The full source is at github.com/e2b-dev/code-interpreter, and the docs live at docs.e2b.dev.

Final Thoughts

E2B isn't trying to be everything—it's solving a specific, increasingly common problem: how do you safely execute code that a language model produced? If you're building agents, code assistants, or anything where generated code needs to actually run, this is a sensible foundation, and the stateful execution model plus the ability to customize templates gives you room to grow. It's best suited to developers who already have an LLM pipeline and need a trustworthy place to put its output. The README is refreshingly short and to the point, which is usually a good sign—the team would rather you read the docs and the cookbook than wade through marketing copy.


Follow @githubprojects for more developer tools and open source projects.

Back to Projects
Project ID: 067c590e-c90e-4eb9-ac6f-613c5662f89cLast updated: September 15, 2026 at 04:13 AM