[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-110128":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":9,"pushedAt":26,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},110128,"gemini-api-cli","google-gemini\u002Fgemini-api-cli","google-gemini","An (experimental) CLI for the Gemini API",null,"https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli","Go",1028,117,8,6,0,5,17,51,70.4,false,"main",[24,25],"gemini","gemini-api","2026-11-20 23:34:38","2026-11-23 20:37:46","# Gemini API CLI (`gemini-api`)\n\n[![Release](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Fgoogle-gemini\u002Fgemini-api-cli)](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Freleases)\n[![License: Apache 2.0](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache_2.0-blue.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n\n**Gemini models and managed agents for the agent you already use.**\n\nGive Codex, Claude Code, Antigravity, OpenClaw, Hermes, or any other agent with shell access the ability to use the Gemini API. Configure an API key, put `gemini-api` on `PATH`, and let your agent choose a model, generate an asset, analyze a file, or launch a managed agent to handle a task.\n\nYour agent plans the work. Gemini provides models and managed agents. This stateless CLI connects them through standard shell commands:\n\n```bash\ngemini-api image \"A friendly robot mascot for a developer tool\" --out .\u002Fassets\u002F\n```\n\nA prompt goes in. An image lands in your project. Your agent gets the file path and keeps building. The same binary can return an analysis, a voiceover, a transcript, or the interaction ID of a background managed-agent run.\n\n[Installation](#installation) · [Quick start](#quick-start) · [Command overview](#command-overview) · [Agent discovery](#agent-discovery-and-machine-interface) · [Workflows](#agent-workflows) · [Gemini API docs](https:\u002F\u002Faistudio.google.com\u002Fdocs)\n\n---\n\n## Why this CLI\n\nA coding agent building an app may need a hero image, a voiceover, a second opinion on a design, or an answer inside a PDF. An assistant may need to turn a recording into captions or delegate multi-step research. Give that agent `gemini-api` and an API key, and it can call those capabilities directly when the task requires them.\n\n- **One binary for models, media, and managed agents:** Access text and reasoning models, multimodal file analysis, image\u002Faudio\u002Fmusic\u002Fvideo generation, and managed agents from the command line.\n- **Delegate long-running work:** Start a Gemini managed agent in the background, keep the returned interaction ID, and retrieve the result when needed.\n- **Self-describing interface:** Commands, flags, request schemas (`--schema`), and machine-readable usage (`--usage`) are built into the binary so an agent can inspect what it needs on the fly.\n- **Safe dry-run validation:** `--dry-run` validates inputs and prints the resolved HTTP request with credentials redacted—without making a network call or reading the OS keychain.\n- **Script- and agent-friendly output:** Stream text, write media directly to disk, emit structured JSON (`--output-format json`) or compact TOON (`--output-format toon`), or filter fields inline with `--jq`.\n- **Stateless execution:** Each invocation runs independently. Your agent supplies the context, chooses the model, and controls the next step.\n\nBuilt for headless use by coding agents and assistant tools, with the same interface available to shell scripts and CI jobs. A single Go binary runs on macOS, Linux, and Windows.\n\n---\n\n## Installation\n\n### macOS and Linux\n\n```bash\ncurl -fsSL https:\u002F\u002Fraw.githubusercontent.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Fmain\u002Fscripts\u002Finstall.sh | bash\n```\n\n### Windows (PowerShell)\n\n```powershell\niwr -useb https:\u002F\u002Fraw.githubusercontent.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Fmain\u002Fscripts\u002Finstall.ps1 | iex\n```\n\n### Go install\n\nInstall the latest release with Go:\n\n```bash\ngo install github.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Fcmd\u002Fgemini-api@latest\n```\n\nTo build the current development version, use `@main` instead of `@latest`. Current `main` requires **Go 1.26.10** or later (Go's automatic toolchain selection downloads the required version if needed).\n\n### Prebuilt binaries\n\nDownload prebuilt archives for macOS, Linux, and Windows from [GitHub Releases](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Freleases) and place `gemini-api` on your `PATH`.\n\n---\n\n## Quick start\n\n### 1. Configure your API key\n\nCreate an API key in Google AI Studio (see the [Gemini API key docs](https:\u002F\u002Faistudio.google.com\u002Fdocs\u002Fapi-key)) and make it available to your shell or your agent's subprocess environment:\n\n```bash\nexport GEMINI_API_KEY=\"YOUR_API_KEY\"\n```\n\n> **Workstation tip:** To persist your key in your OS keychain (macOS Keychain, Linux Secret Service, or Windows Credential Manager) or `~\u002F.config\u002Fgemini-api\u002Fconfig.yaml`, run `gemini-api configure --api-key \"YOUR_API_KEY\"` or open the interactive form with `gemini-api configure --interactive`. Check your active configuration and credential source at any time with `gemini-api whoami`.\n\nVerify your setup locally with `--dry-run` (no network call), then remove `--dry-run` to call the API:\n\n```bash\ngemini-api generate \"Hello from my agent\" --dry-run\ngemini-api generate \"Hello from my agent\"\n```\n\n### 2. Give your agent instructions\n\nAdd the following block to your agent's instructions (`AGENTS.md`, `CLAUDE.md`, `.cursorrules`, or tool configuration):\n\n```text\nYou have access to gemini-api through the shell.\nUse it to call Gemini models, generate or edit media, analyze files, or launch managed agents.\n1. Inspect --help or --usage to choose a command, and --schema when building a --body JSON payload.\n2. Preview API calls with --dry-run (or --dry-run --output-format json).\n3. For discrete JSON output or --jq filtering on streaming commands (generate, agent run, agent status --stream), pass --stream=false --output-format json (--background on agent run returns a single interaction without streaming unless --stream is passed).\n4. Capture returned file paths (from media commands) and interaction IDs (from agent\u002Fmodel runs) to continue multi-step tasks.\n```\n\n### 3. Put your agent to work\n\nPrompt your host agent as usual:\n\n```text\nBuild a landing page for this app. Use Gemini to create a mascot image and a welcome voiceover, and launch a managed research agent to investigate competing products. Incorporate the assets and findings into the page.\n```\n\nYour agent chooses the commands, runs them in its shell, and uses the returned file paths and interaction IDs in its own workflow.\n\n---\n\n## Command overview\n\nRun `gemini-api --help` to see all top-level commands, or `gemini-api \u003Ccommand> --help` for command-specific flags and examples.\n\n| Category | Command | Subcommands \u002F Key Flags | Description & default model |\n|---|---|---|---|\n| **Create** | `gemini-api generate` | `-m`, `-i\u002F--input`, `--stdin`, `--system`, `--stream=false`, `--body` | Text and multimodal generation (`gemini-3.8-flash`) |\n| | `gemini-api image` | `-m`, `-i\u002F--input`, `--stdin`, `--out`, `--body` | Generate or edit images (`gemini-nano-banana-2.1`) |\n| | `gemini-api tts` | `-f\u002F--file`, `--stdin`, `--voice`, `--multi-speaker`, `--out` | Text-to-speech audio generation (`gemini-3.8-flash-tts`) |\n| | `gemini-api music` | `-m`, `-f\u002F--file`, `--stdin`, `--out`, `--body` | Music generation (`lyria-3.5`) |\n| | `gemini-api video` | `-m`, `-i\u002F--input`, `--stdin`, `--async`, `--out`, `--body` | Conversational video generation and editing (`gemini-omni-1.1-flash`) |\n| **Understand** | `gemini-api analyze` | `-i\u002F--input` *(repeatable)*, `--stdin`, `--system`, `-m` | Ask questions about PDFs, images, audio, video, CSV\u002Ftext files, or YouTube URLs (`gemini-3.8-flash`) |\n| | `gemini-api transcribe` | `-i\u002F--input` *(repeatable)*, `--format` (`md`, `text`, `json`, `srt`), `--out` | Transcribe audio or video to Markdown (`md`), plain text (`text`), JSON (`json`), or SRT captions (`srt`) (`gemini-3.5-transcribe`) |\n| **Manage** | `gemini-api agent` | `run`, `status`, `cancel`, `delete-interaction`, `create`, `list`, `get`, `delete` | Run interactions with models or managed agents (`run`, `status`, `cancel`) and manage agent definitions |\n| | `gemini-api files` | `upload`, `list`, `get`, `generated-files-list`, `register`, `delete` | Upload, list, inspect, register, and delete files via the Files API (48-hour retention) |\n| | `gemini-api models` | *(bare catalog)*, `list` (`--all`), `get` | View the offline model catalog, or query live API models (`list`, `get`) |\n| | `gemini-api configure` | `--api-key`, `--interactive`, `--output-format` | Configure authentication, global parameters, and persistent preferences |\n| | `gemini-api auth` \u002F `whoami` | `auth login`, `auth whoami`, `auth logout` | Manage stored credentials (`auth`) or inspect active authentication and configuration (`whoami`) |\n| **Advanced** | `gemini-api environments` | `create`, `list`, `get`, `delete`, `files` (`list`, `upload`, `download`) | Manage sandbox environments and upload, list, or download environment files |\n| | `gemini-api credentials` | `create`, `list`, `get`, `update`, `delete` | Manage stored server-side credentials for managed agents |\n| | `gemini-api webhooks` | `create`, `list`, `get`, `update`, `ping`, `rotate-signing-secret`, `delete` | Manage webhook endpoints and signing secrets for event delivery |\n| | `gemini-api triggers` | `list`, `get`, `update`, `run`, `list-executions`, `delete` | Inspect, run, update, and delete cron triggers for managed agents |\n| **Utility** | `gemini-api explore` \u002F `version` | — | Launch the interactive command explorer (`explore`) or print the CLI version (`version`) |\n\n---\n\n## Agent discovery and machine interface\n\nEverything an agent needs to use `gemini-api` is discoverable from the binary itself, without external documentation or credentials:\n\n| When an agent needs to… | It runs… |\n|---|---|\n| Discover commands and flags | `gemini-api --help` or `gemini-api --usage` |\n| Inspect a request body schema | `gemini-api agent run --schema` |\n| Validate and preview a call offline | `gemini-api image \"A robot mascot\" --dry-run` |\n| Parse a complete structured response | `gemini-api generate \"Hello\" --stream=false --output-format json` |\n| Extract a single field inline | `gemini-api agent list --jq '.agents[].id'` |\n\n- **`--usage`** outputs the complete command tree, flags, defaults, environment variables, and config keys as machine-readable [KDL](https:\u002F\u002Fkdl.dev).\n- **`--schema`** prints the bundled JSON Schema (draft 2020-12) for any command that accepts a request body.\n- **`--dry-run`** validates flags and payloads and previews the HTTP request without credentials or network access (use `--dry-run --output-format json` for machine-parseable JSON request previews).\n- **`--no-interactive`** disables all interactive prompts and TUI forms.\n- **`--agent-mode`** (or `GEMINI_CLI_AGENT_MODE=1`) enables structured JSON error envelopes on `stderr` and defaults `stdout` to compact [TOON](https:\u002F\u002Fgithub.com\u002Ftoon-format\u002Fspec) output (`--output-format json` explicitly selects JSON).\n- **Exit codes** distinguish success (`0`), runtime\u002FAPI failures (`1`), invalid usage\u002Fvalidation errors (`2`), and authentication\u002Fauthorization failures (`3`).\n\nRun `gemini-api --help-global` to see all global authentication, network, output, and diagnostic flags.\n\n---\n\n## Agent workflows\n\n### 1. Generate and edit creative assets\n\nCoding agents like Codex, Claude Code, or Antigravity can generate images, speech, music, and video while building an app:\n\n\u003C!-- readme-examples: skip (needs local file from previous command) -->\n```bash\n# Generate an image and capture the written file path\nMASCOT_PATH=$(gemini-api image \"A friendly robot mascot, soft studio lighting\" --out .\u002Fassets\u002Fmascot.jpg)\n\n# Edit an existing image with -i \u002F --input\ngemini-api image \"Add a winter scarf and snowy background\" -i \"$MASCOT_PATH\" --out .\u002Fassets\u002Fmascot-winter.jpg\n\n# Generate single-speaker or multi-speaker voiceovers\ngemini-api tts \"Welcome. Let's build something together.\" --out .\u002Fassets\u002Fwelcome.wav\ngemini-api tts \"Alice: Welcome to the demo! Bob: Let's dive right in.\" \\\n  --multi-speaker \"Alice=Kore,Bob=Puck\" \\\n  --out .\u002Fassets\u002Fdialogue.wav\n\n# Generate background music and video\ngemini-api music \"Warm ambient music for a product walkthrough\" --out .\u002Fassets\u002F\ngemini-api video \"A slow camera move through a sunlit workshop\" --out .\u002Fassets\u002F\n```\n\nMedia commands write files locally and print only the written file path to `stdout`. When `--out` points to a directory (or is omitted), the CLI names the file automatically using the file extension that matches the API's returned MIME type (for example, `.jpg` for `image\u002Fjpeg`, `.wav` for `audio\u002Fwav`, `.mp3` for `audio\u002Fmpeg`, and `.mp4` for `video\u002Fmp4`).\n\n### 2. Analyze documents and transcribe recordings\n\nAssistants like OpenClaw or Hermes can turn documents, media files, and YouTube URLs into answers and deliverables:\n\n\u003C!-- readme-examples: skip (needs local files) -->\n```bash\n# Analyze a PDF or compare multiple images\ngemini-api analyze --input product-brief.pdf \"What should we build first, and why?\" > plan.md\ngemini-api analyze --input before.png --input after.png \"Summarize the visual design changes\"\n\n# Transcribe audio or video (valid formats: md, text, json, srt)\ngemini-api transcribe --input interview.mp4 --format srt --out interview.srt\n```\n\nFor larger media files (over ~14 MB raw \u002F 20 MB base64-encoded), upload once with `files upload --wait` and reuse the returned `files\u002F\u003Cid>` URI across `analyze`, `transcribe`, `generate`, `image`, `video`, or `agent run`:\n\n\u003C!-- readme-examples: skip (needs local file and uploaded file URI) -->\n```bash\nFILE_URI=$(gemini-api files upload interview.mp4 --wait --output-format json --jq '.name')\ngemini-api analyze --input \"$FILE_URI\" \"List the key action items with timestamps\"\n```\n\n### 3. Launch and poll a background managed agent\n\nDelegate multi-step research or coding tasks to a Gemini managed agent such as Deep Research. Pass `--background` so the CLI returns a single interaction (no stream, unless `--stream` is passed) with the interaction ID immediately instead of holding open an SSE stream:\n\n```bash\nINTERACTION_ID=$(gemini-api agent run \"Research battery recycling approaches and cite sources\" \\\n  --agent deep-research-preview-04-2026 \\\n  --background \\\n  --jq '.id')\necho \"Started interaction: $INTERACTION_ID\"\n```\n\nCheck progress or retrieve the finished output using the returned `INTERACTION_ID`:\n\n```bash\ngemini-api agent status \"$INTERACTION_ID\" --stream=false --output-format json\n```\n\nYou can also stream live progress events (`gemini-api agent status \"$INTERACTION_ID\" --stream`) or cancel an active run (`gemini-api agent cancel \"$INTERACTION_ID\"`).\n\n### 4. Choose the right model\n\nUse `--model` (`-m`) on generation and analysis commands to pick a model for reasoning, fast text, multimodal understanding, or media generation:\n\n```bash\n# View the curated offline model catalog grouped by capability\ngemini-api models\n\n# Query all live models available to your API key (--all auto-paginates across pages)\ngemini-api models list --all\ngemini-api models get gemini-3.8-flash\n\n# Run a prompt with a specific model\ngemini-api generate \"Review this approach: cache immutable responses by content hash\" --model gemini-3.8-flash\n```\n\n---\n\n## Go deeper: custom request bodies (`--schema` to `--body`)\n\nShort flags cover common tasks; `--body` gives your agent full access to the underlying Interactions API request schema while keeping the CLI's file output and error handling.\n\nFirst, inspect the schema for `image`:\n\n```bash\ngemini-api image --schema > image-schema.json\n```\n\nNext, create `hero-image.json` to select `gemini-nano-banana-2.1`, request a `16:9` image at `2K` size (`image_size`: `\"512\"`, `\"1K\"`, `\"2K\"`, or `\"4K\"`), and disable server-side interaction storage (`\"store\": false`):\n\n```bash\ncat > hero-image.json \u003C\u003C'JSON'\n{\n  \"model\": \"gemini-nano-banana-2.1\",\n  \"input\": \"A friendly robot mascot in a sunlit workshop, composed on the right with uncluttered space on the left for a landing page headline. No text or watermark.\",\n  \"response_format\": {\n    \"type\": \"image\",\n    \"aspect_ratio\": \"16:9\",\n    \"image_size\": \"2K\"\n  },\n  \"store\": false,\n  \"stream\": false\n}\nJSON\n```\n\nPreview the exact HTTP payload with `--dry-run`, then execute the request:\n\n\u003C!-- readme-examples: skip (needs local hero-image.json file) -->\n```bash\ngemini-api image --body @hero-image.json --out .\u002Fassets\u002Fhero.jpg --dry-run --output-format json\ngemini-api image --body @hero-image.json --out .\u002Fassets\u002Fhero.jpg --output-format json\n```\n\nWith `--output-format json`, the CLI writes the image to disk and returns structured artifact metadata on `stdout`:\n\n```json\n{\n  \"kind\": \"image\",\n  \"mime_type\": \"image\u002Fjpeg\",\n  \"path\": \"\u002Fpath\u002Fto\u002Fproject\u002Fassets\u002Fhero.jpg\",\n  \"size_bytes\": 2914159,\n  \"status\": \"completed\"\n}\n```\n\n`--out` controls the local file destination; `response_format` controls what the model generates (pass `--raw-response` instead of `--out` if you want the full raw API response envelope). The same `--schema` to `--body` workflow applies to `gemini-api agent run` and other commands when configuring `system_instruction`, `tools`, structured JSON `response_format.schema`, or stateful multi-turn continuations via `previous_interaction_id`:\n\n\u003C!-- readme-examples: skip (uses shell variable from previous turn) -->\n```bash\n# Turn 1: Run a non-streaming interaction and capture its ID\nTURN1_ID=$(gemini-api generate \"Propose 3 database indexing strategies for a time-series log table.\" \\\n  --stream=false --jq '.id')\n\n# Turn 2: Continue the conversation using previous_interaction_id\ngemini-api agent run \"Compare strategy #2 and #3 for write-heavy workloads.\" \\\n  --body \"{\\\"previous_interaction_id\\\": \\\"$TURN1_ID\\\"}\" \\\n  --stream=false\n```\n\nThe CLI stores no local conversation state—server-side interactions and uploaded files manage their own retention on the API, and your workflow keeps only the IDs it wants to reuse.\n\n---\n\n## Status, feedback, and contributions\n\n> [!NOTE]\n> `gemini-api` is in **beta** and evolving alongside the [Gemini Interactions API](https:\u002F\u002Faistudio.google.com\u002Fdocs\u002Finteractions-overview). Breaking changes may occur between releases; we recommend pinning to a specific [release version](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Freleases) in CI and automated workflows.\n\n- **Feedback & bug reports:** Try `gemini-api` in your agent workflow and let us know where it helps or where it gets in the way by opening an issue in [GitHub Issues](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Fissues).\n- **Contributions:** We are **not** accepting open source contributions (pull requests) at this time.\n- **Releases:** Browse changelog notes and prebuilt binaries on [GitHub Releases](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-api-cli\u002Freleases).\n\n---\n\n## Licensing & Disclaimer\n\nCopyright 2026 Google LLC\n\nAll software is licensed under the Apache License, Version 2.0 (Apache 2.0); you may not use this file except in compliance with the Apache 2.0 license. You may obtain a copy of the Apache 2.0 license at: https:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nAll other materials are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). You may obtain a copy of the CC-BY license at: https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby\u002F4.0\u002Flegalcode.\n","这是一个为 Google Gemini API 提供命令行接口（CLI）的轻量级工具，专为自动化场景设计。它支持调用 Gemini 的文本生成、多模态文件分析（如 PDF\u002F图像\u002F音频）、图像\u002F语音\u002F视频生成，以及后台托管代理（managed agent）任务；具备状态无关、结构化输出（JSON\u002FTOON）、dry-run 验证、自描述接口等特性。适用于集成到编程助手、AI 代理工作流、CI\u002FCD 脚本或 Shell 自动化中，帮助非交互式环境按需调用 Gemini 能力。",2,"2026-11-24 04:38:10","trending"]