
Nano Banana Build
- 62 installs
- 124 repo stars
- Updated February 6, 2026
- cnemri/google-genai-skills
Guides generating and editing images in Python with Gemini 2.5 Flash Image and Gemini 3 Pro Image (Nano Banana), covering style transfer and character consistency.
About
Provides code patterns for image generation and editing via the google-genai SDK using Gemini's Nano Banana image models. A developer uses it to build text-to-image, style-transfer, or character-consistency features in Python.
- Fast Flash model vs 2K/4K Pro image model
- Text-to-image, editing, style transfer, virtual try-on
Nano Banana Build by the numbers
- 62 all-time installs (skills.sh)
- Ranked #861 of 1,335 Generative Media skills by installs in the Skillselion catalog
- Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cnemri/google-genai-skills --skill nano-banana-buildAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 62 |
|---|---|
| repo stars | ★ 124 |
| Last updated | February 6, 2026 |
| Repository | cnemri/google-genai-skills ↗ |
What it does
Guides generating and editing images in Python with Gemini 2.5 Flash Image and Gemini 3 Pro Image (Nano Banana), covering style transfer and character consistency.
Files
Nano Banana Image Generation Skill
Use this skill to generate and edit images using the google-genai Python SDK with Gemini's specialized image models (Nano Banana).
Quick Start Setup
from google import genai
from google.genai import types
from PIL import Image
import io
client = genai.Client()Reference Materials
- [Model Capabilities](references/model_capabilities.md): Comparison of Gemini 2.5 vs 3 Pro, resolutions, and token costs.
- [Image Generation](references/image_generation.md): Text-to-Image, Interleaved Text/Image.
- [Image Editing](references/image_editing.md): Subject Customization, Style Transfer, Multi-turn Editing.
- [Thinking Process](references/thinking_process.md): Understanding thoughts and signatures (Gemini 3 Pro).
- [Recipes](references/recipes.md): Extensive collection of examples (Logos, Stickers, Mockups, Comics, etc.).
- [Source Code](references/source_code.md): Deep inspection of SDK internals.
Available Models
- `gemini-2.5-flash-image` (Nano Banana): Fast, high-quality generation and editing. Best for most use cases.
- `gemini-3-pro-image-preview` (Nano Banana Pro): Highest fidelity, supports
2Kand4Kresolution, complex prompt adherence, and grounding.
Common Workflows
1. Fast Generation
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents='A cute robot eating a banana',
config=types.GenerateContentConfig(
response_modalities=['IMAGE']
)
)2. High-Quality Editing
response = client.models.generate_content(
model='gemini-3-pro-image-preview',
contents=[
types.Part.from_uri(file_uri='gs://.../shoe.jpg', mime_type='image/jpeg'),
"Change the color of the shoe to neon green."
],
config=types.GenerateContentConfig(response_modalities=['IMAGE'])
)Image Editing
Nano Banana models support advanced image-to-image capabilities.
Subject Customization
Change the style or attributes of a subject while preserving its identity.
with open("dog.jpg", "rb") as f:
image_bytes = f.read()
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
types.Part.from_bytes(data=image_bytes, mime_type="image/jpeg"),
"Create a pencil sketch of this dog wearing a cowboy hat."
],
config=types.GenerateContentConfig(response_modalities=["IMAGE"])
)Style Transfer
Apply the style of one image to the content of another.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
types.Part.from_uri(file_uri="gs://.../style_ref.png", mime_type="image/png"),
"Using the concepts and colors from this image, generate a kitchen with the same aesthetic."
],
config=types.GenerateContentConfig(response_modalities=["IMAGE"])
)Multi-turn Editing (Chat)
Iteratively refine an image in a chat session.
chat = client.chats.create(
model='gemini-2.5-flash-image',
config=types.GenerateContentConfig(response_modalities=['TEXT', 'IMAGE'])
)
# First turn
response = chat.send_message("Create an image of a perfume bottle.")
image_data = response.candidates[0].content.parts[1].inline_data.data
# Second turn (pass previous image back)
response = chat.send_message([
types.Part.from_bytes(data=image_data, mime_type="image/png"),
"Make the bottle purple."
])Multiple Reference Images
Combine elements from multiple images.
response = client.models.generate_content(
model='gemini-3-pro-image-preview',
contents=[
types.Part.from_uri(file_uri="gs://.../person.jpg", mime_type="image/jpeg"),
types.Part.from_uri(file_uri="gs://.../background.png", mime_type="image/png"),
"Generate an image of the person from the first image standing in the background from the second image."
]
)Image Generation
Gemini 2.5 Flash Image and Gemini 3 Pro Image (Nano Banana) support advanced image generation capabilities.
Text-to-Image
Generate images from text prompts.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents="A futuristic cityscape at sunset",
config=types.GenerateContentConfig(
response_modalities=["IMAGE"],
image_config=types.ImageConfig(
aspect_ratio="16:9",
# image_size="1K" # Optional
),
candidate_count=1,
),
)
for part in response.candidates[0].content.parts:
if part.inline_data:
# Display or save image
image = part.as_image()
image.save("generated.png")Interleaved Text & Image
Generate tutorials or stories with mixed text and image outputs.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents="Create a 3-step tutorial for making a sandwich. For each step, provide text and an illustration.",
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
),
)Image Sizes (Gemini 3 Pro Image)
Gemini 3 Pro Image supports 1K, 2K, and 4K.
config=types.GenerateContentConfig(
image_config=types.ImageConfig(
image_size="2K",
aspect_ratio="1:1"
)
)Model Capabilities & Differences
Choose the model best suited for your specific use case.
| Feature | Gemini 2.5 Flash Image (Nano Banana) | Gemini 3 Pro Image Preview (Nano Banana Pro) |
|---|---|---|
| Optimization | Speed, efficiency, high-volume tasks. | Professional asset production, complex reasoning. |
| Max Resolution | 1024x1024 (1K) | Up to 4096x4096 (4K) |
| Thinking Process | No | Default "Thinking" process to refine composition. |
| Grounding | No | Google Search Grounding supported. |
| Reference Images | Best with up to 3 images. | Supports up to 14 images (5 humans, 6 objects). |
| Text Rendering | Good | Advanced, high-fidelity text rendering. |
Aspect Ratios & Resolutions
Gemini 2.5 Flash Image
| Aspect Ratio | Resolution | Tokens |
|---|---|---|
| 1:1 | 1024x1024 | 1290 |
| 9:16 | 768x1344 | 1290 |
| 16:9 | 1344x768 | 1290 |
| 4:3 | 1184x864 | 1290 |
| 3:4 | 864x1184 | 1290 |
Gemini 3 Pro Image Preview
Supports 1K, 2K, and 4K sizes. Use uppercase 'K' (e.g., 2K).
| Aspect Ratio | 1K Res | 1K Tokens | 2K Res | 2K Tokens | 4K Res | 4K Tokens |
|---|---|---|---|---|---|---|
| 1:1 | 1024x1024 | 1120 | 2048x2048 | 1120 | 4096x4096 | 2000 |
| 9:16 | 768x1376 | 1120 | 1536x2752 | 1120 | 3072x5504 | 2000 |
| 16:9 | 1376x768 | 1120 | 2752x1536 | 1120 | 5504x3072 | 2000 |
| 4:3 | 1200x896 | 1120 | 2400x1792 | 1120 | 4800x3584 | 2000 |
| 3:4 | 896x1200 | 1120 | 1792x2400 | 1120 | 3584x4800 | 2000 |
Configuration Example
config = types.GenerateContentConfig(
image_config=types.ImageConfig(
aspect_ratio="16:9",
image_size="2K", # Only for Gemini 3 Pro
)
)Nano Banana Recipes
Practical examples for common tasks using Gemini 2.5 Flash Image and Gemini 3 Pro Image.
Blank Canvas (Aspect Ratio Control)
Force a specific aspect ratio by providing a blank image.
from PIL import Image
import io
def create_canvas(width=1280, height=720):
img = Image.new("RGB", (width, height), "white")
buf = io.BytesIO()
img.save(buf, format="PNG")
return types.Part.from_bytes(data=buf.getvalue(), mime_type="image/png")
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
create_canvas(1280, 720),
"A cinematic wide shot of a desert planet."
]
)Virtual Try-On
Place a garment on a model.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
types.Part.from_uri(file_uri="gs://.../model.jpg", mime_type="image/jpeg"),
types.Part.from_uri(file_uri="gs://.../dress.jpg", mime_type="image/jpeg"),
"Realistically place the dress from the second image onto the person in the first image."
]
)Product Recontextualization
Place a product in a new scene.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
types.Part.from_uri(file_uri="gs://.../product.png", mime_type="image/png"),
"Place this product on a marble countertop in a luxury kitchen."
]
)Character Consistency
Maintain a character across different scenes.
response = client.models.generate_content(
model='gemini-2.5-flash-image',
contents=[
types.Part.from_uri(file_uri="gs://.../character_ref.png", mime_type="image/png"),
"Generate an image of this character eating an apple in a park."
]
)Stylized Stickers
Create stickers with transparent backgrounds.
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white.",
)Logo Design
Create modern, minimalist logos using accurate text rendering (Gemini 3 Pro).
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents="Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.",
config=types.GenerateContentConfig(
image_config=types.ImageConfig(aspect_ratio="1:1")
)
)Product Mockups
Generate high-resolution commercial photography.
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image.",
)Minimalist Backgrounds
Create negative space designs for text overlays.
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image.",
)Sequential Art (Comics)
Create storytelling panels using character references.
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=[
"Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humorous scene.",
types.Part.from_uri(file_uri="gs://.../character.jpg", mime_type="image/jpeg")
],
)Grounding with Google Search
Generate images based on real-time data.
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents="Make a simple but stylish graphic of last night's Arsenal game in the Champion's League",
config=types.GenerateContentConfig(
tools=[types.Tool(google_search=types.GoogleSearch())],
image_config=types.ImageConfig(aspect_ratio="16:9")
)
)Sketch to Life
Turn a rough drawing into a polished image.
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=[
types.Part.from_uri(file_uri="gs://.../car_sketch.png", mime_type="image/png"),
"Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting."
],
)Multi-Image Composition (Advanced)
Combine up to 14 reference images (Gemini 3 Pro).
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
contents=[
"An office group photo of these people, they are making funny faces.",
types.Part.from_uri(file_uri="gs://.../person1.png", mime_type="image/png"),
types.Part.from_uri(file_uri="gs://.../person2.png", mime_type="image/png"),
types.Part.from_uri(file_uri="gs://.../person3.png", mime_type="image/png"),
# ... up to 14 images total
],
config=types.GenerateContentConfig(
image_config=types.ImageConfig(aspect_ratio="5:4", image_size="2K")
)
)Google GenAI SDK Source Code (Nano Banana)
Use web_fetch to retrieve raw code for deep inspection of image generation parameters.
Base URL: https://raw.githubusercontent.com/googleapis/python-genai/main/google/genai/
Key Modules
Models (Generation)
- File:
models.py - URL:
https://raw.githubusercontent.com/googleapis/python-genai/main/google/genai/models.py - Purpose:
generate_images(helper) andgenerate_content(core logic).
Types (Configuration)
- File:
types.py - URL:
https://raw.githubusercontent.com/googleapis/python-genai/main/google/genai/types.py - Purpose: Definitions for
ImageConfig,GenerateImagesConfig,PersonGeneration,SafetyFilterLevel.
Client
- File:
client.py - URL:
https://raw.githubusercontent.com/googleapis/python-genai/main/google/genai/client.py
Thinking Process & Thought Signatures
Gemini 3 Pro Image Preview uses a default "Thinking" process to refine composition and logic before generation.
Accessing Thoughts
You can inspect the thoughts that led to the final image.
for part in response.parts:
if part.thought:
if part.text:
print(f"Thought: {part.text}")
elif part.inline_data:
# Interim thought image
image = part.as_image()
image.show()Thought Signatures
Crucial for Multi-turn: Thought signatures preserve reasoning context across turns.
- Automatic Handling: If using
client.chatsor appending the full response object to history, the SDK handles this automatically. - Manual Handling: If manually constructing JSON payloads, you must pass back the
thought_signaturefield exactly as received.
Structure
- The first non-thought text part has a signature.
- All inline image parts (except thought images) have signatures.
- Thought parts do not have signatures.
Failure to circulate thought signatures may cause the response to fail.