E2B Code Interpreter
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
- breaking CodeInterpreter class removed in v1.0. All v0.x code using CodeInterpreter() or from e2b_code_interpreter import CodeInterpreter fails with ImportError.
- breaking Global cwd option removed from Sandbox constructor in v1.0. Setting cwd at sandbox creation no longer works.
- breaking Sandbox.list() output structure changed in v1.0. Code parsing the old list format breaks silently or raises KeyError.
- deprecated e2b package (core SDK) v0.x is fully deprecated. All PyPI releases below 1.0 display deprecation warnings at import time.
- gotcha Sandboxes are billed by runtime duration, not by number of calls. Long-running agents with persistent sandboxes accumulate cost even when idle.
- gotcha execution.text is None if the code produces no output. Accessing .text without checking causes NoneType errors downstream.
Install
-
pip install e2b-code-interpreter -
pip install e2b -
npm install @e2b/code-interpreter
Imports
- Sandbox
from e2b_code_interpreter import Sandbox
- Sandbox (core)
from e2b import Sandbox
Quickstart
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