Roll out Gemini CLI in your company: headless runs, Vertex AI and CI on microVMs in France
Last updated
Gemini CLI unattended, two paths on flockvm
Path A: one VM per task
1 / 5
An environment for Gemini
A VM has no OIDC identity to federate, so path A uses a service account key: its JSON as a secret file, and the variables next to it.
2 / 5
A microVM from the Agent image
gemini is preinstalled. The repository is in the environment's GitHub repositories, cloned read-only at first boot.
3 / 5
Admin settings on the machine
The highest settings layer is the system override file, /etc/
4 / 5
One task, headless
Choose the approval mode for the run: with auto_edit, edits happen, commands don't; yolo auto-approves every tool.
5 / 5
The patch out, the VM deleted
The patch is taken out and the pull request opened outside the VM. Your script deletes the VM.
Path B: one VM per CI job
1 / 5
A job with a flockvm label
Change runs-on: 'ubuntu-latest' to a flockvm label in Google's workflows. flockvm runs CI jobs of private repositories only.
2 / 5
A microVM from the runner image
A fresh microVM with its own kernel for the job; nobody can SSH in.
3 / 5
Workload Identity Federation
From GitHub's OIDC token: no stored Google key. GitHub issues it, not the runner, so WIF does not depend on where the job runs.
4 / 5
The action runs Gemini CLI
The action installs Gemini CLI with npm, then runs gemini --yolo: it always runs in yolo mode.
5 / 5
Deleted when the job ends
On flockvm the job runs in a VM deleted afterwards, with open egress. run-gemini-cli has not been run on a flockvm runner yet.
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 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 | 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 for the script that creates VMs; and an 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.
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).
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:
{
"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
enforcedTypeset tovertex-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:
logPromptsdefaults 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 thetelemetryblock 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: 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.
#!/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_editauto-approves edit tools. Google's policy engine treats a rule that would ask the user asdenyin non-interactive mode, so tools that need confirmation, such as most shell commands, are refused rather than run: edits happen, commands don't.planis "strict, read-only": for reviews and questions.yoloauto-approves every tool. Inside a disposable VM that is a reasonable trade, with the egress caveat above; leavedisableYoloModeout 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). 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):
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: writelets 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 runsgemini --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_PROVIDERandSERVICE_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) andGEMINI_MODEL, a model that region serves, such asgemini-2.5-proineurope-west9. Google's README does not listGEMINI_MODEL, but its examples pass it togemini_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
settingsinput writes JSON to the project's.gemini/settings.json: the place fortools.coreand"privacy": {"usageStatisticsEnabled": false}in CI. Don't putdisableYoloModethere: 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-githubin the CLI; change theirruns-on: 'ubuntu-latest'to a flockvm label.gemini-dispatch.ymlis 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);
enforcedTypeset 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_LOCATIONset to a region that serves your model, never the global endpoint if processing location matters. -
/etc/gemini-cli/settings.jsonwritten at boot: auth lock, telemetry withlogPrompts: false, usage statistics off; yolo disabled where you don't want it. -
tools.coreallowlist andmcp.allowedfor 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: writeonly 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.
A CI job with 3 minutes of steps
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 with your organization's name and ID.
Related pages
- Codex CLI for enterprise teams: the same layout for OpenAI's CLI.
- VM images: what the Agent image has, Gemini CLI included.
- Environments, API keys and scopes, Audit log.
- GitHub Actions runners on flockvm, CI limits and CI security.
- EU data residency.
Run your agents in their own microVMs
flockvm gives each coding agent a Firecracker microVM that pauses with its memory and resumes, billed per second. France is live, and you can start with a 7-day free trial.
Start your 7-day free trialCard required. Nothing charged for 7 days.
Rolling this out to a team?
Write to hello@flockvm.com with the agents, repositories and CI volume you plan to run, and we will reply.