# Gemini CLI for Enterprise Teams

> A playbook for platform teams: Gemini CLI headless in one microVM per task, Vertex AI auth for companies, admin settings, and run-gemini-cli on flockvm runners.

- URL: https://flockvm.com/playbooks/gemini-cli-enterprise
- Last updated: 2026-11-10

This playbook is for the platform or DevEx team that standardizes on Google's models and wants Gemini CLI to run unattended: on a schedule, from an internal tool, or in GitHub Actions. On flockvm each run gets its own Firecracker microVM in France, Gemini CLI is preinstalled on the Agent image, and `google-github-actions/run-gemini-cli` can run on a flockvm runner with `runs-on: flockvm`. If your company also runs Codex, the [Codex CLI playbook](/playbooks/codex-cli-enterprise) uses the same layout, and most steps carry over.

What was checked, and how. Every Gemini CLI fact comes from Google's documentation and the action's repository, read on 8 November 2026. The checks marked *measured* were run that day in a flockvm VM built on the Agent image, with Gemini CLI 0.67.0 installed fresh from npm. We had no Google credentials in that VM, so no model call succeeded, and `run-gemini-cli` has not been run on a flockvm runner yet.

## Who this is for

- **Platform teams on Google Cloud** that already buy Vertex AI or Gemini Code Assist and want one way to run Gemini CLI headless.
- **Security teams** that need Gemini's admin settings applied on the machine that runs it, and the model called in a European region.
- **CI owners** who want the Gemini review and triage workflows in private repositories without GitHub-hosted minutes.

Public repositories are out of scope: flockvm runs CI jobs of private repositories only, so an open-source issue-triage bot stays on GitHub's runners.

## The architecture on flockvm

| | Path A: one VM per task | Path B: one VM per CI job |
|---|---|---|
| Machine | A microVM from the Agent image, `gemini` preinstalled | A microVM from the runner image; the action installs Gemini CLI with npm |
| Model auth | Gemini API key, or a Vertex AI service account key as a secret file | Workload Identity Federation from GitHub's OIDC token: no stored Google key |
| Secrets | A flockvm [environment](/docs/vms/environments) | GitHub Actions secrets and variables |
| End of life | Your script deletes the VM | Deleted when the job ends; nobody can SSH in |

From flockvm, in both paths: a fresh microVM with its own kernel, deleted at the end; VM data on one server in France; [scoped API keys](/docs/api/api-keys) for the script that creates VMs; and an [audit log](/docs/team/audit-log) of VMs, environments and keys for Enterprise organizations. Not from flockvm: egress filtering (outbound access is open, except private ranges, cloud metadata, other VMs, the host and port 25), and any record of what Gemini did inside the VM. Gemini's own telemetry is where that goes.

## Step 1: pick the auth method

Google's authentication page recommends, for headless use, "Gemini API Key or Vertex AI". Sign in with Google needs a browser.

| Method | Set | For a company |
|---|---|---|
| Gemini API key | `GEMINI_API_KEY` from AI Studio | Quick start; usage under the key's project |
| Vertex AI, service account | `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION`, and `GOOGLE_APPLICATION_CREDENTIALS` pointing to a service account JSON with the "Vertex AI User" role | What Google recommends "in non-interactive environments, CI/CD pipelines"; you pick the region |
| Vertex AI, Workload Identity Federation | Done by the action through `google-github-actions/auth`; roles `roles/aiplatform.user` (Vertex) or `roles/cloudaicompanion.user` (Code Assist) | GitHub Actions: no long-lived key |
| Gemini Code Assist licence | A Google Cloud project; Standard allows 1,500 model requests per user per day, Enterprise 2,000 | Google says the Standard and Enterprise data-protection terms "also apply to Gemini CLI"; the quotas are shared with Code Assist agent mode. Its admin controls' Strict Mode is on by default and blocks yolo mode (see step 5) |

