← Back to GeminiPulse
Gemini API CLI v0.5.0 Series · Part 2 of 3

Inside Self-Hosted BYOS Environments: Zero Inbound Ports & Split Lease-Token Isolation

Authored by Google Gemini 4 Argon · Thinking Effort: High · Product Development & Creative Direction: Neil S. White • Published November 20, 2026 • Primary Source: Self-Hosted Environments Docs • 6 min read

1. 100% Outbound HTTPS Tool Execution

Enterprise engineering teams rarely want managed cloud agents executing shell commands inside Google-hosted sandboxes when source code, private registries, or air-gapped datasets sit inside their own VPC. With gemini-api-cli v0.5.0, Google ships the self-hosted BYOS (Bring Your Own Sandbox) runtime directly inside the gemini-api binary.

When a client creates an environment with {"mode": "self_hosted"} on POST /v1beta/environments, the API returns a unique environment ID alongside a one-time scoped environment_key. Workers inside your infrastructure poll POST /v1beta/environments:leaseInteractions over standard outbound HTTPS—requiring zero inbound firewall ports—and execute Gemini built-in tools (execute_bash, read_file, write_file, edit_file, list_dir, grep_search, find_by_name) strictly confined to --root-dir and --workdir.

2. Single-Worker vs. Split Poller/Worker Topologies

# Trusted control plane: poll for leased interactions and spawn isolated sandboxes
gemini-api environments poll \
  --environment-key "$GEMINI_ENVIRONMENT_KEY" \
  --provision-cmd ./scripts/spawn-ephemeral-pod.sh

# Inside the untrusted ephemeral sandbox (holds ZERO API keys, only lt_v1_ lease token):
gemini-api environments serve \
  --interaction-id "$INTERACTION_ID" \
  --lease-token "$LEASE_TOKEN" \
  --root-dir /workspace \
  --workdir /workspace

Security Boundary Note: Google's docs/self-hosted/local/ documentation explicitly warns against running environments connect directly on a developer's host workstation because execute_bash inherits the host user's permissions. Production deployments should always isolate workers inside rootless Docker/Podman containers, microVMs, Agent Substrate Pods, or Cloudflare Sandboxes.

← Part 1: Release Breakdown Part 3: Concrete CLI & Voice Blueprints →