Loading...
Loading...
AI image generation and editing using Google Gemini models (Nano Banana). Use when the user asks to generate an image, create an image, edit an image, or references "nano banana", "nanobanana", or "gemini image". Supports text-to-image, image editing, multi-image references, and 1K/2K/4K resolution.
npx skill4agent add kenneth-liao/ai-launchpad-marketplace nanobananagemini-3-pro-image-previewgemini-2.5-flash-imageGEMINI_API_KEYuvgoogle-genaiuvuv runpython3pip install -r <skill_dir>/requirements.txt~/Downloads/nanobanana_<timestamp>.png-o-o ~/Downloads/robot.pnguv run <skill_dir>/scripts/generate.py "a cute robot mascot, pixel art style"uv run <skill_dir>/scripts/generate.py "make the background blue" -i input.jpguv run <skill_dir>/scripts/generate.py "quick sketch of a cat" --model flashuv run <skill_dir>/scripts/generate.py "apply the style of the first image to the second" \
-i style_ref.png subject.jpguv run <skill_dir>/scripts/generate.py "cinematic landscape" --ratio 21:9 --size 4Kuv run <skill_dir>/scripts/generate.py "logo design" -o ~/Projects/brand/logo.png| Pro (default) | Flash | |
|---|---|---|
| Speed | Slower | ~2-3x faster |
| Cost | Higher | Lower |
| Text rendering | Good | Unreliable |
| Complex scenes | Excellent | Adequate |
| Thinking mode | Yes | No |
| Best for | Final production images | Exploration, drafts, batch |
scripts/generate.pyUsage: generate.py [OPTIONS] PROMPT
Arguments:
PROMPT Text prompt for image generation
Options:
-o, --output PATH Output file path (default: ~/Downloads/nanobanana_<timestamp>.png)
-i, --input PATH... Input image(s) for editing / reference (up to 14)
-m, --model MODEL Model: 'pro' (default), 'flash', or full model ID
-r, --ratio RATIO Aspect ratio (1:1, 16:9, 9:16, 21:9, etc.)
-s, --size SIZE Image size: 1K, 2K, or 4K (default: standard)
--search Enable Google Search grounding for accuracy
--retries N Max retries on rate limit (default: 3)
-v, --verbose Show detailed output1:12:33:23:44:34:55:49:1616:921:91K2K4Kscripts/batch_generate.pyUsage: batch_generate.py [OPTIONS] PROMPT
Arguments:
PROMPT Text prompt for image generation
Options:
-n, --count N Number of images to generate (default: 10)
-d, --dir PATH Output directory (default: ~/Downloads)
-p, --prefix STR Filename prefix (default: "image")
-m, --model MODEL Model: 'pro' (default), 'flash', or full model ID
-r, --ratio RATIO Aspect ratio
-s, --size SIZE Image size (1K/2K/4K)
--search Enable Google Search grounding
--retries N Max retries per image on rate limit (default: 3)
--delay SECONDS Delay between generations (default: 3)
--parallel N Concurrent requests (default: 1, max recommended: 5)
-q, --quiet Suppress progress outputuv run <skill_dir>/scripts/batch_generate.py "pixel art logo" -n 20 --model flash -d ./logos -p logoNote: When importing as a Python module,must be available in the calling script's environment. If usinggoogle-genai, add a PEP 723uv runblock to your own script (see example in Pattern 2 below).dependencies
import sys
from pathlib import Path
sys.path.insert(0, str(Path("<skill_dir>/scripts")))
from generate import generate_image, edit_image, batch_generate
# Generate image
result = generate_image(
prompt="a futuristic city at night",
output_path="city.png",
aspect_ratio="16:9",
image_size="4K",
model="pro",
)
# Edit existing image
result = edit_image(
prompt="add flying cars to the sky",
input_path="city.png",
output_path="city_edited.png",
)
# Multi-image reference
result = generate_image(
prompt="combine the color palette of the first with the composition of the second",
input_paths=["palette_ref.png", "composition_ref.png"],
output_path="combined.png",
){
"success": True, # or False
"path": "/path/to/output.png", # or None on failure
"error": None, # or error message string
"metadata": {
"model": "gemini-3-pro-image-preview",
"prompt": "...",
"aspect_ratio": "16:9",
"image_size": "4K",
"use_search": False,
"input_images": None, # or list of paths
"text_response": "...", # optional text from model
"thinking": "...", # Pro model reasoning (when available)
"timestamp": "2025-01-26T...",
}
}# In your skill's script:
uv run <nanobanana_dir>/scripts/generate.py "{prompt}" --model flash --ratio 16:9 -o output.png# /// script
# requires-python = ">=3.10"
# dependencies = [
# "google-genai>=1.0.0",
# ]
# ///
import sys
from pathlib import Path
NANOBANANA_DIR = Path("<nanobanana_dir>/scripts")
sys.path.insert(0, str(NANOBANANA_DIR))
from generate import generate_image
def generate_thumbnail(prompt: str, output_path: str) -> dict:
"""Generate a YouTube thumbnail with project defaults."""
return generate_image(
prompt=prompt,
output_path=output_path,
aspect_ratio="16:9",
image_size="2K",
model="flash",
max_retries=3,
)from batch_generate import batch_generate
def on_progress(completed, total, result):
print(f"Progress: {completed}/{total}")
results = batch_generate(
prompt="logo concept",
count=20,
output_dir="./logos",
prefix="logo",
model="flash",
aspect_ratio="1:1",
on_progress=on_progress,
)
successful = [r for r in results if r["success"]]from generate import generate_image
# Step 1: Generate the style anchor
anchor = generate_image(
prompt="warm illustration style, earth tones, soft gradients, clean lines",
output_path="anchor.png",
model="pro",
)
# Step 2: Generate each image in the series, referencing the anchor
subjects = ["laptop on desk with coffee", "person reading a book", "sunrise over mountains"]
series_paths = [anchor["path"]]
for i, subject in enumerate(subjects):
result = generate_image(
prompt=f"{subject}, matching the visual style and color palette of the reference image exactly",
input_paths=[anchor["path"]], # always include the anchor
output_path=f"series_{i+1:02d}.png",
model="pro",
)
if result["success"]:
series_paths.append(result["path"])| Variable | Description | Default |
|---|---|---|
| Google Gemini API key | Required |
| Default output directory | |
--search-iuv run <skill_dir>/scripts/generate.py \
"modern flat illustration style, warm earth tones, soft gradients, clean lines, \
minimal detail, cozy atmosphere" \
--model pro -o anchor.pnguv run <skill_dir>/scripts/generate.py \
"a laptop on a desk with coffee, matching the visual style, color palette, \
and lighting of the reference image exactly" \
-i anchor.png --model pro -o image_01.pnguv run <skill_dir>/scripts/generate.py \
"a friendly robot mascot with round blue body, orange antenna, large expressive eyes, \
simple geometric design, standing front-facing on white background" \
--model pro -o subject_front.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference image, now sitting at a desk typing, \
same proportions and colors, office background" \
-i subject_front.png --model pro -o subject_office.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference images, now outdoors in a park, \
same proportions and colors, waving at the viewer" \
-i subject_front.png subject_office.png --model pro -o subject_park.png-i-i--model flash--delay 5--parallelcurl -LsSf https://astral.sh/uv/install.sh | shbrew install uvuv runpython3pip install -r <skill_dir>/requirements.txtGEMINI_API_KEY