Vercel AI SDK
Run AI SDK tools and harness agents in an isolated sandbox. @e2b/ai-sdk-sandbox implements the AI SDK 7 sandbox interface, so commands and file writes happen in E2B, not on your server.
- E2B
- AI SDK 7 sandbox provider
- @e2b/ai-sdk-sandbox
- TypeScript
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 Vercel AI SDK project.
- 1.Install @e2b/ai-sdk-sandbox using the project's package manager. It targets AI SDK 7.
- 2.The provider 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 Vercel AI SDK guide at https://docs.e2b.dev/agents/vercel-ai-sdk. Create a session with createE2BSandbox(), give my tools session.restricted() so they can run commands but not destroy the sandbox, and call session.destroy() when done.
- 4.Run one generation and show me the output that came from the sandbox.
Or set it up yourself
1. Install the provider
2. Set your API keys
3. Create a sandbox session
4. Hand the sandbox to a tool
What runs in the sandbox
Commands and file operations your tools run happen in an isolated sandbox, away from your server.
- Shell commands and file reads and writes from your AI SDK tools, or a whole harness agent like Claude Code or Codex.
- Tools get session.restricted(): file I/O, run and spawn, without stop, destroy or network controls.
- 30 minutes by default; set timeoutMs. stop() pauses the sandbox so it can resume, destroy() removes it.
- Tighten outbound access with setNetworkPolicy, available only on the full session your app keeps.
More agent frameworks
Other frameworks that run their tools on E2B.
