Kimi Code CLI
Run Moonshot AI's Kimi Code CLI in an E2B sandbox with a real filesystem, terminal and git. In headless mode its tool calls run without approval, inside the sandbox.
- E2B
- Prebuilt kimi template
- kimi
- TypeScript, Python
Get started
Paste the prompt into your coding agent, or follow the steps yourself.
Paste this into your coding agent
Run Kimi Code CLI in an E2B sandbox from this project.
- 1.Install the e2b package using the project's package manager.
- 2.The SDK 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. Kimi also needs a Moonshot AI API key, passed to the sandbox as KIMI_MODEL_API_KEY.
- 3.Follow the Kimi Code CLI guide at https://docs.e2b.dev/agents/kimi-cli: create a sandbox from the kimi template with KIMI_MODEL_NAME and KIMI_MODEL_API_KEY, and run kimi -p with a task.
- 4.Run it once, show me the output that came from the sandbox, then kill the sandbox.
Or set it up yourself
1. Install the E2B SDK
2. Set your API keys
3. Run Kimi headless
4. Or open it interactively
What runs in the sandbox
Kimi's tool calls run in the sandbox, away from your host files and credentials.
- Shell commands, file edits and git operations. With -p, Kimi runs tool calls without asking for approval.
- Sessions are stored under ~/.kimi-code/sessions in the sandbox. kimi -r <id> continues one.
- The model key goes in as KIMI_MODEL_API_KEY. Kimi doesn't read KIMI_API_KEY from the environment.
- Sandboxes reach the internet by default. Limit where the agent connects with outbound network rules.
More coding agents
Other coding agents that run in E2B sandboxes.
- Gemini CLIRun Google's Gemini CLI in a sandbox with full filesystem, terminal, and git access.
- GitHub Copilot CLIRun GitHub Copilot CLI in a sandbox with full filesystem, terminal, and git access.
- Claude CodeRun Claude Code in its own sandbox with a real filesystem, terminal, and git, so it can work unattended.
