
Gemini Api Cli
- 12 installs
- 38 repo stars
- Updated July 28, 2026
- google-gemini/gemini-api-cli
gemini-api-cli skill documents Guide for using the Gemini API CLI tool.
About
gemini-api-cli skill documents Guide for using the Gemini API CLI tool. Use when you need to interact with the Gemini API via the command line, manage agents, or generate media (images, audio).. name: gemini-api-cli description: Guide for using the Gemini API CLI tool. Use when you need to interact with the Gemini API via the command line, manage agents, or generate media (images, audio).
- Guide for using the Gemini API CLI tool.
- Platform-specific setup patterns for gemini-api-cli.
- Evidence-backed steps from upstream SKILL.md.
- When-to-use criteria for gemini-api-cli versus alternatives.
Gemini Api Cli by the numbers
- 12 all-time installs (skills.sh)
- Ranked #11,618 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
gemini-api-cli capabilities & compatibility
- Capabilities
- gemini api cli quick start · gemini api cli when to use guidance · gemini api cli integration patterns
- Use cases
- api development
What gemini-api-cli says it does
This skill provides guidance on using the `gemini-api` command-line interface.
The `gemini-api` CLI allows you to:
npx skills add https://github.com/google-gemini/gemini-api-cli --skill gemini-api-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 12 |
|---|---|
| repo stars | ★ 38 |
| Last updated | July 28, 2026 |
| Repository | google-gemini/gemini-api-cli ↗ |
How do I use gemini-api-cli correctly?
Guide for using the Gemini API CLI tool. Use when you need to interact with the Gemini API via the command line, manage agents, or generate media (images, audio).
Who is it for?
Teams implementing gemini-api-cli workflows from the catalog.
Skip if: Skip when requirements clearly match a different specialized stack.
When should I use this skill?
User asks about gemini-api-cli, guide for using the gemini api cli tool. use when you need to interact with the gemini api.
What you get
Working gemini-api-cli setup with validated configuration and next steps.
Files
Gemini API CLI Skill
This skill provides guidance on using the gemini-api command-line interface.
Overview
The gemini-api CLI allows you to:
- Run prompts against various Gemini models.
- Manage the full lifecycle of Gemini Agents.
- Generate and edit media (images, audio, TTS).
References
For detailed usage and examples, see the following references:
- Normal Model Calls: See references/model_calls.md for text generation, multi-turn conversations, and tool usage.
- Agents (Lifecycle): See references/agents.md for creating, testing, and managing agents.
- Agent Calls: See references/agent_calls.md for invoking antigravity-preview-05-2026 and Deep Research agents.
- Genmedia: See references/genmedia.md for image generation, image editing, and text-to-speech.
Basic Usage
The primary command is gemini-api run.
gemini-api run "Hello, who are you?"Always ensure your GEMINI_API_KEY environment variable is set.
Global Flags & Features
The CLI supports several flags that are useful for debugging and automation:
Dry Run (--dry-run)
Prints the equivalent curl command and exits without making an API call. Useful for verifying what request would be sent.
gemini-api run "Hello" --dry-runHelp (--help)
Displays usage information and available flags for any command.
gemini-api --help
gemini-api run --helpJSON Output (--json)
Outputs raw SSE events as JSONL (one event per line), useful for machine parsing.
gemini-api run "Hello" --jsonVerbose (--verbose / -v)
Outputs complete JSON step objects line-by-line as they finish. Recommended for programmatic parsing by calling agents.
gemini-api run "Hello" --verboseAgent Calls
This reference covers how to interact with Gemini Agents using the gemini-api run command.
antigravity-preview-05-2026 (Custom Agents)
When you create a custom agent (which defaults to using antigravity-preview-05-2026 as the base agent), you interact with it using the --agent flag followed by the agent ID.
gemini-api run "Analyze this dataset for trends" --agent my-custom-agentIf the agent requires files in its workspace, ensure they are provided or already uploaded.
Passing Environment Sources
When using --agent antigravity-preview-05-2026 (or a custom agent based on it), you can pass environment sources using the --source flag. This allows you to seed files or clone repositories into the agent's environment. Custom sources override the default auto-enabled environment.
gemini-api run "Generate a video" \
--agent antigravity-preview-05-2026 \
--source "inline:/.agents/README.md:# Instructions" \
--source "github:https://github.com/user/repo:/.agents"Supported source types:
inline:<target>:<content>: Creates a file with the specified content.github:<url>:<target>: Clones a GitHub repository to the target path.gcs:<source>:<target>: Copies files from Google Cloud Storage to the target path.
Deep Research
Deep Research is a specialized agent designed for long-running, complex research tasks. You can invoke it using the specific agent ID listed in the models/agents table.
Invoke the latest Deep Research agent:
gemini-api run "Research the latest developments in room-temperature superconductors" \
--agent deep-research-preview-04-2026Invoke Deep Research Max (for more extensive research):
gemini-api run "Provide a comprehensive analysis of the global semiconductor supply chain" \
--agent deep-research-max-preview-04-2026[!NOTE]
Deep Research queries often take longer to complete and may involve multiple steps and tool usage (like web search) automatically.
Gemini Agents
This reference covers managing the lifecycle of Gemini Agents using the CLI.
Scaffolding a New Agent
Create a new agent project directory:
gemini-api agents init my-agentThis creates a directory with the default structure.
Agent Directory Structure
my-agent/
├── agent.yaml # Configuration (ID, tools, etc.) — not inlined
├── AGENTS.md # System instructions (inlined to /.agents/AGENTS.md)
├── skills/ # Custom skills (all files inlined recursively)
└── workspace/ # Files seeded into remote environment (all files inlined recursively)Note: OnlyAGENTS.md,workspace/, andskills/are inlined from the agent directory. All other root-level files and directories (e.g.,README.md,package.json) are ignored duringagents testandagents create.
Adding Skills
To add a skill to your agent, place the skill files (e.g., SKILL.md, references/) in the skills/ directory of your agent project. The agent will have access to these skills when running in its environment.
Agent Configuration (agent.yaml)
Required fields:
id: Agent identifierbase_agent: Base model (Supported only:antigravity-preview-05-2026)
Optional fields:
description: Description of the agentsystem_instruction: Short system instruction (preferAGENTS.mdfor long instructions)tools: List of tools (e.g.,code_execution,google_search)environment:"remote", a base environment ID, or a structured config object to configure sources, network allowlists, and secrets injection:
environment:
type: "remote"
sources:
- type: "gcs"
source: "gs://my-bucket/folder/"
target: ".agents/workspace"
network:
allowlist:
- domain: "api.github.com"
transform:
Authorization: "Bearer your-github-token"
- domain: "*" # Catch-allTesting an Agent Locally
You can test your agent configuration locally before creating it on the platform:
cd my-agent
gemini-api agents test --prompt "Hello, what are your instructions?"Or specify the path:
gemini-api agents test --prompt "Hello" --path ./my-agentCreating/Deploying an Agent
Deploy the agent to the platform:
cd my-agent
gemini-api agents createThis will output the agent ID and environment ID.
Running an Interaction with an Agent
Once created, you can run prompts against the agent:
gemini-api run "Analyze my data" --agent my-agentListing Agents
List all agents you have created:
gemini-api agents listUse --json for machine-readable output:
gemini-api agents list --jsonDeleting an Agent
Delete an agent from the platform:
gemini-api agents delete my-agentUse --force to skip confirmation:
gemini-api agents delete my-agent --forceDownloading Files from Agent Environment
You can download all files from an agent's environment (e.g., generated data, logs) as a snapshot:
gemini-api files download <env-id>Specify an output directory:
gemini-api files download <env-id> --output ./resultsHandling Long-Running Tests
Tests initiated via agents test can take multiple minutes to complete.
- Do Not Interrupt: Be patient and allow the command to run.
- Streaming: Streaming is enabled by default. The CLI will stream output live.
Best Practices
- Always check that the current directory contains
agent.yamlbefore running local commands. - Use
--dry-runto see what the CLI would do without executing. - Prefer
AGENTS.mdfor detailed instructions rather than putting them all inagent.yaml'ssystem_instruction.
Genmedia (Image, Audio, TTS)
This reference covers generating and editing media using the Gemini API CLI.
Image Generation
To generate an image, use a model that supports image generation and specify an output file with --output or -o.
gemini-api run "A cat in space, oil painting" --model gemini-3.1-flash-image --output cat.pngSupported image models include:
gemini-3-pro-image(Nano Banana Pro)gemini-3.1-flash-image(Nano Banana 2)gemini-2.5-flash-image
Image Editing
You can edit an existing image by providing it as input and describing the changes:
gemini-api run "Add a red hat to the person" \
--input image:person.jpg \
--response-modality image \
--output with_hat.jpgText-to-Speech (TTS)
To generate audio from text, use a TTS model and specify an audio output file:
gemini-api run "Hello, I can help you with a wide range of tasks." \
--model gemini-3.1-flash-tts-preview \
--voice Kore \
--output hello.wavSupported TTS models:
gemini-3.1-flash-tts-previewgemini-2.5-flash-preview-ttsgemini-2.5-pro-preview-tts
Music Generation (Lyria)
The CLI supports Lyria models for music generation, although specific command examples are minimal. You would typically use the run command with a Lyria model and an appropriate output extension (e.g., .wav or .mp3).
Supported Lyria models:
lyria-3-clip-preview(Music clips)lyria-3-pro-preview(Full-song generation)
Example (inferred usage):
gemini-api run "A happy upbeat electronic track" --model lyria-3-pro-preview --output song.wavNormal Model Calls
This reference covers standard interactions with Gemini models using the gemini-api CLI.
Basic Prompting
Run a simple prompt against the default model (gemini-3.5-flash):
gemini-api run "What is the capital of France?"Specifying a Model
Use the --model or -m flag to specify a different model:
gemini-api run "Explain quantum computing" --model gemini-3.1-pro-previewCommon models:
gemini-3.5-flash(default)gemini-3.1-pro-previewgemini-3.1-flash-lite
Multi-Turn Conversations
To continue a conversation, use the --previous-interaction-id or -p flag with the ID returned from the previous command.
# First turn
gemini-api run "Remember the word: banana"
# Output will include: interaction_id: v1_...
# Second turn
gemini-api run "What word did I tell you to remember?" --previous-interaction-id v1_...Using Tools
You can enable tools like Google Search or Code Execution:
gemini-api run "What is the current weather in Tokyo?" --tool google_search
gemini-api run "Calculate the 100th Fibonacci number" --tool code_executionYou can repeat the --tool flag to enable multiple tools:
gemini-api run "Research and analyze the latest AI trends" --tool google_search --tool code_executionMultimodal Input
Pass files as input using the --input or -i flag:
gemini-api run "Describe this image" --input image:path/to/photo.jpg
gemini-api run "Summarize this document" --input document:path/to/report.pdfRelated skills
FAQ
What does gemini-api-cli do?
gemini-api-cli skill documents Guide for using the Gemini API CLI tool.
When should I use gemini-api-cli?
User asks about gemini-api-cli, guide for using the gemini api cli tool. use when you need to interact with the gemini api.
Is this skill safe to install?
Review the Security Audits panel on this page before installing in production.