- Universal Agent API - A single interface to manage Claude Code, Codex, OpenCode, Cursor, Amp, and Pi with full feature coverage across every supported agent.
- Universal Session Schema - A standardized schema that normalizes all agent event formats into a consistent structure for storage and replay.
- Server or SDK Mode - Run as a standalone HTTP server or integrate natively using the TypeScript SDK.
Workflow overview
- A local Node.js script starts an E2B sandbox and boots the Sandbox Agent server inside it.
- The script opens a session, sends a prompt to an agent (Claude in this example), and prints the response.
- When the script exits, the sandbox is destroyed.
Prerequisites
E2B_API_KEY— get your key from the E2B Dashboard- At least one provider key:
OPENAI_API_KEY,CODEX_API_KEY, orANTHROPIC_API_KEY
Setup
Install the Sandbox Agent SDK and its dependencies. dotenv loads environment variables from your.env file, and tsx lets you run TypeScript directly without a build step.
.env file with your API keys:
.env
Run headless
Create anindex.ts file and follow the steps below to build a script that boots an agent inside an E2B sandbox, sends a prompt, and streams the response.
Forward provider credentials
Load your environment variables and collect the provider API keys that need to be forwarded into the sandbox so the agent can authenticate with the LLM provider.
Start Sandbox Agent
Initialize the SDK with the E2B provider. This creates a sandbox and boots the Sandbox Agent server inside it. The inspector UI lets you view sessions, events, and agent state in real time.
Send a prompt and stream events
Create a session targeting a specific agent (Claude in this example), send a prompt, and stream the resulting events. Read more about Sessions and Events.To use a different agent, update the
agent value in createSession (for example, codex) and ensure the corresponding provider credentials are available in the environment.Full file preview
Full example
See the complete project in the e2b-cookbook repo.Related guides
Sandbox persistence
Auto-pause, resume, and manage sandbox lifecycle
Git integration
Clone repos, manage branches, and push changes
SSH access
Connect to the sandbox via SSH for interactive sessions