E2B Documentation — Secure Sandboxes for AI Agents
by E2B
Somewhere safe for your agent's generated code to actually run.
Overview
E2B is open-source infrastructure (Apache-2.0, 13.5k-plus GitHub stars, 1k forks) for running AI-generated code in isolated cloud sandboxes, which the docs describe as "a fast, secure Linux VM created on demand for your agent". The documentation is organised into Quickstart, Examples and an SDK Reference. Quickstart walks through running your first sandbox, connecting LLMs to E2B, uploading and downloading files, and installing custom packages; Examples covers deeper use cases; the SDK Reference documents the Python and JavaScript/TypeScript clients. Two concepts carry most of the mental model: a Sandbox is the running VM, and a Template defines the environment it boots from, so dependencies are baked in once rather than installed on every run. Lifecycle is explicit and worth reading before you design around it — sandboxes run until their timeout expires, then pause while preserving full state so you can resume at any time; set_timeout in Python or setTimeout in JavaScript extends the window from the moment it is called rather than from creation, get_info and getInfo return the sandbox ID, template, metadata and start and end timestamps, and kill terminates immediately. Maximum session length is one hour on the free Hobby tier and 24 hours on Pro, with pause and resume the documented route for anything longer. Concurrency caps are 20 sandboxes on Hobby and 100 on Pro, expandable to 1,100. Hobby is free with a one-time $100 usage credit and no card required; Pro is $150 a month plus metered CPU at $0.000014 to $0.000112 per second depending on vCPU count, RAM at $0.0000045 per GiB-second, and storage above the 10 GiB (Hobby) or 20 GiB (Pro) allowance. A separate Code Interpreter SDK adds stateful code evaluation, and self-hosting is documented through Terraform deployments on AWS and Google Cloud.
At a Glance
- Topic
- Agentic
- Level
- Intermediate
- Format
- Documentation
- Cost
- Freemium
- Duration
- ~1-2 hours to a first working sandbox; about a day to build a custom template
- Provider
- E2B
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Create, pause, resume and kill a sandbox from Python or TypeScript
- ✓Wire an LLM tool call through to code execution inside a sandbox
- ✓Build a custom template so dependencies are preloaded at boot
- ✓Upload and download files between your app and the sandbox filesystem
- ✓Extend a running sandbox's timeout and inspect its metadata
- ✓Estimate cost from per-second CPU, RAM and storage metering
- ✓Self-host E2B on AWS or Google Cloud using the published Terraform modules
Highlights
- •Pause and resume preserves full VM state, so long jobs are not capped by session limits
- •Templates make cold starts predictable instead of pip-installing on every single run
- •Self-hostable via Terraform, which is rare for a sandbox-as-a-service product
- •A one-time $100 free credit is enough to prototype without a credit card
- •Widely used as the reference implementation that newer agent-sandbox projects benchmark against
Who It’s For
Best For
- ✓Engineers building agents that write and then execute their own code
- ✓Teams adding a data-analysis or code-interpreter feature to a product
- ✓Anyone who needs untrusted model output isolated from production systems
- ✓Platform teams comparing hosted sandboxes against self-hosted alternatives
Prerequisites
- •A working Python or Node.js project and an E2B API key
- •Basic Linux command line and package management familiarity
- •Terraform and cloud IAM knowledge, but only for the self-hosting path
FAQ
What is E2B Documentation — Secure Sandboxes for AI Agents?
Documentation for E2B, the Apache-2.0 platform that gives AI agents isolated Linux VMs in which to execute generated code, process files and run tools. It covers the Python and JavaScript/TypeScript SDKs, sandbox lifecycle including timeouts and pause-resume persistence, custom templates that define the starting environment, connecting an LLM to a sandbox, file transfer, package installation, and self-hosting via Terraform.
Is E2B Documentation — Secure Sandboxes for AI Agents free?
E2B Documentation — Secure Sandboxes for AI Agents offers free content, with paid options for certificates or premium features.
What level is E2B Documentation — Secure Sandboxes for AI Agents for?
E2B Documentation — Secure Sandboxes for AI Agents is aimed at a intermediate audience. Recommended background: A working Python or Node.js project and an E2B API key, Basic Linux command line and package management familiarity, Terraform and cloud IAM knowledge, but only for the self-hosting path.
How long does E2B Documentation — Secure Sandboxes for AI Agents take?
Expect roughly ~1-2 hours to a first working sandbox; about a day to build a custom template. Most learners work through it at their own pace.
What will I learn from E2B Documentation — Secure Sandboxes for AI Agents?
You'll learn: Create, pause, resume and kill a sandbox from Python or TypeScript; Wire an LLM tool call through to code execution inside a sandbox; Build a custom template so dependencies are preloaded at boot; Upload and download files between your app and the sandbox filesystem; Extend a running sandbox's timeout and inspect its metadata; Estimate cost from per-second CPU, RAM and storage metering; Self-host E2B on AWS or Google Cloud using the published Terraform modules.
Topics
Sources
This page was written from 4 sources, 2 on domains other than docs.e2b.dev.