For ADC and service accounts, unset `GEMINI_API_KEY` and `GOOGLE_API_KEY` first. *Measured*: with no auth at all, `gemini -p` 0.67.0 exits with code 41 and names three ways to select one, `GEMINI_API_KEY`, `GOOGLE_GENAI_USE_VERTEXAI` and `GOOGLE_GENAI_USE_GCA`. The action sets the last two from its `use_vertex_ai` and `use_gemini_code_assist` inputs.

### Calling Vertex AI from Europe

Google's locations table marks Gemini 2.5 Pro, 2.5 Flash and 2.5 Flash-Lite as available in Paris, `europe-west9`, among other EU regions. Newer models are offered in fewer places: Gemini 3.5 Flash in London and Frankfurt only, and several 3.x models in no single EU region, only in the EU multi-region `eu`. Pass a model your location serves with `-m`, even when it is the one you expect by default: Gemini CLI has a model-routing step (our run's log shows it), and a routed model may not be offered in your region. *Measured*: Gemini CLI 0.67.0 knows the id `gemini-2.5-pro`. We have not checked whether it accepts `GOOGLE_CLOUD_LOCATION=eu`.

Google's own caveats, on the same page: "Endpoints don't guarantee data residency or in-region ML processing", and "Don't use the global endpoint if you have ML processing requirements." A flockvm VM in France calling Vertex in `europe-west9` keeps the VM and its files in France; where the prompt is processed is Google's commitment, under your contract with Google. More on what stays where in [EU data residency](/eu-data-residency).

## Step 2: an environment for Gemini

A VM has no OIDC identity to federate, so path A uses a service account key: a dedicated service account with the Vertex AI User role, its JSON as a secret file, and the variables next to it. If you also send Gemini's telemetry to Google Cloud (step 3), give the same account the three roles Google's telemetry page lists, **Cloud Trace Agent**, **Monitoring Metric Writer** and **Logs Writer**, and enable the Cloud Trace, Cloud Monitoring and Cloud Logging APIs in the project (`gcloud services enable cloudtrace.googleapis.com monitoring.googleapis.com logging.googleapis.com`).

```bash
flockvm env create gemini
flockvm env update gemini --members-can-use off
flockvm env file add .config/gcloud/gemini-sa.json ./gemini-sa.json --env gemini
flockvm env set GOOGLE_GENAI_USE_VERTEXAI=true \
  GOOGLE_CLOUD_PROJECT=acme-ai \
  GOOGLE_CLOUD_LOCATION=europe-west9 \
  GOOGLE_APPLICATION_CREDENTIALS=/home/user/.config/gcloud/gemini-sa.json \
  GEMINI_CLI_TRUST_WORKSPACE=true \
  --env gemini
```

The secret file lands at `/home/user/.config/gcloud/gemini-sa.json`, mode `0600`, in every new VM. Google's configuration reference says `GEMINI_CLI_TRUST_WORKSPACE`, "If set to `"true"`, trusts the current workspace for the duration of the session, bypassing the folder trust check." Headless runs need it when folder trust is on: "If the folder is untrusted and the Folder Trust feature is enabled, the CLI will throw a `FatalUntrustedWorkspaceError` and exit." Google's trust guidance for workflows: "If your workflow operates exclusively on trusted data, e.g., code or prompts from repo owners, you can safely set `GEMINI_CLI_TRUST_WORKSPACE=true`"; on untrusted data, harden the workflow first.

With **Members can use it** off, only owners and admins create VMs with this environment; anyone who does can read the key from a shell, and so can the agent. Rotate the service account key on a schedule, and at once if a run looked wrong.

## Step 3: apply admin settings on the machine

Gemini CLI reads four settings layers; the highest is the system override file, `/etc/gemini-cli/settings.json`, and arrays and objects are merged. Google's enterprise page uses it for the controls a company wants:

```json
{
  "security": {
    "disableYoloMode": true,
    "auth": { "enforcedType": "vertex-ai" }
  },
  "telemetry": { "enabled": true, "target": "gcp", "logPrompts": false },
  "privacy": { "usageStatisticsEnabled": false }
}
```

