--- id: e2b-code-interpreter version: "2.9.1" license: MIT license_treatment: permissive maintenance: active --- # e2b-code-interpreter — E2B Code Interpreter - Stateful code execution License: permissive · Maintenance: active · Downloads: 2.6M/mo ## 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 above — 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 pip install e2b-code-interpreter uv add e2b-code-interpreter poetry add e2b-code-interpreter ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 2.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags execute code in sandbox, isolated code execution, ai code interpreter, stateful code runner, secure code execution cloud, python sandbox environment, llm code execution, code-execution, ai-safety, sandbox [View on SkillFed](https://skillfed.io/packages/e2b-code-interpreter) · [View on PyPI](https://pypi.org/project/e2b-code-interpreter/)