Gemini

CLI Tutorials

Learn to use the Gemini CLI to generate code, create images, and manage AI tasks from your terminal.

Get Started

Install the CLI

Linux/macOS

{`curl -fsSL https://cli.gemini.com/install.sh | sh
source ~/.bashrc`}

Windows

{`iex (New-Object Net.WebClient).DownloadString('https://cli.gemini.com/install.ps1')`}

Docker

{`docker run -v $PWD:/app -w /app \\
  -e GEMINI_API_KEY="your_api_key_here" \\
  google/gemini-cli:latest`}
            

Configure Your CLI

Set API Key

{`gemini config set api_key YOUR_API_KEY_HERE`}

Environment Setup

For Linux/macOS:

{`export GEMINI_API_KEY="your_api_key"`

Common CLI Examples

Code Generation

{`gemini code \\
  --prompt "Create a Python API wrapper for Gemini" \\
  --output file.py`}
          

Image Synthesis

{`gemini image \\
  --prompt "Cyberpunk skyline at night" \\
  --output cyberpunk_skylines/city.jpg`}
          

Code Debugging

{`gemini debug \\
  --file broken_code.py \\
  --output fixed_code.py`}
          

Text Summarization

{`gemini summarize \\
  --content "Paste your long article here..." \\
  --output summary.txt`}
          

Pro Tips

Batch Processing

{`gemini batch process \\ *.py \\ --output docs/`}

Process multiple files at once with intelligent batch processing

Watch Mode

{`gemini watch \\ --watch folder/ \\ --output output/`}

Automatically regenerate content when source files change

API Mode

{`gemini api \\ --model gemini-pro \\ --prompt "Explain quantum computing" > response.json`}

Full control over model parameters and input/output formats

Try the CLI Now

Get started with our command line interface to automate AI tasks, generate content, and optimize your workflow.

Create API Key