| name | gemini-cli |
| description | Generate images and text using Google Gemini API via CLI - image, text, models. Use when user mentions 'generate image', 'create image', 'Gemini image', 'Nano Banana', 'Imagen', 'AI image generation', 'image editing', 'describe image', 'text generation with Gemini', or wants to create/edit/analyze images using the Google Gemini API. Supports Nano Banana, Nano Banana Pro, Nano Banana 2, and Imagen 4 models. |
| category | devtools |
gemini-cli
When To Use This Skill
Use the gemini-cli skill when you need to:
- Generate images from text prompts (Gemini native or Imagen models)
- Edit existing images with AI (change colors, remove backgrounds, add elements)
- Describe or analyze images using Gemini vision
- Generate text with Gemini models (with optional file inputs)
- List available Gemini/Imagen models and their capabilities
Setup
If gemini-cli is not found, install and build it:
bun --version || curl -fsSL https://bun.sh/install | bash
npx api2cli bundle gemini
npx api2cli link gemini
api2cli link adds ~/.local/bin to PATH automatically.
Always use --json flag when calling commands programmatically.
Working Rules
- Always use
--json for agent-driven calls so downstream steps can parse the result.
- Start with
--help if the exact action or flags are unclear instead of guessing.
- Image generation can take 30-120 seconds depending on model and complexity.
- Output images are saved to
./out/ by default. Use --out <path> for a specific file.
Authentication
gemini-cli auth set "your-google-api-key"
gemini-cli auth test
Auth commands: auth set <token>, auth show, auth remove, auth test
Token is stored in ~/.config/tokens/gemini-cli.txt.
Resources
image
| Command | Description |
|---|
gemini-cli image generate --prompt "A cat in space" --json | Generate image with default model (gemini-2.5-flash-image) |
gemini-cli image generate --prompt "Logo design" --model gemini-3-pro-image-preview --aspect-ratio 1:1 --json | Generate with Nano Banana Pro |
gemini-cli image generate --prompt "Landscape" --model gemini-3.1-flash-image-preview --image-size 2K --json | Generate with Nano Banana 2, 2K size |
gemini-cli image generate --prompt "Photo" --model imagen-4.0-generate-001 --sample-count 4 --json | Generate 4 images with Imagen 4 |
gemini-cli image generate --prompt "Product shot" --images-only --out ./product.png --json | Images only, specific output path |
gemini-cli image generate --prompt "Art" --aspect-ratio 16:9 --image-size 4K --json | Custom aspect ratio and size |
gemini-cli image edit --prompt "Make the sky purple" --input ./photo.jpg --json | Edit an existing image |
gemini-cli image edit --prompt "Remove background" --input ./product.png --out ./clean.png --json | Edit with specific output |
gemini-cli image describe --input ./photo.jpg --json | Describe/analyze an image |
gemini-cli image describe --input ./diagram.png --prompt "What does this show?" --json | Analyze with custom prompt |
gemini-cli image models --json | List available image generation models |
Image generation models:
gemini-2.5-flash-image - Nano Banana (default, fast)
gemini-3-pro-image-preview - Nano Banana Pro (high quality)
gemini-3.1-flash-image-preview - Nano Banana 2 (newest)
imagen-4.0-generate-001 - Imagen 4
imagen-4.0-ultra-generate-001 - Imagen 4 Ultra (highest quality)
imagen-4.0-fast-generate-001 - Imagen 4 Fast
Aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
Image sizes: 512, 1K, 2K, 4K
text
| Command | Description |
|---|
gemini-cli text generate --prompt "Explain X" --json | Generate text with default model |
gemini-cli text generate --prompt "Summarize" --input ./doc.pdf --json | Generate with file input |
gemini-cli text generate --prompt "Analyze" --input ./a.png ./b.jpg --json | Generate with multiple file inputs |
gemini-cli text generate --prompt "Translate" --model gemini-2.5-pro-preview-06-05 --json | Use specific model |
gemini-cli text generate --prompt "Write code" --system "You are a senior engineer" --json | With system instruction |
gemini-cli text generate --prompt "Short answer" --max-tokens 100 --temperature 0.5 --json | With generation config |
gemini-cli text models --json | List available text models |
models
| Command | Description |
|---|
gemini-cli models list --json | List all available Gemini API models |
gemini-cli models list --filter image --json | Filter models by name |
gemini-cli models list --filter imagen --json | List Imagen models only |
gemini-cli models get gemini-2.5-flash-image --json | Get details about a specific model |
Output Format
--json returns a standardized envelope:
{ "ok": true, "data": { ... }, "meta": { "total": 42 } }
Image generation returns:
{ "ok": true, "data": { "model": "...", "prompt": "...", "images": ["./out/123-1.png"], "texts": ["..."] } }
On error: { "ok": false, "error": { "message": "...", "status": 401 } }
Quick Reference
gemini-cli --help
gemini-cli image --help
gemini-cli image generate --help
gemini-cli text generate --help
gemini-cli models list --help
Global Flags
All commands support: --json, --format <text|json|csv|yaml>, --verbose, --no-color, --no-header
Exit codes: 0 = success, 1 = API error, 2 = usage error