Yum News Yum News

Technology  ·  Artificial Intelligence  ·  Developer Insights

Breaking
Gemini Task Automation Guide: India UK Japan Apps ✦   How to Set Up ChatGPT Wallet for Agent Purchases ✦   How to Set Up and Use Gemini Live on Apple CarPlay ✦   How to Set Up Gemini Live on Apple CarPlay ✦   How to Use the Gemini Decisions API for Fast Choices ✦   How to Use Gemini Task Automation on Pixel Phones   ✦   Gemini 3.8 Live launches with native audio dialogue  ✦  Android September Drop adds Find Hub memory  ✦  ML Kit now supports Gemini Nano on-device inference
How to Install and Use the Gemini API CLI for Agents
geminitutorialsai-toolsdeveloperhow-to

How to Install and Use the Gemini API CLI for Agents

Step-by-step guide to install the new Gemini API CLI, generate media from the terminal, analyze files, and integrate with coding agents.

Google released the experimental Gemini API CLI on October 19, 2026. The zero-dependency binary gives developers and coding agents direct access to Gemini models, media generation, and managed agents from the terminal.

Unlike the older Gemini CLI (now superseded by Antigravity CLI for unpaid users), this tool is purpose-built for shell pipelines and autonomous agents. Media commands write files straight to disk and print only the path, so agents stay focused without base64 bloat.

This guide walks through installation, authentication, core commands, and agent integration.

Prerequisites

You need a Gemini API key from Google AI Studio. Create one at aistudio.google.com if you do not have one. The CLI works on macOS, Linux, and Windows. Go 1.26 or later is optional for building from source.

If you already integrate Gemini models in Android apps, the same API key works here. See our guide on adding Gemini 4 Argon to Android with Firebase AI Logic for related setup.

Developer terminal with code and command output

Install the CLI

On macOS and Linux, run the official installer:

curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash

On Windows PowerShell:

iwr -useb https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.ps1 | iex

Alternatively, if you have Go installed:

go install github.com/google-gemini/gemini-api-cli/cmd/gemini-api@latest

Verify the install with gemini-api version. Prebuilt binaries are also available on the GitHub releases page.

Authenticate

Export your API key:

export GEMINI_API_KEY="YOUR_API_KEY"

Or store it persistently:

gemini-api configure --api-key "YOUR_API_KEY"

Check the active configuration:

gemini-api whoami

Test offline without a network call:

gemini-api generate "Hello from the CLI" --dry-run

The dry-run flag validates the request and redacts credentials.

Generate content and media

List available models:

gemini-api models

Generate text:

gemini-api generate "Explain the difference between a REST API and a webhook in two sentences."

Generate an image (writes the file and prints the path):

gemini-api image "Isometric icon of a distributed database" --out ./assets/

Generate video:

gemini-api video "A slow camera move through a sunlit workshop" --out ./assets/

Create multi-speaker TTS:

gemini-api tts "Alice: Deployment succeeded! Bob: Let's ship it." --multi-speaker "Alice=Kore,Bob=Puck" --out ./assets/

Generate music:

gemini-api music "Lo-fi ambient background track for a focus app" --out ./assets/

Analyze a local PDF:

gemini-api analyze -i architecture.pdf "Summarize the key bottlenecks"

Transcribe audio to SRT:

gemini-api transcribe -i earnings_call.mp3 --format srt --out earnings_call.srt

Laptop screen showing code and terminal

Use with coding agents

Any agent with shell access can call the CLI, including Antigravity, Claude Code, Codex, Cursor, and custom loops. The binary is self-describing: agents can inspect commands with --help or --usage, check schemas with --schema, and validate offline with --dry-run.

Add this block to your agent’s instructions file (AGENTS.md, CLAUDE.md, or similar):

You have access to gemini-api through the shell.
Use it to call Gemini models, generate or edit media, analyze files, or launch managed agents.
1. Inspect --help or --usage to choose a command, and --schema when building a --body JSON payload.
2. Preview API calls with --dry-run (or --dry-run --output-format json).
3. For discrete JSON output or --jq filtering on streaming/background commands, pass --stream=false --output-format json.
4. Capture returned file paths and interaction IDs to continue multi-step tasks.

Then prompt the agent: “Build the landing page. Use the gemini-api CLI to generate a hero image and a welcome voiceover.”

For background research, start a managed agent:

INTERACTION_ID=$(gemini-api agent run "Research battery recycling approaches and cite sources" \
  --agent deep-research-preview-04-2026 \
  --background \
  --stream=false \
  --jq '.id')

gemini-api agent status "$INTERACTION_ID" --stream=false --output-format json

Tips for production use

Prefer the typed Google Gen AI SDKs (Python, TypeScript, Go, Java) for application backends. Use the CLI for interactive terminal work, shell scripts, and agent loops.

Media generation commands write files to disk by default. This keeps agent context windows clean. Use --output-format json or --jq when you need structured data.

The current release is experimental (v0.4.x) and evolves alongside the Interactions API. Report issues on the GitHub repository.

Gemini 4 Argon and other frontier models are available through the same API key when your account is on the paid tier. Introductory pricing for Argon runs through November 30, 2026.

Conclusion

The Gemini API CLI turns terminal sessions and coding agents into first-class Gemini clients. Install the binary, set your API key, and start generating media or delegating research without writing throwaway scripts. Check the official announcement and GitHub repository for the latest command surface and feedback.

Sources

  • Google AI Studio: Introducing the Gemini API CLI (October 19, 2026)
  • GitHub: google-gemini/gemini-api-cli README and installation instructions
  • Gemini API documentation for models and Interactions API

Share this story