OpenAI Agents SDK
Run OpenAI Agents SDK sandbox agents in E2B. The SDK's built-in E2BSandboxClient gives each SandboxAgent a filesystem, terminal and network in an isolated sandbox.
- OpenAI
- Built into openai-agents
- openai-agents[e2b]
- Python
Get started
Paste the prompt into your coding agent, or follow the steps yourself.
Paste this into your coding agent
Add E2B sandboxes to this OpenAI Agents SDK project.
- 1.Install the Agents SDK with the e2b extra ("openai-agents[e2b]") using the project's package manager.
- 2.The sandbox client needs the E2B_API_KEY environment variable. If it isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode it.
- 3.Follow the OpenAI Agents SDK guide at https://docs.e2b.dev/agents/openai-agents-sdk. Create a session with E2BSandboxClient, run a SandboxAgent against it through RunConfig(sandbox=SandboxRunConfig(session=session)), and shut the session down in a finally block.
- 4.Run the agent once and show me the output that came from the sandbox.
Or set it up yourself
1. Install the SDK with the E2B extra
2. Set your API keys
3. Create a sandbox session
4. Run a SandboxAgent in it
What runs in the sandbox
Each SandboxAgent works in its own isolated sandbox, away from the machine running the SDK.
- Commands, file reads and writes the SandboxAgent makes, executed in the E2B session.
- Seed the sandbox with a Manifest of starter files, and expose ports to get live preview URLs.
- timeout bounds the session. pause_on_exit=True keeps the sandbox for inspection; session.shutdown() releases it.
- Pass MCP server configs when you create the session, and the agent reaches them through the sandbox's MCP gateway.
More agent frameworks
Other frameworks that run their tools on E2B.
- Vercel AI SDKGive Vercel AI SDK agents sandbox tools with @e2b/ai-sdk-sandbox. Experimental for AI SDK 7.
- CrewAIGive CrewAI agents E2B tools for shell commands, Python, and files with the crewai-tools[e2b] extra.
- Pydantic AIRun Pydantic AI agent tools in E2B through the pydantic-ai-harness E2B sandbox.
