Generate images using Google Gemini models (Nano Banana 2 / gemini-3-pro-image-preview). Use when the user asks to create, generate, or make an image, picture, photo, or visual from a text description. Also supports image-to-image generation (modify/edit existing images). Supports multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4) and resolutions up to 4K. Triggers on phrases like "generate an image", "create a picture", "make me a photo", "draw", "visualize", "edit this image", "modify this picture", or any request to produce or transform visual content.
Generate images from text descriptions or modify existing images using Google's Gemini models via the Wisdom Gate API.
python scripts/generate_image.py "your prompt here" [--aspect-ratio RATIO] [--size SIZE] [--output PATH]
# Single image
python scripts/generate_image.py "modification prompt" --input input.jpg [--output PATH]
# Multiple images (up to 14)
python scripts/generate_image.py "combine these people in an office photo" --input person1.jpg person2.jpg person3.jpg
# First turn: Generate initial image (auto-selects Nano Banana 2)
python scripts/refine_image.py "Create a vibrant infographic about photosynthesis" --reset
# Second turn: Refine with quality priority
python scripts/refine_image.py "Make it more colorful and add more visual elements" --quality
# Third turn: Further refinement with specific model
python scripts/refine_image.py "Add labels to each component" --model nano-banana-pro
# Start a new conversation with budget model
python scripts/refine_image.py "New prompt here" --reset --model nano-banana
Parameters (generate_image.py):
prompt (required): Text description of the image to generate or modification to apply--input: Input image path(s) for image-to-image generation - supports up to 14 images (optional)--aspect-ratio: Image aspect ratio (text-to-image only) - 1:1 (default), 16:9, 9:16, 21:9, 4:3, 3:4, 5:4, 4:5, 2:3, 3:2, 1:4, 4:1, 1:8, 8:1--size: Image resolution (text-to-image only) - 0.5K, 1K (default), 2K, 4K--output: Output file path (default: generated_image.png)--model: Force specific model - nano-banana, nano-banana-2, nano-banana-pro (auto-select if not specified)--quality: Prioritize quality over cost (uses Nano Banana Pro when possible)Parameters (refine_image.py):
prompt (required): Refinement instruction or initial prompt--history: Conversation history file (default: conversation.json)--output: Output file path (default: refined_image.png)--reset: Reset conversation history and start fresh--model: Force specific model - nano-banana, nano-banana-2, nano-banana-pro (auto-select if not specified)--quality: Prioritize quality over cost (uses Nano Banana Pro)Environment:
WISGATE_KEY environment variableAuthorization: Bearer YOUR_KEY header (modify script if needed)# Basic generation (auto-selects Nano Banana 2 for best balance)
python scripts/generate_image.py "A serene mountain landscape at sunset"
# High quality mode (uses Nano Banana Pro)
python scripts/generate_image.py "Futuristic city skyline" --quality --aspect-ratio 16:9 --size 4K
# Budget mode (force cheapest model)
python scripts/generate_image.py "Simple illustration" --model nano-banana --size 2K
# Portrait orientation with specific model
python scripts/generate_image.py "Portrait of a wise old wizard" --aspect-ratio 9:16 --model nano-banana-pro
# Modify an existing image (auto-selects appropriate model)
python scripts/generate_image.py "make it look like a watercolor painting" --input photo.jpg
# Style transfer with quality priority
python scripts/generate_image.py "Van Gogh style" --input portrait.png --quality
# Multiple reference images (auto-uses Nano Banana Pro for best quality)
python scripts/generate_image.py "group photo of these people at a party" --input person1.jpg person2.jpg person3.jpg person4.jpg
# Budget multi-image (force cheaper model)
python scripts/generate_image.py "combine these items" --input item1.jpg item2.jpg --model nano-banana-2
| Model | Alias | Description | Resolutions | Cost |
|---|---|---|---|---|
| gemini-2.5-flash-image | nano-banana | Cheapest, fast & economical | 1K, 2K | 💰 Low |
| gemini-3.1-flash-image-preview | nano-banana-2 | Best value, recommended | 0.5K, 1K, 2K, 4K | 💰💰 Medium |
| gemini-3-pro-image-preview | nano-banana-pro | Best performance, high quality | 1K, 2K, 4K | 💰💰💰 High |
Smart Model Selection (Default Behavior):
--quality flag)Manual Model Override:
Use the --model parameter to force a specific model:
python scripts/generate_image.py "prompt" --model nano-banana # Cheapest
python scripts/generate_image.py "prompt" --model nano-banana-2 # Best value
python scripts/generate_image.py "prompt" --model nano-banana-pro # Best quality
Quality Priority Mode:
Use the --quality flag to prefer Nano Banana Pro when possible:
python scripts/generate_image.py "prompt" --quality
API Endpoint Format: