agy) is Google’s coding agent for the terminal. E2B provides a pre-built antigravity template with Antigravity CLI already installed and configured to authenticate with a Gemini API key.
Antigravity CLI is the successor to Gemini CLI. Google announced the transition on May 19, 2026: since June 18, 2026, Gemini CLI no longer serves free-tier and Google AI Pro and Ultra users, while it remains available to enterprise customers and with paid API keys. To move existing skills, plugins, and MCP servers, see the migration guide.
Authentication
The template sets"modelProvider": "gemini" in ~/.gemini/antigravity-cli/settings.json, so Antigravity CLI authenticates with the GEMINI_API_KEY environment variable instead of a browser sign-in. Create a key in Google AI Studio and pass it to the sandbox. Antigravity CLI reads only GEMINI_API_KEY — it ignores GOOGLE_API_KEY and .env files — and does not start when the variable is empty.
To sign in with a Google account instead, remove modelProvider from the settings file. Antigravity CLI then prints an authorization URL; open it in your local browser and paste the code back into the terminal.
CLI
Create a sandbox with the E2B CLI and pass your API key to the terminal session.Run headless
Use-p for non-interactive mode and --dangerously-skip-permissions to auto-approve all tool calls. Without it, headless runs cannot ask for approval: tools that need it are denied, and the run still exits with code 0 and lists them under denied_actions in --output-format json output.
Agent runs often take longer than the default command timeout, so pass timeoutMs: 0 (timeout=0 in Python) to wait until the run completes, and give the sandbox enough lifetime.
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
Streaming output
Use--output-format stream-json to get a real-time JSONL event stream: an init event, step_update events for tool calls and response text, and a final result event with the status, response, and token usage.
json output envelope, --json-schema structured output, and resuming a conversation with --conversation.
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-builtantigravity template.
Related guides
Sandbox persistence
Auto-pause, resume, and manage sandbox lifecycle
SSH access
Connect to the sandbox via SSH for interactive sessions