Install
openclaw skills install banana-apiGenerate and edit images using Nano Banana (Gemini-3-Pro-Image-Preview) API. Handles automatic base64 encoding/decoding, image compression, and Discord integration. Use when users want to generate AI images via the Nano Banana service, edit existing photos with AI, or need a streamlined workflow for Gemini image generation without manually handling base64.
openclaw skills install banana-apiStreamlined client for Nano Banana's Gemini-3-Pro-Image-Preview API. Automatically handles the annoying base64 workflow, image compression, and Discord sending.
The Problem with Gemini API:
This Skill Provides:
python3 scripts/banana_gen.py "a cute fluffy cat on a window sill"
python3 scripts/banana_gen.py "transform into rock concert scene with leather jacket" \
--image /path/to/photo.png
python3 scripts/banana_gen.py "cyberpunk cityscape at night" \
--channel-id 1478746465328435412
Option 1: Config File (Recommended - Persistent)
# Interactive setup (stores in ~/.openclaw/workspace/config/banana-api.json)
python3 scripts/banana_gen.py --setup
# Or manually create config file
echo '{"api_key": "sk-your-key-here"}' > ~/.openclaw/workspace/config/banana-api.json
Option 2: Environment Variable
export BANANA_API_KEY="sk-xxxxxxxx"
Option 3: Command Line (One-time)
python3 scripts/banana_gen.py "prompt" --api-key "sk-xxx"
Generated images are saved to:
~/.openclaw/workspace/photos/{description}-{timestamp}.png
python3 scripts/banana_gen.py --show-config
# Simple prompt
python3 scripts/banana_gen.py "sunset over mountains"
# With aspect ratio hint
python3 scripts/banana_gen.py "portrait of a warrior" --ratio 2:3
# Custom filename tag
python3 scripts/banana_gen.py "cat playing piano" --name cat-piano
# Change setting/outfit
python3 scripts/banana_gen.py "wearing a red dress at the beach" \
--image ~/photos/portrait.png
# Change background
python3 scripts/banana_gen.py "standing in front of Tokyo skyline at night" \
--image ~/photos/selfie.png \
--name tokyo-night
# Artistic transformation
python3 scripts/banana_gen.py "oil painting style, renaissance portrait" \
--image ~/photos/photo.jpg
# Auto-send to channel
python3 scripts/banana_gen.py "dragon breathing fire" \
--channel-id 1478746465328435412
# Auto-send with custom name
python3 scripts/banana_gen.py "cute anime girl with blue hair" \
--channel-id 1478746465328435412 \
--name anime-girl
# Save locally only (no Discord)
python3 scripts/banana_gen.py "prompt" --no-send
# Custom output path
python3 scripts/banana_gen.py "prompt" --output ~/Desktop/my-image.png
# Different model (if available)
python3 scripts/banana_gen.py "prompt" --model gemini-2.5-flash-image
# Full example
python3 scripts/banana_gen.py "wizard casting spell in ancient library" \
--image ~/photos/me.png \
--ratio 2:3 \
--name wizard-me \
--channel-id 1478746465328435412
The script auto-generates filenames:
banana-{description}-{timestamp}.png--name for custom suffix: banana-{name}-{timestamp}.pngInput Image → Resize to 512px → JPEG compress (85%) → Base64 encode → API
↓
Output ← Base64 decode ← PNG save ← Response
1. Compress input image (if provided)
2. Build Gemini API request with base64 inlineData
3. POST to /v1beta/models/{model}:generateContent
4. Extract image from response.candidates[0].content.parts
5. Decode base64 and save to workspace/photos/
6. Send to Discord (if channel-id provided)
| Use Case | Recommended Tool |
|---|---|
| Quick Gemini image | banana-api ✅ |
| ComfyUI workflows | comfyui-gen |
| DALL-E / OpenAI | Use their direct API |
| Stable Diffusion | comfyui-gen |
| Problem | Solution |
|---|---|
| "PIL not available" | Install: pip install Pillow |
| "API key required" | Run --setup to save key, or set BANANA_API_KEY env var |
| "No image data found" | Model may have returned text only; try different prompt |
| Large output files | Normal for high-res images (500KB-2MB) |
| Discord send fails | Check channel ID and openclaw CLI access |
API Key is loaded in this order (first found wins):
--api-key command line argumentBANANA_API_KEY environment variable~/.openclaw/workspace/config/banana-api.json config fileTo persist the API key for future use:
python3 scripts/banana_gen.py --setup
python3 scripts/banana_gen.py [PROMPT] [OPTIONS]
Options:
--image, -i PATH Input image for editing
--ratio, -r RATIO Aspect ratio hint (e.g., 2:3, 16:9)
--model, -m MODEL Model name (default: gemini-3-pro-image-preview)
--output, -o PATH Custom output path
--name, -n NAME Filename suffix/tag
--channel-id, -c ID Discord channel ID to auto-send
--no-send Skip Discord sending
--api-key, -k KEY API key (or set BANANA_API_KEY)
--setup Interactive setup to save API key
--show-config Display current configuration
# Generate + send + reference
IMAGE=$(python3 scripts/banana_gen.py "cute cat" --name kitty | grep "OUTPUT_PATH:" | cut -d: -f2-)
echo "Generated: $IMAGE"
Call the script directly:
import subprocess
result = subprocess.run([
'python3', 'scripts/banana_gen.py',
'prompt here',
'--image', input_path,
'--channel-id', channel_id
], capture_output=True, text=True)