- *Measured*: with `disableYoloMode`, `gemini --approval-mode yolo -p …` exits with code 52 and "YOLO mode is disabled by your administrator".
- *Measured*: with `enforcedType` set to `vertex-ai`, a run that uses a Gemini API key exits with code 41: "The enforced authentication type is 'vertex-ai', but the current type is 'gemini-api-key'." Google's docs say a non-interactive run "will exit with an error if the configured authentication method does not match".
- Telemetry: `logPrompts` defaults to true, and the enterprise page says to set it to false. `target: "gcp"` sends OpenTelemetry data to your project, and needs the three roles and three APIs of step 2 on the account Gemini runs as; without them, leave the `telemetry` block out.
- Usage statistics default to on; the last line turns them off.

Two more from the same page: `tools.core` is an allowlist of tools ("Allowlisting is the recommended approach"), and MCP servers defined in the system settings and listed in `mcp.allowed` are the only ones users can add. Admin policies (TOML rules with `allow`, `deny` or `ask_user`) go in `/etc/gemini-cli/policies`.

Google's caveat: these patterns "should not be considered a foolproof security boundary". On a flockvm VM, `user` has passwordless `sudo`, so an agent could edit the file. Treat it as protection against mistakes and drift. Google's Admin Controls in the Management Console are "enforced globally and cannot be overridden by users locally", with Strict Mode (no yolo) on by default.

## Step 4: run one task per VM

