--- name: nano-banana description: Generate or edit images using Google Nano Banana (Gemini image generation API). Trigger this skill whenever the user asks to generate an image, draw something, create artwork, edit a photo, or mentions "nano banana", "nanobanana", or any AI image generation/editing need — even if they don't explicitly mention Nano Banana. Proactively use this skill for any image creation or transformation request. --- # Nano Banana — Image Generation Skill Generate or edit images locally using the Google Gemini image generation API (a.k.a. Nano Banana). ## Quick Workflow 1. Check environment (API key + dependencies) 2. Identify the mode: text-to-image / image editing / batch generation 3. Choose the right model 4. **Use the bundled scripts directly** — no need to rewrite them 5. Run the script and save output to `/var/minis/attachments/` 6. Display the result inline in the conversation --- ## Environment Setup ### Check API Key ```bash source /etc/profile && echo $GEMINI_API_KEY | head -c 10 ``` > ⚠️ Always run `source /etc/profile` first — environment variables are stored there and won't be available otherwise. If not set, direct the user to [Google AI Studio](https://aistudio.google.com/apikey) to obtain a key, then: ```bash echo 'export GEMINI_API_KEY="your_key_here"' >> /etc/profile ``` ### Check Dependencies ```bash pip show google-genai pillow 2>&1 | grep -E "^Name|not found" ``` If missing: ```bash pip install google-genai pillow ``` --- ## Model Selection | Model | Model ID | Best For | |-------|----------|----------| | **Nano Banana 2** (recommended) | `gemini-3.1-flash-image-preview` | Fast, high quality, 2K support — default choice | | **Nano Banana Pro** | `gemini-3-pro-image-preview` | Complex prompts, professional assets, precise text rendering | | **Nano Banana (original)** | `gemini-2.5-flash-image` | Ultra-low latency, simple tasks | **Default to `gemini-3.1-flash-image-preview`** unless the user explicitly requests another version. --- ## ⚠️ Known API Pitfalls ### 1. Aspect ratio / resolution config ❌ **Wrong** (old API, throws `AttributeError`): ```python # types.ImageGenerationConfig does not exist! image_generation_config=types.ImageGenerationConfig(aspect_ratio="16:9") ``` ✅ **Correct**: ```python config=types.GenerateContentConfig( response_modalities=["IMAGE"], image_config=types.ImageConfig( aspect_ratio="16:9", # options: 1:1, 4:3, 3:4, 16:9, 9:16 image_size="2K", # options: 1K, 2K (default: 1K) ), ) ``` ### 2. Environment variable loading ❌ Running `python3 script.py` directly may not have the API key ✅ Always prefix with `source /etc/profile && python3 script.py` ### 3. Saving images `part.as_image()` returns a PIL Image object — call `.save(path)` directly. No need to handle base64 manually. --- ## Bundled Scripts Run any script with: ```bash source /etc/profile && python3 /nano-banana/scripts/