SkillsApr 7, 2026·2 min read

E2B — Cloud Sandboxes for AI Code Execution

Secure cloud sandboxes that let AI agents run code, install packages, and use the filesystem. Spin up in 150ms. Used by Vercel, Langchain, and CrewAI.

SK
Skill Factory · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

npm install @e2b/code-interpreter
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()
const result = await sandbox.runCode('print(1 + 1)')
console.log(result.text) // "2"
await sandbox.kill()

What is E2B?

E2B provides secure, isolated cloud sandboxes for AI agents to execute code. Each sandbox is a micro-VM that spins up in ~150ms with a full Linux environment — perfect for code interpreters, data analysis agents, and AI-generated code execution.

Answer-Ready: E2B provides secure cloud sandboxes (micro-VMs) that spin up in 150ms for AI agents to execute code, install packages, and access filesystems safely.

Core Features

1. Code Interpreter SDK

from e2b_code_interpreter import Sandbox

sandbox = Sandbox()

# Run Python with automatic package installation
execution = sandbox.run_code(
    "import pandas as pd\\n"
    "import matplotlib.pyplot as plt\\n"
    "df = pd.DataFrame({\'x\': [1,2,3], \'y\': [4,5,6]})\\n"
    "df.plot()\\n"
    "plt.savefig(\'chart.png\')\\n"
    "print(df.describe())"
)

print(execution.text)      # stdout
print(execution.results)   # rich outputs (charts, tables)

2. Custom Sandbox Templates

# e2b.Dockerfile
FROM e2b/base
RUN pip install numpy pandas scikit-learn
RUN npm install -g typescript
e2b template build --name "data-science"

3. Filesystem Access

# Upload files
sandbox.files.write("/home/user/data.csv", csv_content)

# Download results
content = sandbox.files.read("/home/user/output.json")

# List files
files = sandbox.files.list("/home/user/")

4. Long-Running Sandboxes

# Keep alive for up to 24 hours
sandbox = Sandbox(timeout=3600)  # 1 hour

# Pause and resume
sandbox_id = sandbox.pause()
# ... later ...
sandbox = Sandbox.resume(sandbox_id)

5. Framework Integrations

# OpenAI Assistants
from e2b_code_interpreter import Sandbox
# Use as code_interpreter tool handler

# Vercel AI SDK
# Built-in e2b sandbox support

# LangChain
from langchain_e2b import E2BCodeInterpreterTool

Use Cases

Use Case Example
Code Interpreter ChatGPT-like code execution
Data Analysis Run pandas/matplotlib in sandbox
CI/CD Test AI-generated code safely
Education Student code execution

FAQ

Q: How secure are the sandboxes? A: Each sandbox is an isolated Firecracker micro-VM with no network access to other sandboxes.

Q: Pricing? A: Free tier with 100 sandbox hours/month. Pay-as-you-go after that.

Q: Supported languages? A: Any language that runs on Linux — Python, Node.js, Go, Rust, etc.

🙏

Source & Thanks

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets