Image Generation
Important (December 2025): The google-generativeai package has been deprecated.
This skill now uses the google-genai SDK. If upgrading from older code, see the
migration guide.
Purpose
This skill enables AI-powered image generation and editing through Google's Gemini image models and OpenAI's DALL-E models. Create photorealistic images, illustrations, logos, stickers, and product mockups from natural language descriptions. Edit existing images with text instructions, apply style transfers, and refine outputs through iterative conversation.
Attribution: This skill is inspired by the gemini-imagegen skill from Every Marketplace by Every Inc.
When to Use
This skill should be invoked when the user asks to:
- Generate images from text descriptions ("create an image of...", "generate a picture...")
- Create logos, icons, or stickers ("design a logo for...", "make a sticker...")
- Edit or modify existing images ("change the background to...", "add... to this image")
- Apply artistic styles or effects ("make it look like...", "stylize as...")
- Create product mockups or visualizations ("product photo of...", "mockup showing...")
- Refine or iterate on images ("make it more...", "adjust the...", "try again with...")
- Generate variations with different styles or compositions
Available Models
Google Gemini Models (Nano Banana)
gemini-2.5-flash-image ("Nano Banana")
- Resolution: 1K (1024px), supports 2K
- Aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
- Best for: Speed, high-volume operations, rapid iteration, image editing
- Use when: Quick prototypes, multiple variations, time-sensitive requests
- Cost:
$0.039 per image ($30/million output tokens)
gemini-3-pro-image-preview ("Nano Banana Pro")
- Resolution: 1K default, supports 2K and 4K
- Aspect ratios: Same as Flash
- Best for: Professional assets, complex instructions, highest quality
- Use when: Final deliverables, detailed compositions, text-heavy designs
- Special features:
- Google Search grounding for real-time data visualization
- "Thinking" mode with interim composition refinement
- Up to 14 reference images (6 objects, 5 humans for character consistency)
- Advanced text rendering
Google Imagen 4 Family (New)
imagen-4.0-fast-generate-001 ("Imagen 4 Fast")
- Resolution: Standard
- Best for: Rapid generation, high-volume tasks
- Use when: Speed is priority, budget-conscious
- Cost: $0.02 per image
- Note: Text-only input (no image editing)
imagen-4.0-generate-001 ("Imagen 4")
- Resolution: Up to 2K
- Best for: High-quality photorealistic images, excellent text rendering
- Use when: Professional quality needed, text in images
- Features: Significant improvements in text rendering over previous Imagen models
imagen-4.0-ultra-generate-001 ("Imagen 4 Ultra")
- Resolution: Up to 2K
- Best for: Highest quality, detailed visuals
- Use when: Maximum quality is essential (one image at a time)
- Limitation: Only generates one image per request
OpenAI GPT Image Models
gpt-image-1.5 (Recommended - December 2025)
- Resolution: 1024x1024, 1536x1024, 1024x1536, or auto
- Best for: Production-quality visuals, precise editing, character consistency
- Use when: Professional design, iterative workflows, text-heavy images
- Features:
- 4x faster than gpt-image-1, 20% lower cost
- Built-in reasoning and world knowledge
- Precise logo & face preservation during edits
- Excellent text rendering (crisp lettering, dense text)
- Complex structured visuals (infographics, diagrams, multi-panel)
- Streaming support
- Output formats: png, jpeg, webp (with compression control)
- Transparency: transparent, opaque, or auto background
gpt-image-1 (April 2025)
- Resolution: Up to 4096x4096
- Best for: High-resolution images, creative workflows
- Use when: Maximum resolution needed
- Cost: ~$0.02 (low), ~$0.07 (medium), ~$0.19 (high) per image
- Output formats: png, jpeg, webp
- Note: Single image per request, no inpainting
Legacy OpenAI DALL-E Models
dall-e-3
- Resolution: 1024x1024, 1024x1792, 1792x1024
- Best for: Creative interpretations, artistic renders
- Use when: Natural artistic style preferred
- Note: Automatic prompt expansion
dall-e-2
- Resolution: 1024x1024, 512x512, 256x256
- Best for: Faster generation, lowest cost, variations
- Use when: Budget-conscious, simpler images
- Unique feature: Can generate variations of existing images
Model Selection Logic
Ask the user or use this decision tree:
Need image editing or iterative refinement?
├─ Yes → gpt-image-1.5 (best editing) or gemini-2.5-flash-image (multi-turn chat)
└─ No → Text-to-image only
├─ Need highest quality?
│ ├─ Text rendering critical → gpt-image-1.5 or imagen-4.0-generate-001
│ ├─ Maximum resolution (4K) → gemini-3-pro-image-preview
│ ├─ Ultra quality (single image) → imagen-4.0-ultra-generate-001
│ └─ Character consistency → gpt-image-1.5 or gemini-3-pro-image-preview
├─ Need speed/volume?
│ ├─ Cheapest → imagen-4.0-fast-generate-001 ($0.02)
│ └─ Fast + editing → gemini-2.5-flash-image
└─ Balanced default → gpt-image-1.5 (recommended)
Quick Reference:
- Best overall:
gpt-image-1.5 - fast, affordable, great editing & text
- Best for text rendering:
gpt-image-1.5 or imagen-4.0-generate-001
- Best for 4K resolution:
gemini-3-pro-image-preview
- Cheapest per image:
imagen-4.0-fast-generate-001 ($0.02)
- Best for reference images:
gemini-3-pro-image-preview (up to 14 refs)
- Best for iterative editing:
gpt-image-1.5 (face/logo preservation)
If the user has specific model preference, use that.
Capabilities
- Text-to-Image Generation: Create images from detailed text descriptions
- Image Editing: Modify existing images with text instructions
- Style Transfer: Apply artistic styles, filters, and effects
- Logo & Sticker Design: Generate branded assets with specific styles
- Product Mockups: Create professional product photography and presentations
- Multi-turn Refinement: Iteratively improve images through conversation
- Aspect Ratio Control: Generate images in various formats (square, portrait, landscape, wide)
- Reference-based Generation: Use existing images as compositional references (Gemini Pro)
Instructions
Step 1: Understand the Request
Analyze the user's request to determine:
- Type: Text-to-image, image editing, style transfer, logo/sticker, mockup
- Subject: What should be in the image
- Style: Photorealistic, illustration, artistic, minimalist, etc.
- Details: Colors, lighting, composition, mood, specific elements
- Format: Aspect ratio, resolution requirements
- Urgency: Speed vs. quality trade-off
Step 2: Select Model
Based on requirements:
- High quality + complexity →
gemini-3-pro-image-preview
- Speed + iterations →
gemini-2.5-flash-image
- DALL-E preference →
dall-e-3 or dall-e-2
If unclear, use AskUserQuestion tool to clarify model preference.
Step 3: Craft Effective Prompt
Build a detailed prompt following these patterns:
For Photorealistic Images:
[Subject], [camera details], [lighting], [mood/atmosphere], [composition]
Example: "Close-up portrait of a woman, 85mm lens, soft golden hour lighting,
serene mood, shallow depth of field, professional photography"
For Illustrations/Art:
[Subject], [art style], [color palette], [details], [mood]
Example: "Kawaii cat sticker, bold black outlines, cel-shading, pastel colors,
cute expression, chibi style"
For Logos:
[concept], [style], [elements], [colors], [context]
Example: "Tech startup logo, minimalist geometric design, abstract network nodes,
blue and silver gradient, professional, vector style"
For Product Photography:
[product], [setting], [lighting], [presentation], [context]
Example: "Wireless earbuds, white background, studio lighting, 3/4 angle view,
clean minimal composition, e-commerce product shot"
Key principles:
- Be specific and detailed
- Include lighting, composition, and mood
- Specify style clearly (photorealistic, illustration, etc.)
- Mention camera/lens for photorealistic (85mm, wide angle, macro)
- For text in images, use Pro model and specify exact text
Step 4: Implement API Call
For Gemini Models:
Note: The google.generativeai package has been deprecated. Use google.genai instead.
See migration guide: https://ai.google.dev/gemini-api/docs/migrate
from google import genai
from google.genai import types
from pathlib import Path
# Initialize client (uses GEMINI_API_KEY or GOOGLE_API_KEY env var automatically)
client = genai.Client()
# Basic text-to-image
response = client.models.generate_content(
model="gemini-2.5-flash-image", # or gemini-3-pro-image-preview
contents=prompt_text,
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
# Optional configurations:
# image_config=types.ImageConfig(
# aspect_ratio="1:1", # 1:1, 3:4, 4:3, 9:16, 16:9, 21:9
# image_size="1K", # 1K, 2K, 4K (Pro only)
# )
)
)
# Extract and save image
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
image.save("output.png")
# For image editing (pass existing image):
from PIL import Image
image = Image.open("input.png")
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=[image, "Make the background a sunset scene"],
config=types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"])
)
# For multi-turn refinement (use chat):
chat = client.chats.create(
model="gemini-2.5-flash-image",
config=types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"])
)
response1 = chat.send_message("A futuristic city skyline")
response2 = chat.send_message("Add more neon lights and flying cars")
For Google Imagen 4 Models:
from google import genai
from google.genai import types
# Initialize client (uses GEMINI_API_KEY or GOOGLE_API_KEY env var automatically)
client = genai.Client()
# Imagen 4 text-to-image (no editing support)
# Also available: imagen-4.0-fast-generate-001, imagen-4.0-ultra-generate-001
response = client.models.generate_images(
model="imagen-4.0-generate-001",
prompt=prompt_text,
config=types.GenerateImagesConfig(
number_of_images=4, # 1-4 for standard, 1 for Ultra
aspect_ratio="1:1", # 1:1, 3:4, 4:3, 9:16, 16:9
person_generation="allow_adult", # "dont_allow", "allow_adult", "allow_all"
)
)
# Save images
for i, generated_image in enumerate(response.generated_images):
generated_image.image.save(f"output_{i}.png")
For OpenAI Models (gpt-image-1.5 recommended):
from openai import OpenAI
from pathlib import Path
import base64
client = OpenAI() # reads OPENAI_API_KEY env var automatically
# gpt-image-1.5 generation (recommended)
response = client.images.generate(
model="gpt-image-1.5",
prompt=prompt_text,
size="1024x1024", # or "1536x1024", "1024x1536", "auto"
quality="high", # "low", "medium", "high"
n=1, # 1-10 images
output_format="png", # "png", "jpeg", "webp"
background="auto", # "transparent", "opaque", "auto"
moderation="auto", # "auto" or "low" for less restrictive
)
# Response returns base64 data
image_data = base64.b64decode(response.data[0].b64_json)
Path("output.png").write_bytes(image_data)
# gpt-image-1 generation (for max 4K resolution)
response = client.images.generate(
model="gpt-image-1",
prompt=prompt_text,
size="1024x1024",
quality="high",
n=1,
)
# Image editing with gpt-image-1.5
response = client.images.edit(
model="gpt-image-1.5",
image=open("input.png", "rb"),
prompt="Change the background to a beach sunset",
size="1024x1024",
)
# Legacy DALL-E 3 generation
response = client.images.generate(
model="dall-e-3",
prompt=prompt_text,
size="1024x1024", # or "1024x1792", "1792x1024"
quality="standard", # or "hd"
n=1,
)
image_url = response.data[0].url
# Download URL-based response
import requests
image_data = requests.get(image_url).content
Path("output.png").write_bytes(image_data)
Implementation approach:
- Use
Bash tool to execute Python scripts with API calls
- Check for API keys in environment variables
- Handle errors gracefully (API limits, invalid prompts, etc.)
- Save images with descriptive filenames
- Report image location to user
Step 5: Handle Output
- Save the generated image to an appropriate location
- Verify the output meets the request
- Show the user the saved file path
- Offer refinement if the result isn't quite right
- Explain the prompt used so the user understands the generation
Step 6: Iterate if Needed
If the user wants changes:
- For Gemini: Use chat interface to maintain context
- For gpt-image-1.5: Use editing API for precise face/logo preservation
- For Imagen/DALL-E: Generate new image with updated prompt
- Keep previous versions for comparison
- Suggest specific adjustments based on the current result
Requirements
API Keys:
- Google (Gemini/Imagen): Set
GOOGLE_API_KEY or GEMINI_API_KEY environment variable
- OpenAI: Set
OPENAI_API_KEY environment variable
Python Packages:
pip install google-genai openai pillow requests
Note: The google-generativeai package has been deprecated and will no longer receive updates.
Use google-genai instead. Migration guide: https://ai.google.dev/gemini-api/docs/migrate
System:
- Python 3.8+
- Internet connection for API access
- Write permissions for saving images
Approximate Costs (per image):
| Model |
Low Quality |
High Quality |
| imagen-4.0-fast |
$0.02 |
$0.02 |
| imagen-4.0 |
- |
~$0.04 |
| imagen-4.0-ultra |
- |
~$0.08 |
| gemini-2.5-flash-image |
~$0.039 |
~$0.039 |
| gpt-image-1.5 |
~$0.016 |
~$0.15 |
| gpt-image-1 |
~$0.02 |
~$0.19 |
| dall-e-3 |
~$0.04 |
~$0.08 |
| dall-e-2 |
~$0.02 |
~$0.02 |
Best Practices
Prompt Engineering
Be Specific: Vague prompts produce inconsistent results
- Bad: "a nice landscape"
- Good: "mountain valley at sunrise, mist over lake, pine trees, warm golden light, peaceful atmosphere"
Include Technical Details for photorealism:
- Camera: "shot on 85mm lens", "wide angle 24mm", "macro photography"
- Lighting: "golden hour", "studio lighting", "rim light", "soft diffused"
- Quality: "high resolution", "detailed", "sharp focus", "professional photography"
Specify Style Clearly:
- "photorealistic", "oil painting", "watercolor", "digital art", "3D render"
- "minimalist", "detailed", "abstract", "realistic", "stylized"
- "anime style", "pixel art", "vector art", "charcoal sketch"
Use Examples and References:
- "in the style of [artist/art movement]"
- "similar to [known visual reference]"
- For Gemini Pro: Provide actual reference images
Negative Prompts (what to avoid):
- DALL-E doesn't support negative prompts directly
- For Gemini, phrase as positive instructions: "clear sky" vs "no clouds"
Model-Specific Tips
gpt-image-1.5 (Recommended):
- Best for iterative editing workflows - preserves faces/logos during edits
- Built-in reasoning understands context (e.g., "Bethel, NY, August 1969" → Woodstock)
- Excellent text rendering, especially dense/small text
- Great for infographics, diagrams, multi-panel compositions
- 4x faster than gpt-image-1, use streaming for real-time feedback
- Use
background="transparent" for assets
gpt-image-1:
- Maximum resolution (4096x4096) when needed
- Good for one-shot high-res generation
- No editing/inpainting support
Imagen 4 Family:
- Best text rendering among Google models
- Use Fast ($0.02) for high-volume prototyping
- Use Ultra for highest quality single images
- Text-to-image only (no editing) - use Gemini for edits
- All images include SynthID watermark
Gemini Flash (2.5) - Nano Banana:
- Best for iterative multi-turn editing via chat
- Good for generating multiple variations quickly
- Use for draft/concept phase with refinement
Gemini Pro (3) - Nano Banana Pro:
- Use for final deliverables and 4K output
- Best for complex compositions with reference images (up to 14)
- "Thinking" mode generates interim drafts for composition planning
- Leverage Google Search grounding for current events/real places
DALL-E 3 (Legacy):
- Excellent at understanding natural language
- Strong at creative interpretations
- Automatic prompt expansion (may deviate from exact request)
DALL-E 2 (Legacy):
- More literal interpretation of prompts
- Can generate variations of existing images
- Budget-friendly for simple tasks
Quality Guidelines
- Start with clear requirements: Ask clarifying questions before generating
- Choose appropriate model: Match model capabilities to requirements
- Iterate thoughtfully: Make specific changes rather than complete regeneration
- Save intermediate versions: Keep promising iterations
- Respect usage policies: Follow content policies for each platform
- Credit the tool: Disclose AI-generated images when sharing
Error Handling
- API key missing: Prompt user to set environment variable
- Invalid prompt: Suggest refinements, check content policy
- Rate limits: Inform user and suggest retry timing
- Generation failure: Try simpler prompt or different model
- Unsatisfactory result: Offer to regenerate with adjusted prompt
Examples
Example 1: Logo Design
User request: "Create a logo for a coffee shop called 'Morning Brew'"
Expected behavior:
- Ask user about style preference (modern, vintage, minimalist, etc.)
- Ask about color preferences
- Select model (gpt-image-1.5 for text rendering, or gemini-3-pro-image-preview for 4K)
- Generate with prompt: "Coffee shop logo for 'Morning Brew', minimalist modern design,
coffee cup with steam forming sunrise rays, warm brown and orange colors,
clean professional aesthetic, vector style, white background"
- Use
background="transparent" for gpt-image-1.5 for easy placement
- Save image and show path
- Offer to generate variations with different styles
Example 2: Product Photography
User request: "Generate product photos of wireless earbuds"
Expected behavior:
- Select model (imagen-4.0-generate-001 for photorealism, or gpt-image-1.5 for editing)
- Generate with prompt: "Wireless earbuds product photography, white background,
professional studio lighting, 3/4 angle view showing charging case and earbuds,
clean minimal composition, high resolution, sharp focus, e-commerce quality"
- Generate additional angles if requested
- Save all versions
Example 3: Illustration
User request: "Create a cute sticker of a robot"
Expected behavior:
- Select model (gpt-image-1.5 with
background="transparent" for stickers)
- Generate with prompt: "Cute robot sticker, kawaii style, bold black outlines,
cel-shading, pastel blue and silver colors, big friendly eyes, rounded shapes,
chibi proportions, white border, transparent background suitable for sticker"
- Save and offer variations
Example 4: Image Editing
User request: "Change the background of this photo to a beach sunset"
Expected behavior:
- Use
Read tool to load the existing image
- Select model (gpt-image-1.5 for best editing with face preservation, or Gemini for chat-based iteration)
- Generate with image + prompt: "Change the background to a beautiful beach at sunset,
golden hour lighting, warm colors, ocean and palm trees visible, maintain the subject
in foreground, seamless composition"
- Save edited image
Example 5: Iterative Refinement
User request: "Generate a futuristic city" → "Add more neon lights" → "Make it rain"
Expected behavior:
- First generation: "Futuristic city skyline, towering skyscrapers, advanced architecture,
night scene, detailed, cinematic lighting"
- Use gpt-image-1.5 edit API or Gemini chat interface to maintain context
- Second refinement: "Add vibrant neon lights throughout the city, cyberpunk aesthetic,
glowing signs and billboards"
- Third refinement: "Add rain effect, wet streets reflecting neon lights, atmospheric,
moody"
- Save each version with descriptive names
Limitations
- Content Policies: All models have content restrictions (no violence,
explicit content, copyrighted characters, real people without consent)
- Text Rendering: Much improved in gpt-image-1.5 and Imagen 4, but very long/complex text may still have issues
- Photorealism of People: May not perfectly capture specific facial features; gpt-image-1.5 preserves faces best during edits
- Complex Compositions: Very complex scenes may need multiple iterations
- Consistency: Hard to maintain exact consistency across multiple generations; use gpt-image-1.5 or Gemini Pro with reference images for character consistency
- Real-time Events: Results may not reflect very recent events (use Gemini Pro Search grounding for current topics)
- API Costs: Be mindful of usage; see pricing table above
- Rate Limits: APIs have rate limits; may need to wait between requests
- Imagen Limitations: Text-to-image only (no editing), single image for Ultra model
- Watermarks: Google Imagen images include SynthID watermark
Related Skills
python-plotting - For data visualization and charts
brainstorming - For ideating visual concepts
scientific-writing - For figure captions and documentation
python-best-practices - For writing clean API integration code
Additional Resources
1---2name: image-generation3description: |4 AI-powered image generation and editing using Google Gemini, Google Imagen, and OpenAI models.5 Generate images from text descriptions, edit existing images, create logos/stickers,6 apply style transfers, and produce product mockups.78 Use this skill when the user requests:9 - Image generation from text descriptions10 - Image editing or modifications11 - Logos, stickers, or graphic design assets12 - Product mockups or visualizations13 - Style transfers or artistic effects14 - Iterative image refinement1516 Available models:17 - Google Gemini: gemini-2.5-flash-image (Nano Banana), gemini-3-pro-image-preview (Nano Banana Pro)18 - Google Imagen: imagen-4.0-generate-001, imagen-4.0-ultra-generate-001, imagen-4.0-fast-generate-00119 - OpenAI: gpt-image-1.5 (recommended), gpt-image-1, dall-e-3, dall-e-22021 Inspired by: https://github.com/EveryInc/every-marketplace/tree/main/plugins/compounding-engineering/skills/gemini-imagegen22allowed-tools: ["Bash", "Read", "Write", "AskUserQuestion", "WebFetch"]23---2425# Image Generation2627> **Important (December 2025)**: The `google-generativeai` package has been deprecated.28> This skill now uses the `google-genai` SDK. If upgrading from older code, see the29> [migration guide](https://ai.google.dev/gemini-api/docs/migrate).3031## Purpose3233This skill enables AI-powered image generation and editing through Google's Gemini image models and OpenAI's DALL-E models. Create photorealistic images, illustrations, logos, stickers, and product mockups from natural language descriptions. Edit existing images with text instructions, apply style transfers, and refine outputs through iterative conversation.3435**Attribution:** This skill is inspired by the `gemini-imagegen` skill from [Every Marketplace](https://github.com/EveryInc/every-marketplace/tree/main/plugins/compounding-engineering/skills/gemini-imagegen) by Every Inc.3637## When to Use3839This skill should be invoked when the user asks to:40- Generate images from text descriptions ("create an image of...", "generate a picture...")41- Create logos, icons, or stickers ("design a logo for...", "make a sticker...")42- Edit or modify existing images ("change the background to...", "add... to this image")43- Apply artistic styles or effects ("make it look like...", "stylize as...")44- Create product mockups or visualizations ("product photo of...", "mockup showing...")45- Refine or iterate on images ("make it more...", "adjust the...", "try again with...")46- Generate variations with different styles or compositions4748## Available Models4950### Google Gemini Models (Nano Banana)51521. **gemini-2.5-flash-image** ("Nano Banana")53 - Resolution: 1K (1024px), supports 2K54 - Aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:955 - Best for: Speed, high-volume operations, rapid iteration, image editing56 - Use when: Quick prototypes, multiple variations, time-sensitive requests57 - Cost: ~$0.039 per image (~$30/million output tokens)58592. **gemini-3-pro-image-preview** ("Nano Banana Pro")60 - Resolution: 1K default, supports 2K and 4K61 - Aspect ratios: Same as Flash62 - Best for: Professional assets, complex instructions, highest quality63 - Use when: Final deliverables, detailed compositions, text-heavy designs64 - Special features:65 - Google Search grounding for real-time data visualization66 - "Thinking" mode with interim composition refinement67 - Up to 14 reference images (6 objects, 5 humans for character consistency)68 - Advanced text rendering6970### Google Imagen 4 Family (New)71723. **imagen-4.0-fast-generate-001** ("Imagen 4 Fast")73 - Resolution: Standard74 - Best for: Rapid generation, high-volume tasks75 - Use when: Speed is priority, budget-conscious76 - Cost: $0.02 per image77 - Note: Text-only input (no image editing)78794. **imagen-4.0-generate-001** ("Imagen 4")80 - Resolution: Up to 2K81 - Best for: High-quality photorealistic images, excellent text rendering82 - Use when: Professional quality needed, text in images83 - Features: Significant improvements in text rendering over previous Imagen models84855. **imagen-4.0-ultra-generate-001** ("Imagen 4 Ultra")86 - Resolution: Up to 2K87 - Best for: Highest quality, detailed visuals88 - Use when: Maximum quality is essential (one image at a time)89 - Limitation: Only generates one image per request9091### OpenAI GPT Image Models92936. **gpt-image-1.5** (Recommended - December 2025)94 - Resolution: 1024x1024, 1536x1024, 1024x1536, or auto95 - Best for: Production-quality visuals, precise editing, character consistency96 - Use when: Professional design, iterative workflows, text-heavy images97 - Features:98 - 4x faster than gpt-image-1, 20% lower cost99 - Built-in reasoning and world knowledge100 - Precise logo & face preservation during edits101 - Excellent text rendering (crisp lettering, dense text)102 - Complex structured visuals (infographics, diagrams, multi-panel)103 - Streaming support104 - Output formats: png, jpeg, webp (with compression control)105 - Transparency: transparent, opaque, or auto background1061077. **gpt-image-1** (April 2025)108 - Resolution: Up to 4096x4096109 - Best for: High-resolution images, creative workflows110 - Use when: Maximum resolution needed111 - Cost: ~$0.02 (low), ~$0.07 (medium), ~$0.19 (high) per image112 - Output formats: png, jpeg, webp113 - Note: Single image per request, no inpainting114115### Legacy OpenAI DALL-E Models1161178. **dall-e-3**118 - Resolution: 1024x1024, 1024x1792, 1792x1024119 - Best for: Creative interpretations, artistic renders120 - Use when: Natural artistic style preferred121 - Note: Automatic prompt expansion1221239. **dall-e-2**124 - Resolution: 1024x1024, 512x512, 256x256125 - Best for: Faster generation, lowest cost, variations126 - Use when: Budget-conscious, simpler images127 - Unique feature: Can generate variations of existing images128129## Model Selection Logic130131Ask the user or use this decision tree:132133```134Need image editing or iterative refinement?135├─ Yes → gpt-image-1.5 (best editing) or gemini-2.5-flash-image (multi-turn chat)136└─ No → Text-to-image only137 ├─ Need highest quality?138 │ ├─ Text rendering critical → gpt-image-1.5 or imagen-4.0-generate-001139 │ ├─ Maximum resolution (4K) → gemini-3-pro-image-preview140 │ ├─ Ultra quality (single image) → imagen-4.0-ultra-generate-001141 │ └─ Character consistency → gpt-image-1.5 or gemini-3-pro-image-preview142 ├─ Need speed/volume?143 │ ├─ Cheapest → imagen-4.0-fast-generate-001 ($0.02)144 │ └─ Fast + editing → gemini-2.5-flash-image145 └─ Balanced default → gpt-image-1.5 (recommended)146```147148**Quick Reference:**149- **Best overall**: `gpt-image-1.5` - fast, affordable, great editing & text150- **Best for text rendering**: `gpt-image-1.5` or `imagen-4.0-generate-001`151- **Best for 4K resolution**: `gemini-3-pro-image-preview`152- **Cheapest per image**: `imagen-4.0-fast-generate-001` ($0.02)153- **Best for reference images**: `gemini-3-pro-image-preview` (up to 14 refs)154- **Best for iterative editing**: `gpt-image-1.5` (face/logo preservation)155156If the user has specific model preference, use that.157158## Capabilities1591601. **Text-to-Image Generation**: Create images from detailed text descriptions1612. **Image Editing**: Modify existing images with text instructions1623. **Style Transfer**: Apply artistic styles, filters, and effects1634. **Logo & Sticker Design**: Generate branded assets with specific styles1645. **Product Mockups**: Create professional product photography and presentations1656. **Multi-turn Refinement**: Iteratively improve images through conversation1667. **Aspect Ratio Control**: Generate images in various formats (square, portrait, landscape, wide)1678. **Reference-based Generation**: Use existing images as compositional references (Gemini Pro)168169## Instructions170171### Step 1: Understand the Request172173Analyze the user's request to determine:174- **Type**: Text-to-image, image editing, style transfer, logo/sticker, mockup175- **Subject**: What should be in the image176- **Style**: Photorealistic, illustration, artistic, minimalist, etc.177- **Details**: Colors, lighting, composition, mood, specific elements178- **Format**: Aspect ratio, resolution requirements179- **Urgency**: Speed vs. quality trade-off180181### Step 2: Select Model182183Based on requirements:184- **High quality + complexity** → `gemini-3-pro-image-preview`185- **Speed + iterations** → `gemini-2.5-flash-image`186- **DALL-E preference** → `dall-e-3` or `dall-e-2`187188If unclear, use `AskUserQuestion` tool to clarify model preference.189190### Step 3: Craft Effective Prompt191192Build a detailed prompt following these patterns:193194**For Photorealistic Images:**195```196[Subject], [camera details], [lighting], [mood/atmosphere], [composition]197198Example: "Close-up portrait of a woman, 85mm lens, soft golden hour lighting,199serene mood, shallow depth of field, professional photography"200```201202**For Illustrations/Art:**203```204[Subject], [art style], [color palette], [details], [mood]205206Example: "Kawaii cat sticker, bold black outlines, cel-shading, pastel colors,207cute expression, chibi style"208```209210**For Logos:**211```212[concept], [style], [elements], [colors], [context]213214Example: "Tech startup logo, minimalist geometric design, abstract network nodes,215blue and silver gradient, professional, vector style"216```217218**For Product Photography:**219```220[product], [setting], [lighting], [presentation], [context]221222Example: "Wireless earbuds, white background, studio lighting, 3/4 angle view,223clean minimal composition, e-commerce product shot"224```225226**Key principles:**227- Be specific and detailed228- Include lighting, composition, and mood229- Specify style clearly (photorealistic, illustration, etc.)230- Mention camera/lens for photorealistic (85mm, wide angle, macro)231- For text in images, use Pro model and specify exact text232233### Step 4: Implement API Call234235#### For Gemini Models:236237> **Note**: The `google.generativeai` package has been deprecated. Use `google.genai` instead.238> See migration guide: https://ai.google.dev/gemini-api/docs/migrate239240```python241from google import genai242from google.genai import types243from pathlib import Path244245# Initialize client (uses GEMINI_API_KEY or GOOGLE_API_KEY env var automatically)246client = genai.Client()247248# Basic text-to-image249response = client.models.generate_content(250 model="gemini-2.5-flash-image", # or gemini-3-pro-image-preview251 contents=prompt_text,252 config=types.GenerateContentConfig(253 response_modalities=["TEXT", "IMAGE"],254 # Optional configurations:255 # image_config=types.ImageConfig(256 # aspect_ratio="1:1", # 1:1, 3:4, 4:3, 9:16, 16:9, 21:9257 # image_size="1K", # 1K, 2K, 4K (Pro only)258 # )259 )260)261262# Extract and save image263for part in response.parts:264 if part.text is not None:265 print(part.text)266 elif part.inline_data is not None:267 image = part.as_image()268 image.save("output.png")269270# For image editing (pass existing image):271from PIL import Image272273image = Image.open("input.png")274response = client.models.generate_content(275 model="gemini-2.5-flash-image",276 contents=[image, "Make the background a sunset scene"],277 config=types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"])278)279280# For multi-turn refinement (use chat):281chat = client.chats.create(282 model="gemini-2.5-flash-image",283 config=types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"])284)285response1 = chat.send_message("A futuristic city skyline")286response2 = chat.send_message("Add more neon lights and flying cars")287```288289#### For Google Imagen 4 Models:290291```python292from google import genai293from google.genai import types294295# Initialize client (uses GEMINI_API_KEY or GOOGLE_API_KEY env var automatically)296client = genai.Client()297298# Imagen 4 text-to-image (no editing support)299# Also available: imagen-4.0-fast-generate-001, imagen-4.0-ultra-generate-001300response = client.models.generate_images(301 model="imagen-4.0-generate-001",302 prompt=prompt_text,303 config=types.GenerateImagesConfig(304 number_of_images=4, # 1-4 for standard, 1 for Ultra305 aspect_ratio="1:1", # 1:1, 3:4, 4:3, 9:16, 16:9306 person_generation="allow_adult", # "dont_allow", "allow_adult", "allow_all"307 )308)309310# Save images311for i, generated_image in enumerate(response.generated_images):312 generated_image.image.save(f"output_{i}.png")313```314315#### For OpenAI Models (gpt-image-1.5 recommended):316317```python318from openai import OpenAI319from pathlib import Path320import base64321322client = OpenAI() # reads OPENAI_API_KEY env var automatically323324# gpt-image-1.5 generation (recommended)325response = client.images.generate(326 model="gpt-image-1.5",327 prompt=prompt_text,328 size="1024x1024", # or "1536x1024", "1024x1536", "auto"329 quality="high", # "low", "medium", "high"330 n=1, # 1-10 images331 output_format="png", # "png", "jpeg", "webp"332 background="auto", # "transparent", "opaque", "auto"333 moderation="auto", # "auto" or "low" for less restrictive334)335336# Response returns base64 data337image_data = base64.b64decode(response.data[0].b64_json)338Path("output.png").write_bytes(image_data)339340# gpt-image-1 generation (for max 4K resolution)341response = client.images.generate(342 model="gpt-image-1",343 prompt=prompt_text,344 size="1024x1024",345 quality="high",346 n=1,347)348349# Image editing with gpt-image-1.5350response = client.images.edit(351 model="gpt-image-1.5",352 image=open("input.png", "rb"),353 prompt="Change the background to a beach sunset",354 size="1024x1024",355)356357# Legacy DALL-E 3 generation358response = client.images.generate(359 model="dall-e-3",360 prompt=prompt_text,361 size="1024x1024", # or "1024x1792", "1792x1024"362 quality="standard", # or "hd"363 n=1,364)365image_url = response.data[0].url366367# Download URL-based response368import requests369image_data = requests.get(image_url).content370Path("output.png").write_bytes(image_data)371```372373**Implementation approach:**374- Use `Bash` tool to execute Python scripts with API calls375- Check for API keys in environment variables376- Handle errors gracefully (API limits, invalid prompts, etc.)377- Save images with descriptive filenames378- Report image location to user379380### Step 5: Handle Output3813821. **Save the generated image** to an appropriate location3832. **Verify the output** meets the request3843. **Show the user** the saved file path3854. **Offer refinement** if the result isn't quite right3865. **Explain the prompt used** so the user understands the generation387388### Step 6: Iterate if Needed389390If the user wants changes:391- For Gemini: Use chat interface to maintain context392- For gpt-image-1.5: Use editing API for precise face/logo preservation393- For Imagen/DALL-E: Generate new image with updated prompt394- Keep previous versions for comparison395- Suggest specific adjustments based on the current result396397## Requirements398399**API Keys:**400- Google (Gemini/Imagen): Set `GOOGLE_API_KEY` or `GEMINI_API_KEY` environment variable401- OpenAI: Set `OPENAI_API_KEY` environment variable402403**Python Packages:**404```bash405pip install google-genai openai pillow requests406```407408> **Note**: The `google-generativeai` package has been deprecated and will no longer receive updates.409> Use `google-genai` instead. Migration guide: https://ai.google.dev/gemini-api/docs/migrate410411**System:**412- Python 3.8+413- Internet connection for API access414- Write permissions for saving images415416**Approximate Costs (per image):**417| Model | Low Quality | High Quality |418|-------|-------------|--------------|419| imagen-4.0-fast | $0.02 | $0.02 |420| imagen-4.0 | - | ~$0.04 |421| imagen-4.0-ultra | - | ~$0.08 |422| gemini-2.5-flash-image | ~$0.039 | ~$0.039 |423| gpt-image-1.5 | ~$0.016 | ~$0.15 |424| gpt-image-1 | ~$0.02 | ~$0.19 |425| dall-e-3 | ~$0.04 | ~$0.08 |426| dall-e-2 | ~$0.02 | ~$0.02 |427428## Best Practices429430### Prompt Engineering4314321. **Be Specific**: Vague prompts produce inconsistent results433 - Bad: "a nice landscape"434 - Good: "mountain valley at sunrise, mist over lake, pine trees, warm golden light, peaceful atmosphere"4354362. **Include Technical Details** for photorealism:437 - Camera: "shot on 85mm lens", "wide angle 24mm", "macro photography"438 - Lighting: "golden hour", "studio lighting", "rim light", "soft diffused"439 - Quality: "high resolution", "detailed", "sharp focus", "professional photography"4404413. **Specify Style Clearly**:442 - "photorealistic", "oil painting", "watercolor", "digital art", "3D render"443 - "minimalist", "detailed", "abstract", "realistic", "stylized"444 - "anime style", "pixel art", "vector art", "charcoal sketch"4454464. **Use Examples and References**:447 - "in the style of [artist/art movement]"448 - "similar to [known visual reference]"449 - For Gemini Pro: Provide actual reference images4504515. **Negative Prompts** (what to avoid):452 - DALL-E doesn't support negative prompts directly453 - For Gemini, phrase as positive instructions: "clear sky" vs "no clouds"454455### Model-Specific Tips456457**gpt-image-1.5 (Recommended):**458- Best for iterative editing workflows - preserves faces/logos during edits459- Built-in reasoning understands context (e.g., "Bethel, NY, August 1969" → Woodstock)460- Excellent text rendering, especially dense/small text461- Great for infographics, diagrams, multi-panel compositions462- 4x faster than gpt-image-1, use streaming for real-time feedback463- Use `background="transparent"` for assets464465**gpt-image-1:**466- Maximum resolution (4096x4096) when needed467- Good for one-shot high-res generation468- No editing/inpainting support469470**Imagen 4 Family:**471- Best text rendering among Google models472- Use Fast ($0.02) for high-volume prototyping473- Use Ultra for highest quality single images474- Text-to-image only (no editing) - use Gemini for edits475- All images include SynthID watermark476477**Gemini Flash (2.5) - Nano Banana:**478- Best for iterative multi-turn editing via chat479- Good for generating multiple variations quickly480- Use for draft/concept phase with refinement481482**Gemini Pro (3) - Nano Banana Pro:**483- Use for final deliverables and 4K output484- Best for complex compositions with reference images (up to 14)485- "Thinking" mode generates interim drafts for composition planning486- Leverage Google Search grounding for current events/real places487488**DALL-E 3 (Legacy):**489- Excellent at understanding natural language490- Strong at creative interpretations491- Automatic prompt expansion (may deviate from exact request)492493**DALL-E 2 (Legacy):**494- More literal interpretation of prompts495- Can generate variations of existing images496- Budget-friendly for simple tasks497498### Quality Guidelines4995001. **Start with clear requirements**: Ask clarifying questions before generating5012. **Choose appropriate model**: Match model capabilities to requirements5023. **Iterate thoughtfully**: Make specific changes rather than complete regeneration5034. **Save intermediate versions**: Keep promising iterations5045. **Respect usage policies**: Follow content policies for each platform5056. **Credit the tool**: Disclose AI-generated images when sharing506507### Error Handling508509- **API key missing**: Prompt user to set environment variable510- **Invalid prompt**: Suggest refinements, check content policy511- **Rate limits**: Inform user and suggest retry timing512- **Generation failure**: Try simpler prompt or different model513- **Unsatisfactory result**: Offer to regenerate with adjusted prompt514515## Examples516517### Example 1: Logo Design518519**User request:** "Create a logo for a coffee shop called 'Morning Brew'"520521**Expected behavior:**5221. Ask user about style preference (modern, vintage, minimalist, etc.)5232. Ask about color preferences5243. Select model (gpt-image-1.5 for text rendering, or gemini-3-pro-image-preview for 4K)5254. Generate with prompt: "Coffee shop logo for 'Morning Brew', minimalist modern design,526 coffee cup with steam forming sunrise rays, warm brown and orange colors,527 clean professional aesthetic, vector style, white background"5285. Use `background="transparent"` for gpt-image-1.5 for easy placement5296. Save image and show path5307. Offer to generate variations with different styles531532### Example 2: Product Photography533534**User request:** "Generate product photos of wireless earbuds"535536**Expected behavior:**5371. Select model (imagen-4.0-generate-001 for photorealism, or gpt-image-1.5 for editing)5382. Generate with prompt: "Wireless earbuds product photography, white background,539 professional studio lighting, 3/4 angle view showing charging case and earbuds,540 clean minimal composition, high resolution, sharp focus, e-commerce quality"5413. Generate additional angles if requested5424. Save all versions543544### Example 3: Illustration545546**User request:** "Create a cute sticker of a robot"547548**Expected behavior:**5491. Select model (gpt-image-1.5 with `background="transparent"` for stickers)5502. Generate with prompt: "Cute robot sticker, kawaii style, bold black outlines,551 cel-shading, pastel blue and silver colors, big friendly eyes, rounded shapes,552 chibi proportions, white border, transparent background suitable for sticker"5533. Save and offer variations554555### Example 4: Image Editing556557**User request:** "Change the background of this photo to a beach sunset"558559**Expected behavior:**5601. Use `Read` tool to load the existing image5612. Select model (gpt-image-1.5 for best editing with face preservation, or Gemini for chat-based iteration)5623. Generate with image + prompt: "Change the background to a beautiful beach at sunset,563 golden hour lighting, warm colors, ocean and palm trees visible, maintain the subject564 in foreground, seamless composition"5654. Save edited image566567### Example 5: Iterative Refinement568569**User request:** "Generate a futuristic city" → "Add more neon lights" → "Make it rain"570571**Expected behavior:**5721. First generation: "Futuristic city skyline, towering skyscrapers, advanced architecture,573 night scene, detailed, cinematic lighting"5742. Use gpt-image-1.5 edit API or Gemini chat interface to maintain context5753. Second refinement: "Add vibrant neon lights throughout the city, cyberpunk aesthetic,576 glowing signs and billboards"5774. Third refinement: "Add rain effect, wet streets reflecting neon lights, atmospheric,578 moody"5795. Save each version with descriptive names580581## Limitations5825831. **Content Policies**: All models have content restrictions (no violence,584 explicit content, copyrighted characters, real people without consent)5852. **Text Rendering**: Much improved in gpt-image-1.5 and Imagen 4, but very long/complex text may still have issues5863. **Photorealism of People**: May not perfectly capture specific facial features; gpt-image-1.5 preserves faces best during edits5874. **Complex Compositions**: Very complex scenes may need multiple iterations5885. **Consistency**: Hard to maintain exact consistency across multiple generations; use gpt-image-1.5 or Gemini Pro with reference images for character consistency5896. **Real-time Events**: Results may not reflect very recent events (use Gemini Pro Search grounding for current topics)5907. **API Costs**: Be mindful of usage; see pricing table above5918. **Rate Limits**: APIs have rate limits; may need to wait between requests5929. **Imagen Limitations**: Text-to-image only (no editing), single image for Ultra model59310. **Watermarks**: Google Imagen images include SynthID watermark594595## Related Skills596597- `python-plotting` - For data visualization and charts598- `brainstorming` - For ideating visual concepts599- `scientific-writing` - For figure captions and documentation600- `python-best-practices` - For writing clean API integration code601602## Additional Resources603604- **Google GenAI SDK Migration Guide**: https://ai.google.dev/gemini-api/docs/migrate605- **Gemini Image Generation**: https://ai.google.dev/gemini-api/docs/image-generation606- **Imagen API Documentation**: https://ai.google.dev/gemini-api/docs/imagen607- **OpenAI Images API**: https://platform.openai.com/docs/api-reference/images608- **gpt-image-1.5 Prompting Guide**: https://cookbook.openai.com/examples/multimodal/image-gen-1.5-prompting_guide609- **Deprecated SDK Info**: https://github.com/google-gemini/deprecated-generative-ai-python610- **Prompt Engineering Guide**: See `references/prompt-engineering.md`