E2B Code Interpreter

2.4.1 · active · verified Sun Mar 01

Secure cloud sandboxes for executing AI-generated code. Two packages: e2b-code-interpreter (Jupyter/stateful code execution) and e2b (core sandbox SDK). v0.x is fully deprecated — all versions below 1.0 show deprecation warnings and the API is incompatible with v1.x.

Warnings

Install

Imports

Quickstart

Stateful code execution in a secure cloud sandbox. Requires E2B_API_KEY environment variable.

from e2b_code_interpreter import Sandbox

with Sandbox() as sandbox:
    sandbox.run_code("x = 1")
    execution = sandbox.run_code("x += 1; x")
    print(execution.text)  # outputs 2

view raw JSON →