Gemini CLI
Run Google's Gemini CLI in a sandbox from the prebuilt gemini template. Give it a Gemini API key and a task, and it works on the sandbox's files, terminal and git.
- E2B
- Prebuilt gemini sandbox template
- e2b
- TypeScript, Python
Get started
Paste the prompt into your coding agent, or follow the steps yourself.
Paste this into your coding agent
Run Gemini CLI in an E2B sandbox from this project.
- 1.Install the e2b SDK using the project's package manager.
- 2.The SDK needs the E2B_API_KEY environment variable, and Gemini CLI needs GEMINI_API_KEY. If E2B_API_KEY isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode either key.
- 3.Follow the Gemini CLI guide at https://docs.e2b.dev/agents/gemini-cli: create a sandbox from the gemini template, pass GEMINI_API_KEY in envs, and run gemini --skip-trust --yolo -p with a command timeout of 0. Kill the sandbox when it's done.
- 4.Run one task and show me the output that came from the sandbox.
Or set it up yourself
1. Install the E2B SDK
2. Set your API keys
3. Run Gemini CLI headless
4. Work on a repository
What runs in the sandbox
Gemini CLI and every command it runs live in the sandbox, away from your machine.
- gemini with --yolo auto-approving tool calls and --skip-trust trusting the working folder for the run.
- The repo you clone and every change Gemini CLI makes. Read the result back with git diff.
- Sessions are saved per folder under ~/.gemini. --resume latest continues the most recent one.
- Internet access is on by default. Restrict outbound traffic with network rules for untrusted input or secrets.
More coding agents
Other coding agents that run in E2B sandboxes.
- Claude CodeRun Claude Code in its own sandbox with a real filesystem, terminal, and git, so it can work unattended.
- OpenAI CodexRun OpenAI's Codex CLI headless in a sandbox and collect the diff when it's done.
- Kimi Code CLIRun Moonshot AI's Kimi Code CLI in a sandbox with full filesystem, terminal, and git access.
