Skip to main content
Kiro CLI is AWS’s coding agent for the terminal. E2B provides a pre-built kiro template with Kiro CLI already installed.

CLI

Create a sandbox with the E2B CLI.
Once inside the sandbox, start Kiro CLI.

Run headless

Use kiro-cli chat --no-interactive to run a single prompt without user input, and --trust-all-tools to auto-approve all tool calls. Headless runs authenticate with a Kiro API key passed as the KIRO_API_KEY environment variable. API keys are available on the Kiro Pro, Pro+, Pro Max, and Power plans. Create one in the Kiro web console. On the Free plan, log in with device flow instead.
Auto-approving tool calls is contained by the sandbox: the agent cannot touch your host machine, local files, or credentials. It can still make outbound network requests — internet access is enabled by default. To limit where an auto-approved agent can connect, configure outbound network rules (allowInternetAccess, plus allow/deny lists by CIDR or hostname). Hostname rules apply to HTTP(S) traffic only; use CIDR rules for other protocols.

Example: work on a cloned repository

Stream events as JSON

Add --output-format stream-json to get the run as JSON Lines on stdout, one event per line. Each event has a type and a data field. This option implies --no-interactive, so you don’t need to pass it. Parse each line as it arrives. See Kiro headless mode for the event format.

Resume a session

Add --resume to continue the most recent conversation in the same working directory.

Log in without an API key

On the Kiro Free plan, or when you sign in with AWS Builder ID, GitHub, or Google, log in once per sandbox with device flow instead of an API key. Run the command from a sandbox terminal (see CLI). It prints a URL and a code — open the URL in your browser, confirm the code, and the command finishes once the login is confirmed.
After logging in, run headless commands without KIRO_API_KEY.
Kiro stores login credentials inside the sandbox, under /home/user/.local/share/kiro-cli. They persist across pause and resume, so anyone with access to the sandbox can act with your Kiro account until the sandbox is killed or you run kiro-cli logout.

Build a custom template

If you need to customize the environment (e.g. pre-install dependencies, add config files), build your own template on top of the pre-built kiro template.
Run the build script to create the template.

Sandbox persistence

Auto-pause, resume, and manage sandbox lifecycle

SSH access

Connect to the sandbox via SSH for interactive sessions