Skip to content

Latest commit

 

History

History

README.md

layout default
title E2B Tutorial
nav_order 200
has_children true
format_version v2

E2B Tutorial: Secure Cloud Sandboxes for AI Agent Code Execution

Learn how to use e2b-dev/E2B to give AI agents secure, sandboxed cloud environments for code execution with sub-200ms cold starts.

GitHub Repo License Docs

Why This Track Matters

When AI agents generate code, they need a safe place to run it. Local execution is dangerous --- an agent can delete files, exfiltrate data, or crash the host. E2B solves this by providing on-demand cloud sandboxes that spin up in under 200ms, run arbitrary code in full isolation, and tear down automatically.

This track focuses on:

  • spinning up sandboxes and executing code securely from Python and TypeScript
  • understanding the Firecracker microVM architecture that powers E2B
  • managing filesystems, processes, and network access inside sandboxes
  • building custom sandbox templates with pre-installed dependencies
  • integrating E2B with LangChain, CrewAI, and other agent frameworks
  • handling streaming output and real-time execution feedback
  • operating E2B at scale in production AI applications

Current Snapshot (auto-updated)

Mental Model

flowchart LR
    A[AI Agent generates code] --> B[E2B SDK call]
    B --> C[Sandbox spins up <200ms]
    C --> D[Code executes in Firecracker microVM]
    D --> E[Results stream back to agent]
    E --> F[Sandbox auto-teardown]
    F --> G[Agent reasons on output]
Loading

Chapter Guide

Chapter Key Question Outcome
01 - Getting Started How do I spin up my first sandbox and run code? Working baseline with Python and TypeScript SDKs
02 - Sandbox Architecture How does E2B achieve sub-200ms cold starts securely? Strong mental model of Firecracker microVM isolation
03 - Code Execution How do I run code, handle errors, and capture output? Reliable execution patterns for any language
04 - Filesystem and Process Management How do I read/write files and manage processes inside sandboxes? Full control over sandbox state
05 - Custom Sandbox Templates How do I pre-install dependencies and tools? Faster startup with custom environments
06 - Framework Integrations How do I connect E2B to LangChain, CrewAI, and other frameworks? Agent framework code execution
07 - Streaming and Real-time Output How do I get live output from long-running executions? Real-time feedback loops
08 - Production and Scaling How do I run E2B reliably at scale? Production-grade deployment patterns

What You Will Learn

  • how to give AI agents secure code execution without risking your infrastructure
  • how Firecracker microVMs provide true isolation with near-instant startup
  • how to build custom sandbox templates for specialized workloads
  • how to integrate E2B with popular agent frameworks
  • how to stream execution output for interactive experiences
  • how to operate sandboxes at scale with proper lifecycle management

Source References

Related Tutorials


Start with Chapter 1: Getting Started.

Navigation & Backlinks

Full Chapter Map

  1. Chapter 1: Getting Started
  2. Chapter 2: Sandbox Architecture
  3. Chapter 3: Code Execution
  4. Chapter 4: Filesystem and Process Management
  5. Chapter 5: Custom Sandbox Templates
  6. Chapter 6: Framework Integrations
  7. Chapter 7: Streaming and Real-time Output
  8. Chapter 8: Production and Scaling

Generated by AI Codebase Knowledge Builder