google-gemini/gemini-api-cli
A stateless Go CLI for Gemini models, media, and managed agents via the shell
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
gemini-api is a stateless Go client, not an agent orchestrator. A host agent or script starts a subprocess, supplies the context and model choice, and decides what to do with the result. For supported operations, the CLI turns flags or a --body payload into an HTTP request to the Gemini Interactions API. It can stream responses, write media to disk, or return an interaction ID that the caller keeps for a later invocation.
The installable command lives at cmd/gemini-api, with implementation under internal/. The manifest includes Cobra and pflag for command handling, Bubble Tea and Bubbles for terminal UI, gojq for filtering, and go-keyring for credential storage. The extension surface is the shell and the underlying request schema, not a documented MCP server or in-process plugin API. Managed-agent progress can stream over SSE; the caller still owns orchestration across invocations.
Key Capabilities & Differentiators
In v0.5.1, generate and analyze default to gemini-4-neon. Analysis accepts PDFs, images, audio, video, CSV or text files, and YouTube URLs. The media commands cover image generation and editing, single- or multi-speaker TTS, music, and video. transcribe exports Markdown, plain text, JSON, or SRT captions. The curated models catalog works offline, while models list --all queries and paginates the live catalog available to the configured key.
For automation, --usage exposes the CLI contract in KDL, and --schema describes bodies accepted through --body. --dry-run validates locally and previews the resolved request without network or keychain access. Use --stream=false --output-format json when a downstream step needs one complete response rather than streamed events. For media above roughly 14 MB raw or 20 MB base64-encoded, upload once with files upload --wait and reuse the returned URI within the Files API's 48-hour retention window.
Trade-offs & Limitations
Compared with a direct Gemini API integration, the CLI saves glue code for one-off requests, artifact output, and shell pipelines. The trade-off is a subprocess boundary: the host must manage process lifecycle, parse output, retain interaction IDs, and handle retries where appropriate. A direct client is a better fit when a long-lived service needs in-process request control or typed interfaces. This CLI complements a coding agent rather than replacing its planner or repository tooling.
Dry-run validation catches local request problems but cannot establish that a model is available to the key or that the service will accept the request. Live calls remain subject to network reliability, model availability, quotas, and API charges. Stateless execution also says nothing about server-side retention: review interaction storage settings and the Files API lifecycle separately. The Apache-2.0 license covers the client, not the hosted service, and the project accepts issue reports but not pull requests.
Hardware & Deployment Guide
Deploy a single binary on macOS, Linux, or Windows. Put a prebuilt release on PATH or install from cmd/gemini-api with go install; building current main requires Go 1.26.10 or later. Pass GEMINI_API_KEY through the subprocess environment for headless use, or configure a workstation via the OS keychain or YAML. Use --no-interactive in CI to prevent prompts. Request previews and the curated catalog work offline, but live model calls require network access and API credentials.
No local GPU, CUDA stack, or model weights are needed. Budget local resources for file handling, disk space, network transfers, and concurrent processes. The v0.5.1 release makes gemini-4-neon the default and introduces a common StreamClient interface in envruntime; v0.5.0 adds text_normalization to SpeechConfig. For reproducible automation, pin the CLI release and select models explicitly rather than depending on moving defaults.
--usage emits KDL with the command tree, defaults, environment variables, and config keys; --schema emits bundled JSON Schema draft 2020-12.--dry-run validates flags and bodies and previews the resolved HTTP request with credentials redacted, without network or OS keychain access.--jq filtering, and agent-mode JSON errors on stderr; exit codes distinguish usage, auth, and runtime/API failures.agent run --background returns an interaction ID for later polling, SSE progress streaming, or cancellation.files upload --wait returns a files/ reference that can be reused across compatible commands; Files API uploads have a 48-hour retention window.Teams extending an existing shell-capable agent or CI job with document analysis, media generation, transcription, or background Gemini tasks.
Inference must stay offline or on-premises, you require a native MCP server, or the application needs a long-lived, typed API integration rather than subprocess calls.
Quick Start & Installation
curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| gemini-api-cli ★ | 4.9k | +613 | Go | Apache-2.0 | A stateless Go CLI for Gemini models, media, and managed agents via the shell |
| headroom | 81.5k | +455 | Python | Apache-2.0 | Local context compression for LLMs via a Python library, proxy, and MCP server |
| gemini-cli | 109.6k | +376 | TypeScript | Apache-2.0 | A Node.js terminal agent for enterprise Gemini coding workflows and MCP tools |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/google-gemini/gemini-api-cli.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about gemini-api-cli
How should a coding agent integrate with the CLI?
gemini-api as a subprocess. It can discover commands with --usage, inspect request bodies with --schema, and validate a call locally with --dry-run. For a single JSON response from a streaming command, use --stream=false --output-format json; for background managed-agent runs, persist the interaction ID and query agent status later. No MCP server is required for this integration.Does it need a GPU, and what drives local resource usage?
Can we use it commercially or self-host it for compliance?
When is a direct API client or a coding agent a better choice?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy