e2b-code-interpreter
E2B Code Interpreter - Stateful code execution
What it is and what it does
E2B Code Interpreter is a Python SDK that provisions and controls isolated, stateful code execution environments in E2B's cloud infrastructure. It lets you run Python code—typically generated by LLMs or user input—in a sandbox where each execution preserves state from previous runs, so variables and imports persist across calls. You authenticate with an API key, create a sandbox context, and call run_code() to execute snippets; the sandbox returns execution results including stdout and any errors.
The package is designed for AI workflows where you need to safely execute untrusted or dynamically generated code without risking your local system. It abstracts away sandbox provisioning and lifecycle management, exposing a simple context-manager interface. The underlying e2b dependency handles the cloud communication; httpx manages HTTP requests and attrs provides data structures.
Use it for:
- Execute LLM-generated Python code safely in an AI agent or chatbot without running it locally.
- Build interactive notebooks or REPLs where code state persists across user inputs in a cloud sandbox.
- Test or validate user-submitted scripts in a secure, isolated environment before review.
- Run data analysis or math code from untrusted sources without exposing your system.
- Prototype multi-step workflows where intermediate results must carry over between code blocks.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Runs AI-generated or arbitrary Python code in isolated cloud sandboxes with state preservation across multiple executions.
Yes, if you need to execute untrusted or AI-generated code safely. The package is actively maintained, has low install friction, uses a permissive license, and provides a clean API for a real security need. Requires an E2B account and API key, and incurs cloud costs; verify pricing and resource limits before committing to production use.
Install
e2b-code-interpreter on PyPI
pip
pip install e2b-code-interpreteruv
uv add e2b-code-interpreterpoetry
poetry add e2b-code-interpreterInstalling e2b-code-interpreter
Before you install
Low friction install with a pure Python wheel. Active maintenance—last commit 2026-08-13, released 1 day ago. Supports Python 3.10 through 3.13. Depends on three lightweight runtime packages: httpx, attrs, and e2b.
License in practice
MIT license (permissive). You can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.
Quickstart
pip install e2b-code-interpreter
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)
Requires a valid E2B API key set as the E2B_API_KEY environment variable; sign up at e2b.dev to obtain one.
Verify before relying
- Pricing model and cost per sandbox execution or compute time.
- Sandbox resource limits (memory, CPU, execution timeout).
- Supported Python versions inside the sandbox vs. the host interpreter.
- Data residency and compliance certifications for the cloud infrastructure.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — httpx, attrs, e2b |
| Maintenance | actively maintained — 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,640,566/month — #2,963 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: e2b_code_interpreter-2.9.1-py3-none-any.whl
Tags
More Distributed Computing packages
gRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
smart-openProvides a unified, open()-compatible Python…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
e2bE2B provides a Python SDK to create and control…
permissive · top 5,000 on PyPI
e2b-desktopProvides a Python SDK to create and control…
permissive · top 15,000 on PyPI
llm-sandboxExecutes code generated by large language…
unclear · top 15,000 on PyPI
hyperlight-sandboxHyperlight-sandbox provides a Python API for…
permissive · top 15,000 on PyPI
opensandboxOpenSandbox SDK provides low-level Python…
permissive · top 15,000 on PyPI
daytonaDaytona is a Python SDK for managing and…
permissive · top 5,000 on PyPI
prime-sandboxesPython SDK for creating, managing, and…
permissive · top 15,000 on PyPI
koyeb-sdkOfficial Python SDK for Koyeb that provides…
permissive · top 15,000 on PyPI
pydantic-monty-runtimeProvides the `monty` command-line binary, a…
permissive · top 15,000 on PyPI
lightning-sdkPython SDK to create, manage, and automate…
permissive · top 15,000 on PyPI