Reference guide for the Gemini Command Line Interface - generate code, text, and images generation directly from the terminal.
Start Using CLIInstall the Gemini cli using your package manager or download standalone binaries. Supports Windows, macOS, and Linux distributions.
{`# Linux/macOS curl -fsSL https://cli.gemini.com/install.sh | sh source ~/.bashrc`}
{`# Windows (PowerShell) iwr https://cli.gemini.com/win.zip -O gemini.zip Expand-Archive gemini.zip -DestinationPath .`}
{`# Docker docker run -it --volume .:/app gemini`}
{`# After visiting developer console and getting an API key: gemini config set api_key "your_api_key_here" # or set environment variable export GEMINI_API_key="your_api_key"`
The CLI will automatically use the API key from either environment variables or the config file.
{`$ gemini code "Create a Python function to reverse a string" Output saved to: /output/reverse_string.py # Generated content: def reverse_string(s): return s[::-1]`}
Generate production-ready code from natural language prompts with optional syntax highlighting and formatting.
{`$ gemini write "Explain quantum computing to a child" Saved to: blog/post.md # Generated content: Imagine quantum computing is like a magic box that can solve puzzles...`}
Generate blog posts, explanations, documentation, or any text content in 100+ languages.
{`$ gemini image "Cyberpunk city neon lights, 8K resolution" Saved to: images/cyberpunk.jpg # Image with ID: ai_image_783921`}
Create images based on text descriptions with options for resolution, style, and media format.
{`gemini code "Web app with CRUD" | gemini doc | gemini test`}
Combine commands in a pipeline to create code, documentation, and tests in one workflow.
{`$ gemini chat > Create a logo design for a tech startup > Add dark mode to the website > Explain the business model`}
Use the interactive chat mode for multi-turn conversations with your project.
Option | Description |
---|---|
-c, --config <PATH> | Custom config file path |
-v, --version | Display CLI version (1.4.3) |
-h, --help | Show command help |
{`$ gemini code "fastapi CRUD app with JWT auth"
File created: main.py
File created: requirements.txt
$ pip install -r requirements.txt
$ uvicorn main:app --reload`}
{`$ gemini image "Infographic: Climate Change Facts" --style modern
Image with ID: infographic_23150
Open in viewer: https://view.gemini.com/infographic_23150`}
{`$ gemini write "Summarize this research paper" < paper.pdf > summary.md
Summary saved to: summary.md
File size: 1.2 MB`}
{`$ cat error.log | gemini debug
Proposeded fix saved to: fix.patch
Apply with: patch -p0 < fix.patch`}
The cli uses a $HOME/.gemini/config.yml file by default. Here are some common entries:
{`api_key: your_key_here
default_language: python
output_dir: ~/projects
cache: true
verbose: false`}
$ gemini config
$ gemini config edit
$ gemini config env > env_vars.sh
Execute complex tasks from your terminal with natural language commands. Create, analyze, and innovate at the speed of thought.
Try CLI Commands