Gemini API CLI
$ gemini-api Official Med Riskgemini-api exposes every Gemini REST resource as a shell command with -o json/toon, in-process --jq filtering, --dry-run, --no-interactive, and --agent-mode. Media (image, tts, music, video) and transcribe write artifacts to disk and print only file paths.
https://github.com/google-gemini/gemini-api-cli/releases Stateless shell client (--agent-mode, --jq, --dry-run) that writes generated media directly to disk and prints paths, keeping large binaries out of LLM context.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Purpose-built for agents: -o json|toon, built-in --jq, --dry-run, --no-interactive, --agent-mode, and file-path-only media output.
- Supports
--agent-mode,--jq,--dry-run,--no-interactive, and-o json
OS keychain storage by default, whoami credential masking, and --dry-run validation; API calls incur Gemini billing and files upload persists media for 48h TTL.
- OS keychain auth +
--dry-runoffline preview; API calls incur billing
Static release binaries via install.sh / GitHub Releases, though lacks Homebrew core or npm/PyPI distribution.
- Installed via official
install.shor GitHub release binaries
Unifies text, image, TTS, music, video, audio/video transcription, Deep Research, and sandboxes in one token-lean CLI.
- Writes media/transcripts to disk and returns paths or compact
--jqJSON
Official google-gemini/gemini-api-cli repository under Apache-2.0.
- Official
google-gemini/gemini-api-clirepository
Rich skill/CLI docs, --help, and --schema, though --schema (~92 KB) must be piped to jq.
- Official docs and
gemini-api-cliagent skill
Security, Auth & Guardrails
Resolves --api-key/--access-token, GEMINI_API_KEY/GEMINI_ACCESS_TOKEN, OS keychain (configure), then ~/.config/gemini-api/config.yaml (--no-keyring).
Apache-2.0 open-source CLI; live Gemini API generation, analysis, and Deep Research bill to your Google AI/Vertex project.
# Gemini API CLI Agent Rules - Check `gemini-api whoami` first because an exported `GEMINI_API_KEY` overrides keychain/config credentials. - Pass `--no-interactive`, `--dry-run`, and `--jq` (or `--page-size 10` on `list`) instead of dumping `--usage` or `--schema` raw.
Agent-Ready Command Recipes
Safe Read-Only Queries
gemini-api whoami -o json
Prints masked active credentials and whether GEMINI_API_KEY or keychain won.
gemini-api generate 'Hello' --dry-run -o json
Validates parameters and prints the redacted HTTP request locally without billing.
Controlled Writes & Previews
gemini-api image 'Isometric cloud architecture icon' --aspect-ratio 16:9 --out ./icon.png -o json
Calls Gemini image generation, writes ./icon.png to disk, and prints JSON metadata.
Strengths for Agents
- + Built-in
--jq,--dry-run,--agent-mode, and--no-interactivedesigned specifically for agent shells. - + Media and transcription commands write binaries locally and emit only compact paths/metadata.
- + Covers text, images, TTS, music, video, transcription, and Deep Research in one CLI.
Caveats & Pitfalls
- ! Exported
GEMINI_API_KEYsilently overrides OS keychain credentials—verify withgemini-api whoami. - ! Do not dump
--schemaor--usageraw withoutjqdue to ~45–92 KB payload sizes.