E2B

Python SDK for spinning up secure, isolated cloud sandboxes where AI agents can safely run code.

SDK
PyPI
v2.49.1
13,798stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity100
Maintenance100
Community64
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture85
Code Quality85
Innovation88
Learning Curve80

e2b is the official Python SDK for E2B, an open-source infrastructure for running AI-generated code in secure, isolated cloud sandboxes. It gives agents and AI applications short- or long-lived Linux environments with filesystem access, command execution, PTY support, and outbound networking - the same tools a human developer would use, safely walled off from the host infrastructure.

Beyond spinning up a bare sandbox, the SDK exposes Volumes for persistent storage across sandbox lifecycles, Templates for building and versioning custom sandbox images, and Secrets for injecting credentials without hardcoding them. Every resource class ships in matching sync and async variants, and a newer E2B client class lets callers bind distinct API keys or domains to isolated client instances instead of relying on a single set of environment variables.

What You Get

  • A Sandbox class (plus AsyncSandbox) for creating, listing, and killing cloud sandboxes with configurable timeouts.
  • Filesystem, command, and PTY modules (sandbox.files, sandbox.commands, sandbox.pty) for interacting with the running environment.
  • Template/AsyncTemplate classes for building custom, versioned sandbox images with configurable ready-checks.
  • Volume/AsyncVolume classes for durable storage attached to sandboxes.
  • Secret/AsyncSecret classes for injecting credentials into sandboxes without hardcoding them.
  • An E2B client class for binding explicit API keys or domains instead of relying on process-wide environment variables.

Common Use Cases

  • Running AI-agent-generated code safely, isolated from the host machine.
  • Powering code-interpreter features in AI chat products (pairs with the separate e2b-code-interpreter package).
  • Building reproducible, versioned sandbox templates for repeatable agent tasks.
  • Isolating multiple tenants or API keys within a single backend process via the E2B client.

Under The Hood

Architecture The package structures around a central SandboxApi base class extended by separate sync (sandbox_sync/main.py) and async (sandbox_async/main.py) sandbox implementations that share common configuration and exception layers (connection_config.py, exceptions.py); parallel module trees for filesystem, commands, pty, and git operations under sandbox_sync/ and sandbox_async/ mirror each other to keep the sync and async APIs at parity. A generated OpenAPI client (api/client_sync, api/client_async) plus a separate envd/ layer (wrapping the sandbox’s in-VM daemon over Connect-RPC) form two distinct communication tiers - control-plane calls to the E2B API and RPC calls into the running sandbox. The newer E2B client class (client.py) binds explicit ApiParams into per-client bound subclasses of Sandbox, Volume, Template, and Secret via a dynamic type() call, allowing multiple isolated client instances instead of a single environment-variable-configured global. Changing the core ConnectionConfig/ApiParams abstraction would ripple through every resource module since all of them inherit connection and auth handling from it.

Tech Stack Built for Python 3.10+ using the uv_build backend. Runtime dependencies include httpx (with HTTP/2 via h2) for REST calls to the E2B control plane, connectrpc and protobuf-py for RPC calls into the sandbox’s envd daemon, attrs for typed data classes, packaging for version comparisons, dockerfile-parse for template Dockerfile parsing, rich for terminal output, and wcmatch for filesystem-watch globbing. Dev tooling covers pytest with pytest-xdist, pytest-asyncio, pytest-dotenv, and pytest-timeout for the test suite, ruff for linting and formatting, and ty (Astral’s type checker) for static typing. A dedicated codegen dependency group regenerates the OpenAPI and Connect-RPC clients from the platform’s shared API spec, keeping the generated layer in sync with the service.

Code Quality The test suite splits into sync/, async/, and shared/ fixture directories with dedicated files per concern - transport, codec, interceptors, retries, and timeout behavior of the envd RPC layer each get their own test file, alongside coverage for connection config, API keys, and the new E2B client binding. A dedicated GitHub Actions workflow runs the suite on every change. Exceptions are typed and hierarchical, all deriving from SandboxException rather than bare Exception raises, and public classes and methods carry docstrings including explicit deprecation notices where relevant (e.g. the legacy Sandbox() constructor).

API Design The entrypoint is deliberately minimal: from e2b import Sandbox; with Sandbox.create() as sandbox: sandbox.commands.run(...), using a context manager for automatic cleanup. Sync and async APIs are near-identical in shape (AsyncSandbox mirrors Sandbox method-for-method), and naming stays consistent across resources (Sandbox/AsyncSandbox, Volume/AsyncVolume, Template/AsyncTemplate, Secret/AsyncSecret). The newer E2B client class addresses a concrete pain point - needing several API keys or domains active in one process - without disturbing the simpler top-level, environment-variable-configured exports most users start with.

Used by 12 apps in this directory

Python
67%
Other

AutoGPT

Automation · Productivity · AI Assistants

187,344

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python67%
TypeScript32%
Updated 2 days ago
Swift
64%
GPL 3.0

cmux

Developer Tools · AI Development

27,100

A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.

View details
84
Repo Health
81
Technical
69
Dependency
Built with
Swift64%
Rust14%
Updated 2 days ago
Go
33%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

12,344

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go33%
Rust26%
C23%
Updated 3 days ago
Go
75%
MIT

Digger

Devops · Automation · Developer Tools

5,045

Run Terraform and OpenTofu natively inside your existing CI pipeline — no separate runners, no third-party secrets, no extra compute costs.

View details
74
Repo Health
73
Technical
67
Dependency
Built with
Go75%
TypeScript15%
Updated 4 days ago
TypeScript
96%
AGPL 3.0

Libra AI

AI Development · No Code Platforms

1,683

Open-source AI-powered platform that generates and deploys full-stack web applications from natural language prompts, built natively for Cloudflare Workers.

View details
31
Repo Health
71
Technical
68
Dependency
Built with
TypeScript96%
Updated 11 months ago
TypeScript
96%
Other

Lightdash

Analytics · Data Engineering

6,136

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript96%
Updated 2 days ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

28,044

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
88
Repo Health
73
Technical
65
Dependency
Built with
TypeScript99%
Updated 2 days ago
TypeScript
88%
MIT

Mistle

AI Agents · Developer Tools

91

Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.

View details
69
Repo Health
76
Technical
70
Dependency
Built with
TypeScript88%
Rust11%
Updated 2 months ago
TypeScript
97%
Other

nango

Developer Tools · Automation · Authentication

12,079

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
94
Repo Health
85
Technical
68
Dependency
Built with
TypeScript97%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search