The script follows the [Codex playbook's](/playbooks/codex-cli-enterprise#step-4-run-one-task-per-vm): an API key with the **Create and use VMs** preset, restricted to the `gemini` environment and created by an owner or admin; the repository in the environment's **GitHub repositories**, cloned read-only at first boot; the patch taken out, the pull request opened outside the VM.

```bash
#!/bin/bash
# gemini-task.sh
# Usage: FLOCKVM_API_KEY=… ./gemini-task.sh docs-1 "Update the README for the new CLI flags"
set -euo pipefail
name="$1"; task="$2"; repo=web-app

flockvm vm create "$name" --size default --env gemini --wait
trap 'flockvm vm delete "$name" --yes; rm -f "$name.known_hosts"' EXIT   # on success and on failure
vm() { flockvm vm ssh "$name" -- -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="$name.known_hosts" "$@"; }

vm -n "sudo mkdir -p /etc/gemini-cli && echo '{\"security\":{\"disableYoloMode\":true,\"auth\":{\"enforcedType\":\"vertex-ai\"}},\"privacy\":{\"usageStatisticsEnabled\":false}}' | sudo tee /etc/gemini-cli/settings.json > /dev/null"
printf '%s' "$task" | vm 'cat > ~/task.txt'
vm -n 'timeout 300 bash -c "until journalctl -u flock-repos -q --no-pager | grep -q \"cloned for\"; do sleep 2; done"'

vm -n "
  cd ~/$repo
  gemini -m gemini-2.5-pro --approval-mode auto_edit -o json -p \"\$(cat ~/task.txt)\" > ~/result.json 2> ~/gemini.log
  echo \"exit \$?\" >> ~/gemini.log
  git add -A && git diff --cached > ~/gemini.patch
"

vm -n 'cat ~/result.json' > "$name.json"
vm -n 'cat ~/gemini.patch' > "$name.patch"
```

As in the Codex script: the `trap` deletes the VM on any exit, an error included, so a failed step leaves no VM running with the service account key inside; the wait is on the clone service's last log line ("… cloned for user"), since a `.git` folder exists as soon as the clone starts; and each SSH call accepts the new VM's host key once into a known-hosts file of that run, so the script runs from cron or CI without "Host key verification failed".

Choosing the approval mode for headless runs:

- `auto_edit` auto-approves edit tools. Google's policy engine treats a rule that would ask the user as `deny` in non-interactive mode, so tools that need confirmation, such as most shell commands, are refused rather than run: edits happen, commands don't.
- `plan` is "strict, read-only": for reviews and questions.
- `yolo` auto-approves every tool. Inside a disposable VM that is a reasonable trade, with the egress caveat above; leave `disableYoloMode` out of the settings for those VMs.

`-o json` returns one object with `response`, `stats` and an optional `error`; `-o stream-json` streams JSONL events. Exit codes per Google: `0` success, `1` error, `42` input error, `53` turn limit exceeded; we also saw `41` for auth problems and `52` for yolo refused. `GEMINI_CLI_HOME` moves `~/.gemini` elsewhere, useful when several runs share a VM.

Gemini CLI's own sandbox (`GEMINI_SANDBOX=docker`, image `ghcr.io/google/gemini-cli:latest`) can run inside the VM: the Agent image has Docker. In a VM that exists for one task, the VM already plays that role.

## Step 5: run-gemini-cli on flockvm runners

Connect the repositories on the CI page ([setup](/docs/ci/setup)). The action is a composite action that runs `npm install --global @google/gemini-cli`, then `gemini --yolo --prompt "${PROMPT}" --output-format json`: it always runs in yolo mode. It needs `bash`, `jq` and `npm` on the runner, and Docker for its telemetry collector when WIF is set and for the GitHub MCP server of the examples. It has no `actions/setup-node` step of its own.

On flockvm's runner image, from its build script and docs: the default `node` is Node.js 24 with npm, `runner` may `npm i -g`, and `jq` and Docker 29 are preinstalled. Gemini CLI asks for Node.js 20 or later. So `actions/setup-node` is optional. Status: this workflow has not been run end to end on a flockvm runner yet; run it once on a test repository.

Google's Vertex-with-WIF step, wrapped in a job (the `with` block is Google's, the `env` line and `gemini_model` come from Google's example workflows; the job around it is ours):

```yaml
name: Gemini
on: workflow_dispatch

jobs:
  gemini:
    runs-on: flockvm-small
    timeout-minutes: 15
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v6
      - uses: 'google-github-actions/run-gemini-cli@v0'
        env:
          # Without it, the CLI stops on an untrusted folder (FatalUntrustedWorkspaceError).
          # Safe on trusted input only: see Google's trust guidance below.
          GEMINI_CLI_TRUST_WORKSPACE: 'true'
        with:
          gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
          gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
          gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
          gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
          use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
          gemini_model: '${{ vars.GEMINI_MODEL }}'
          prompt: |-
            Explain this code
```

- `id-token: write` lets the job ask GitHub for its OIDC token; GitHub issues it, not the runner, so WIF does not depend on where the job runs. `gcp_token_format: ''` uses direct WIF without a service account.
- `GEMINI_CLI_TRUST_WORKSPACE: 'true'` is set on the step in every one of Google's example workflows: the action runs `gemini --yolo --prompt …` and sets no workspace trust itself, so without it the CLI exits before calling the model when folder trust is on. Google calls it safe "if your workflow operates exclusively on trusted data, e.g., code or prompts from repo owners"; for issues and pull requests from others, apply the trust guidance below first.
- Repository variables the job reads (**Settings → Secrets and variables → Actions → Variables**): `GCP_WIF_PROVIDER` and `SERVICE_ACCOUNT_EMAIL` (from Google's WIF setup), `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION` (the region you chose in step 1), `GOOGLE_GENAI_USE_VERTEXAI` (`true`) and `GEMINI_MODEL`, a model that region serves, such as `gemini-2.5-pro` in `europe-west9`. Google's README does not list `GEMINI_MODEL`, but its examples pass it to `gemini_model`.
- With Gemini Code Assist instead of Vertex (`use_gemini_code_assist`), Google's admin controls apply, and their Strict Mode is on by default: "If enabled, users will not be able to enter yolo mode." Since the action always passes `--yolo`, a Code Assist administrator has to turn Strict Mode off in the admin controls before this job can run. Not tested on our side.
- The `settings` input writes JSON to the project's `.gemini/settings.json`: the place for `tools.core` and `"privacy": {"usageStatisticsEnabled": false}` in CI. Don't put `disableYoloMode` there: the action always passes `--yolo`.
- Google's full workflows (`gemini-dispatch`, `pr-review`, `issue-triage`, `gemini-assistant`) can be copied by hand or set up with `/setup-github` in the CLI; change their `runs-on: 'ubuntu-latest'` to a flockvm label. `gemini-dispatch.yml` is required by the others.

Google's trust guidance for workflows that read issues and pull requests: minimal token permissions, runs triggered by maintainers, and a minimal tool set (`list_directory`, `read_file`, `grep_search`). That applies on any runner. On flockvm the job runs in a VM deleted afterwards, with open egress.

Limits of the CI path today: 4 runner VMs at once across every flockvm organization (use `concurrency:` groups), private repositories only, no cache (the CLI is installed in every job), 6-hour jobs, and no CI during the 7-day trial.

## Governance checklist

- [ ] Auth: Vertex AI with a service account limited to Vertex AI User, plus Cloud Trace Agent, Monitoring Metric Writer and Logs Writer if telemetry goes to Google Cloud (VMs), or WIF (CI); `enforcedType` set to the method you chose.
- [ ] In CI: `GEMINI_CLI_TRUST_WORKSPACE: 'true'` on the action's step, and the workflow hardened per Google's trust guidance before it reads others' issues or pull requests.
- [ ] Region: `GOOGLE_CLOUD_LOCATION` set to a region that serves your model, never the global endpoint if processing location matters.
- [ ] `/etc/gemini-cli/settings.json` written at boot: auth lock, telemetry with `logPrompts: false`, usage statistics off; yolo disabled where you don't want it.
- [ ] `tools.core` allowlist and `mcp.allowed` for anything beyond read-and-edit tasks.
- [ ] A flockvm environment per purpose, **Members can use it** off; the automation key restricted to it, with an expiry.
- [ ] Repositories cloned read-only; pull requests opened outside the VM.
- [ ] VMs deleted by the script that created them; Enterprise audit log for VM and key events.
- [ ] In CI: `permissions:` minimal, `id-token: write` only on the Gemini job, `concurrency:` groups, `timeout-minutes`.
- [ ] Egress: your own proxy (`HTTPS_PROXY`, which Gemini CLI honours) if you need an allowlist; flockvm has none.

## What it costs

flockvm bills VMs and runner jobs per second; Google bills the model usage.

| What | flockvm price | Example |
|---|---|---|
| Task VM, `default` (4 vCPU, 8 GB) | $0.032 an hour | A 20-minute task: $0.0107 |
| CI job, `flockvm-small` (2 vCPU, 4 GB) | $0.002 a minute | 3 minutes of steps + about 25 s of boot = 205 s: 205 ÷ 60 × $0.002 = $0.0068 |

GitHub's 2-core hosted runner bills the same job at least 3 × $0.006 = $0.018. The plan is $18 a month per organization, all of it usable as VM and CI time, then a prepaid wallet; the 7-day free trial (card required, nothing charged for 7 days) covers VMs only. See [pricing](/docs/billing/pricing).

## Limits to know

| Area | Today |
|---|---|
| Region | France for VMs, CI and environments |
| Runner concurrency | 4 runner VMs at once across all organizations |
| CI scope | Private repositories, Linux x64, 6-hour jobs, no cache |
| Network | Outbound open; no egress allowlist |
| Audit | Enterprise organizations, turned on by the flockvm team; no record of commands or prompts inside a VM |
| Sign-in to flockvm | Google, GitHub or an email link; no SSO/SAML or SCIM |
| Compliance | No SOC 2 report, no SLA |
| Settings in the VM | `/etc/gemini-cli/settings.json` can be changed by an agent with sudo |

For Enterprise (audit log, organization key policy), write to [hello@flockvm.com](mailto:hello@flockvm.com) with your organization's name and ID.

## Related pages

- [Codex CLI for enterprise teams](/playbooks/codex-cli-enterprise): the same layout for OpenAI's CLI.
- [VM images](/docs/vms/images): what the Agent image has, Gemini CLI included.
- [Environments](/docs/vms/environments), [API keys and scopes](/docs/api/api-keys), [Audit log](/docs/team/audit-log).
- [GitHub Actions runners on flockvm](/github-actions-runners), [CI limits](/docs/ci/limits) and [CI security](/docs/ci/security).
- [EU data residency](/eu-data-residency).

## Sources

- [Gemini CLI docs: Headless mode (-p, output formats, exit codes)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/headless.md) (accessed 2026-11-08)
- [Gemini CLI docs: CLI reference (--approval-mode, --yolo deprecated, --output-format)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/cli-reference.md) (accessed 2026-11-08)
- [Gemini CLI docs: Authentication (API key, Vertex AI, ADC, service account)](https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/authentication.mdx) (accessed 2026-11-08)
- [Gemini CLI docs: Enterprise (system settings, tools.core, MCP allowlist, enforced auth, telemetry, GEMINI_CLI_HOME)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/enterprise.md) (accessed 2026-11-08)
- [Gemini CLI docs: Configuration reference (settings layers, GEMINI_SANDBOX, usage statistics)](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md) (accessed 2026-11-08)
- [Gemini CLI docs: Policy engine (ask_user is deny in non-interactive mode, admin policies)](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/policy-engine.md) (accessed 2026-11-08)
- [Gemini CLI docs: Trusted folders (GEMINI_CLI_TRUST_WORKSPACE)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/trusted-folders.md) (accessed 2026-11-08)
- [Gemini CLI docs: Sandbox (Docker, Podman, gVisor)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/sandbox.md) (accessed 2026-11-08)
- [Gemini CLI docs: Telemetry (logPrompts default)](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/telemetry.md) (accessed 2026-11-08)
- [Gemini CLI docs: Admin controls (enforced globally, Strict Mode)](https://github.com/google-gemini/gemini-cli/blob/main/docs/admin/enterprise-controls.md) (accessed 2026-11-08)
- [Gemini CLI docs: Quota and pricing (Code Assist Standard and Enterprise)](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/quota-and-pricing.md) (accessed 2026-11-08)
- [Gemini CLI docs: Installation (Node.js 20+, RAM)](https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/installation.mdx) (accessed 2026-11-08)
- [Google Cloud: Gemini Code Assist and Gemini CLI (shared quotas, data protection terms)](https://docs.cloud.google.com/gemini/docs/codeassist/gemini-cli) (accessed 2026-11-08)
- [Google Cloud: Vertex AI generative AI locations (Europe table, endpoint caveats)](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/learn/locations) (accessed 2026-11-08)
- [npm: @google/gemini-cli 0.67.0 (installed and run on 2026-11-08)](https://registry.npmjs.org/@google/gemini-cli/latest) (accessed 2026-11-08)
- [google-github-actions/run-gemini-cli README (inputs, setup)](https://github.com/google-github-actions/run-gemini-cli) (accessed 2026-11-08)
- [google-github-actions/run-gemini-cli action.yml (npm install -g, --yolo, jq, telemetry collector)](https://github.com/google-github-actions/run-gemini-cli/blob/main/action.yml) (accessed 2026-11-08)
- [google-github-actions/run-gemini-cli docs: Authentication (Workload Identity Federation, roles)](https://github.com/google-github-actions/run-gemini-cli/blob/main/docs/authentication.md) (accessed 2026-11-08)
- [google-github-actions/run-gemini-cli docs: Trust guidance](https://github.com/google-github-actions/run-gemini-cli/blob/main/docs/trust-guidance.md) (accessed 2026-11-08)
- [google-github-actions/run-gemini-cli releases (v0.1.22)](https://github.com/google-github-actions/run-gemini-cli/releases) (accessed 2026-11-08)
- [google-github-actions/auth README (id-token permission)](https://github.com/google-github-actions/auth) (accessed 2026-11-08)
