← Back to Lessons
Claude Skills

Generate Images with Nano Banana Pro

Install a small skill that turns a text description into an image using Google's Nano Banana Pro (Gemini 3 Pro Image), right from Claude Code.
⏱ ~10 min

What you get. A small skill that takes a text description and hands you back an image, generated by Google's Nano Banana Pro (the gemini-3-pro-image-preview model) through the Gemini API. Ask Claude for a picture in plain language and it saves a PNG for you.

Two quick setups. First you create a Gemini API key so the skill can reach the model. Then you paste one prompt to install the skill. After that, you are generating images by just asking.

1
Create a Gemini API key
3 min

The skill authenticates to Google with a key from Google AI Studio.

Open Google AI Studio →

  1. Sign in with a Google account.
  2. Click Get API key, then Create API key.
  3. Copy the key and keep it somewhere safe.
  4. Set it as an environment variable so the skill can find it.

On Mac or Linux, add it to your shell profile, then restart your terminal:

echo 'export GEMINI_API_KEY="paste-your-key-here"' >> ~/.zshrc

On Windows, search Environment Variables, add a new user variable named GEMINI_API_KEY with your key as the value, then reopen your terminal.

Nano Banana Pro is a paid model

Creating the key is free, but Nano Banana Pro has no free API tier, so you must enable billing on the key's Google project to use it (roughly $0.13 per image). In AI Studio, open your key's project and turn on billing. Prefer to test for free first? The standard Nano Banana (Flash) model has a free daily quota, and the install step below tells you the one-line change to use it.

2
Install the skill
1 min

This is the part that actually puts the skill on your machine. Open Claude Code in any folder, paste the prompt below, and hit Enter. Claude creates the skill at ~/.claude/skills/nano-banana/, writes both files, installs the Python dependencies, and verifies it.

One-paste install prompt — self-contained, the SKILL.md and Python script are inline.

Install a global Claude Code skill called "nano-banana". Do all of the following: 1. Create the directory: ~/.claude/skills/nano-banana/scripts/ 2. Write the file ~/.claude/skills/nano-banana/SKILL.md with EXACTLY the content between the SKILL_START and SKILL_END markers (do not include the markers): ===SKILL_START=== --- name: nano-banana description: Generate an image from a text description using Google's Nano Banana Pro (Gemini 3 Pro Image) via the Gemini API. Use whenever the user asks to generate, create, make, or draw an image, picture, logo, illustration, or artwork from a text prompt. Requires a GEMINI_API_KEY with billing enabled (Nano Banana Pro is a paid model). --- # Nano Banana Pro Image Generator Generates a single image from a text prompt using the Gemini API model `gemini-3-pro-image-preview` (Google's "Nano Banana Pro") and saves it to a PNG file. ## When to use Trigger this skill when the user asks to generate, create, make, or draw an image, picture, logo, illustration, or artwork from a text description. ## Requirements - `GEMINI_API_KEY` in the environment. Create one at https://aistudio.google.com/apikey - Nano Banana Pro is a PAID model (no free API tier as of 2026), so billing must be enabled on the key's Google project. Roughly $0.13 per image. - Python packages: `google-genai`, `Pillow` ## How to run Run the bundled script with a prompt and, optionally, an output path and aspect ratio: python3 ~/.claude/skills/nano-banana/scripts/generate.py "<prompt>" [output.png] [aspect_ratio] Examples: python3 ~/.claude/skills/nano-banana/scripts/generate.py "a cozy coffee shop on a rainy evening, watercolor" coffee.png 16:9 python3 ~/.claude/skills/nano-banana/scripts/generate.py "a minimalist flat-vector logo of a fox" fox.png 1:1 ## Tips - Write the prompt as a full sentence describing the subject, style, lighting, and mood. Narrative prompts beat keyword lists. - Default aspect ratio is 1:1. Pass 16:9, 9:16, 4:3, etc. as the third argument. - Output is saved as a PNG at 2K resolution. ## Free alternative To test without billing, edit scripts/generate.py and change MODEL to gemini-2.5-flash-image (standard Nano Banana), which has a free daily quota. Quality is lower than Pro. ===SKILL_END=== 3. Write the file ~/.claude/skills/nano-banana/scripts/generate.py with EXACTLY the content between the PY_START and PY_END markers (do not include the markers): ===PY_START=== import os import sys from io import BytesIO MODEL = "gemini-3-pro-image-preview" # Nano Banana Pro. Change to gemini-2.5-flash-image for the free tier. def main(): args = sys.argv[1:] if not args: print('Usage: generate.py "<prompt>" [output.png] [aspect_ratio]') sys.exit(1) prompt = args[0] out = args[1] if len(args) > 1 else "image.png" aspect = args[2] if len(args) > 2 else "1:1" key = os.getenv("GEMINI_API_KEY") if not key: print("GEMINI_API_KEY is not set. Create one at https://aistudio.google.com/apikey") sys.exit(1) try: from google import genai from google.genai import types from PIL import Image except ImportError: print("Missing dependencies. Run: python3 -m pip install google-genai Pillow") sys.exit(1) client = genai.Client(api_key=key) try: resp = client.models.generate_content( model=MODEL, contents=[prompt], config=types.GenerateContentConfig( response_modalities=["TEXT", "IMAGE"], image_config=types.ImageConfig(aspect_ratio=aspect, image_size="2K"), ), ) except Exception as e: print("Image generation failed:", e) print("If this is a billing or quota error, Nano Banana Pro needs billing enabled.") sys.exit(1) for part in resp.candidates[0].content.parts: if getattr(part, "inline_data", None) and part.inline_data.data: Image.open(BytesIO(part.inline_data.data)).save(out) print("Saved image to", out) return print("No image was returned.") sys.exit(1) main() ===PY_END=== 4. Install the Python dependencies by running: python3 -m pip install google-genai Pillow 5. Verify both files exist, then print "nano-banana installed". If GEMINI_API_KEY is not set in my environment, remind me to set it.
3
Generate an image
1 min

With the skill installed and your key set, just ask Claude for a picture in plain language:

Use the nano-banana skill to generate an image of a cozy coffee shop on a rainy evening, warm light in the windows, watercolor style. Save it as coffee.png at 16:9.

Claude runs the skill and saves the PNG where you asked. Describe the subject, style, lighting, and mood in a full sentence. A narrative prompt gives the model far more to work with than a keyword dump like "coffee shop, rain, watercolor."

Want it free to start?

Open ~/.claude/skills/nano-banana/scripts/generate.py and change the MODEL line to gemini-2.5-flash-image. That is the standard Nano Banana, which has a free daily quota. Switch back to gemini-3-pro-image-preview for the higher-quality Pro results once billing is on.

4
If something is off

"GEMINI_API_KEY is not set"

The key is not set, or your terminal has not picked it up yet. Set it (Step 1) and open a fresh terminal.

A billing or quota error

Nano Banana Pro is a paid model and needs billing enabled on the key's Google project. Turn it on in AI Studio, or switch the script to the free Flash model using the tip above.

No module named google or PIL

The Python dependencies did not install. Run python3 -m pip install google-genai Pillow.

Questions?

Made by AI Service Engine · what is a skill? · build your own skill