Start with one bounded analysis job
Google announced the Gemini API CLI beta on October 27, 2026, as a stateless client for agents, scripts and continuous integration (CI). Version v0.4.4 preceded the announcement on October 23, 2026; v0.4.5 followed on October 30, 2026. The repository describes independent invocations: the caller supplies context and controls the next step. Put job boundaries and recovery decisions in the surrounding pipeline. Sources: Google AI for Developers, Google Gemini on GitHub
Start with a versioned product brief and extract unresolved questions, explicitly named owners and supporting evidence. Require evidence copied from the document and a null owner when none is stated. The JSON below is a proposed application contract, separate from the CLI’s response envelope. For this experiment, use one UTF-8 fixture of at most 100 KiB and accept at most 20 questions. Set a 180-second overall deadline and allow at most two submission attempts, including the first.
{
"schema_version": 1,
"questions": [
{
"question": "Which regions are included in the launch?",
"owner": null,
"evidence": "Launch regions remain to be confirmed."
}
]
}- Exclude browsing, external tools and follow-up conversation.
- Select an explicit model and prohibit automatic substitution.
- Publish only after local validation.
Pin the client and inspect the resolved request
Select v0.4.4 for announcement-era behavior, or evaluate v0.4.5 separately. Version v0.3.0 replaced TypeScript with Go and broke compatibility in commands, flags and output formats. Version v0.4.0 changed the generation, analysis and transcription default from gemini-3.6-flash to gemini-3.8-flash. Version v0.4.5 changed background agent execution and the transcription default. Record the binary version, then inspect the analysis command’s help and request schema through the documented discovery interface. Sources: Google AI for Developers, Google Gemini on GitHub
gemini-api --version
gemini-api analyze --help
gemini-api analyze --schemaNext, preview the basic analysis request with the CLI’s offline dry-run facility. Assemble the final model selection, response schema and generation bounds against the pinned binary’s schema. The CLI accepts customization through a JSON request body, but duplicate keys between flags and that body fail with exit status 2. Inspect the resolved request before adding settings that the command may already supply. Sources: Google AI for Developers
gemini-api analyze \
-i ./fixtures/product-brief.txt \
"Extract unresolved questions, their explicitly stated owners, and supporting evidence." \
--dry-run -o jsonMake storage policy explicit
The Interactions API stores interactions by default, with retention of 55 days for paid-tier interactions and one day for free-tier interactions. Paid projects can configure shorter retention windows. Disabling storage prevents subsequent continuation from that interaction and is incompatible with background execution. These server-side rules are separate from the client’s independent invocation model. Sources: Google AI for Developers, Google Gemini on GitHub
Command behavior adds another layer: The Git Reporter found that v0.4.4 analysis previews explicitly disabled storage, while image requests omitted that field. The publication said it downloaded and checksum-verified the binary, then ran schema and dry-run checks without credentials or network calls. Inspect the effective storage setting for the pinned analysis request before approving it for the document’s retention requirements. Keep this fixture’s input handling simple: the CLI documents a 14 MB raw inline-input cap, while uploaded files expire after 48 hours. Sources: Google AI for Developers, The Git Reporter
Validate the process, response and analysis separately
Capture stdout, stderr and process exit status separately, preserving the initial live response intact. Establish the analysis response’s structure before choosing a field to extract. The Interactions documentation describes execution steps and a convenient text accessor, but that does not establish the CLI command’s output shape. Avoid a shell pipeline that lets a successful parser hide a failed CLI process. Sources: Google AI for Developers
The table below proposes acceptance tests, not observed results. The Git Reporter’s offline checks found that conflicting inputs produced exit status 2, structured stderr and empty stdout. Those checks did not establish authenticated analysis behavior, including response structure, enforced schema constraints, internal retries, timeouts or remote cancellation. Before production use, test the wrapper with fixtures and controlled failures, then run the bounded job against the service. Sources: The Git Reporter
Table
Proposed output acceptance tests
| Condition | Required wrapper behavior |
|---|---|
| Valid response and analysis | Preserve raw output, validate and publish |
| Exit 0 with empty stdout | Reject missing output |
| Truncated JSON | Reject and retain received bytes |
| Missing fields or wrong types | Reject contract mismatch |
| More than 20 questions | Reject application limit violation |
| Markdown fences around JSON | Reject without silently repairing |
| Evidence absent from input | Reject unsupported evidence |
| No unresolved questions | Accept an empty questions array |
| Unknown response status | Stop with an unsupported-state result |
Include a document that instructs the model to ignore the task, and check whether that content changes the requested analysis. Validate evidence against the input and require explicit support for named owners. Keep raw responses separate from accepted application artifacts. Publish each validated artifact atomically and associate it with the current job, so a failed rerun cannot make an older success look current.
Budget retries around what actually failed
The CLI documents exit status 0 for success and 1 for runtime or API failure. Status 2 covers usage or validation problems; status 3 covers authentication or authorization failure. Network failures, rate limits and API errors share status 1, so that number alone cannot justify a retry. Use structured error details where available, and preserve unrecognized response states instead of guessing what they mean. Sources: Google AI for Developers
- Fail immediately on invalid request settings or credentials.
- Retry an explicit temporary service failure only within the remaining attempt and time budgets.
- Distinguish temporary throttling from exhausted quota before retrying a rate limit.
- Record a lost connection after submission as an unknown outcome.
- Record a CI deadline timeout separately from CLI exit statuses.
- Treat malformed or unsupported analysis as a validation failure.
Account for the client’s internal retries before treating the wrapper’s attempt budget as a request limit. A local timeout record should describe what happened locally, without asserting that remote work stopped or incurred no charge. If a connection disappears after submission, another request may duplicate work. Preserve any remote identifier that could help reconcile the outcome before resubmitting.
Record rerun state and evaluate the integration
Derive an application job key from input bytes, prompt, response schema, explicit model, relevant request settings and CLI version. Use it to find a previously validated artifact, without treating it as an API idempotency mechanism. Persist input and request hashes, configuration, attempts, timestamps, raw output, exit status, validation results and the final artifact hash. Retain an interaction identifier when available, plus any uploaded-file reference and upload time. The table below proposes a separate action for each recorded outcome.
Table
Proposed rerun decisions
| Previous outcome | Next action |
|---|---|
| Validated success with matching job key | Reuse the validated artifact |
| Known failure before submission | Fix the cause, then retry |
| Unknown outcome after submission | Reconcile remotely or explicitly accept duplication risk |
Keep conversation continuation separate from retry tracking. The Interactions API carries conversation history forward, but tools, system instructions and generation configuration must be supplied again. Continuing a conversation can change the context of an intended independent analysis. For expired uploaded inputs, re-upload the same verified content before resubmission. Sources: Google AI for Developers
Evaluate the CLI against a prewritten equivalent SDK request with the same input, model and output contract. Jack Wotherspoon’s reported benchmark compared managed agents using a preinstalled CLI with agents building a Python integration for an image task. That comparison addresses setup overhead, not this file-analysis job’s reliability. Measure first-attempt completion, schema-valid results, evidence accuracy, median and tail latency, attempts and usage. Retain failures in the results, then decide whether the step should inform a developer or block a build. Sources: Thread Navigator