CrewAI
Give CrewAI agents an isolated sandbox for running Python. The native E2BPythonTool runs the code your agents write in E2B, not on your machine.
- CrewAI
- Built into crewai-tools
- crewai-tools[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 CrewAI project.
- 1.Install crewai-tools with the e2b extra ("crewai-tools[e2b]") using the project's package manager.
- 2.The tool 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 CrewAI guide at https://docs.e2b.dev/agents/crewai and give my agents an E2BPythonTool, so the Python they write runs in an E2B sandbox. Close the tool in a finally block.
- 4.Run one task and show me the output that came from the sandbox.
Or set it up yourself
1. Install the E2B tools
2. Set your API keys
3. Give the tool to an agent
4. Run your crew
What runs in the sandbox
The code your agents write runs in an isolated sandbox, away from the machine running CrewAI.
- Python the agent writes, executed by E2BPythonTool in an E2B Code Interpreter sandbox.
- A new sandbox per tool call by default. persistent=True keeps imports and variables between calls.
- sandbox_timeout bounds how long the sandbox lives. Call close() in finally to shut it down.
- Your API keys stay with CrewAI on your machine unless you pass them into the sandbox.
More agent frameworks
Other frameworks that run their tools on E2B.
- LangChain Deep AgentsBack LangChain Deep Agents with an E2B sandbox through the langchain-e2b package.
- Hugging Face smolagentsSet executor_type="e2b" and smolagents runs every code action in a sandbox.
- Vercel AI SDKGive Vercel AI SDK agents sandbox tools with @e2b/ai-sdk-sandbox. Experimental for AI SDK 7.
