This page provides a ready-to-use Agent Skill: drop it into the coding Agent you already use, and use natural language (or an explicit command) to call Nano Banana Pro (
gemini-3-pro-image) on the APIYI platform for image generation and editing. The whole thing is just two files — copy and go.What the skill does
A single combined skill. The script auto-detects whether you pass input images to decide between text-to-image and image editing:Text to image
Prompt only → a brand-new image, with 10 aspect ratios and 1K/2K/4K resolution.
Image editing
One image + an instruction → local edits, restyle, background replacement, and more.
Multi-image compositing
Multiple images + one instruction → compositing, comparison, outfit swaps, etc.
Which Agents can use it
A Skill is essentially just a folder: a set of instructions for the Agent to read (
SKILL.md) + a script that does the work. So any coding Agent that can read local files and run shell commands can use it — for example Codex, OpenClaw, hermes-agent, Claude Code, and more.The only requirement: the machine running the Agent (your computer or server) has Python 3 installed and network access (the script calls api.apiyi.com directly). That’s it — it is not tied to any specific Agent.Set up in 3 steps
① Create the folder and paste the files
Create a skill folder with these two files (full contents in the next two sections):② Put your key in the same folder
Write your APIYI API Key (create one in theapi.apiyi.com console) into nano-banana-pro/.env:
.env automatically — no extra configuration or environment variables needed.
③ Hand it to your Agent
- Agents that auto-discover skills (e.g. Claude Code): drop the whole
nano-banana-pro/folder into its skills directory — personal~/.claude/skills/, or project-level.claude/skills/(shared via the repo). - Other Agents: place it per their own skill/plugin convention; or simplest of all — just tell the Agent to “read the SKILL.md in this folder and follow it”.
SKILL.md
Createnano-banana-pro/SKILL.md with the full content below (the description states “what it does + when to use it”, which is what the Agent uses to auto-trigger it):
scripts/nano_banana.py
Createnano-banana-pro/scripts/nano_banana.py using the Gemini-native format (identical to the verified, working code on the APIYI text-to-image / image-edit reference pages). Pure Python standard library — no pip install needed:
Why a single sentence generates an image
People often wonder: I never typed a command, so how did “draw a cat” produce an image? Here’s how: at startup, the Agent first reads thedescription from each skill’s SKILL.md (a very short piece of metadata describing “what this skill does and when to use it”). When your request matches that scenario (e.g. “draw / generate / render an image”, “edit this image to…”), the Agent automatically decides to invoke the skill, reads the full SKILL.md, and runs the script — all without you remembering any command.
So:
- A well-written
description= more accurate auto-triggering. This skill’s description already covers phrasings like “generate / draw / edit / composite an image”. - When you don’t want the Agent to guess and want full control, use the explicit invocation below.
How to use it
Natural language (implicit trigger)
Once installed, just talk to the Agent:| What you say | Skill behavior |
|---|---|
| ”Draw a 16:9 snow-mountain sunrise poster with nano banana” | Runs the script (no -i), 1 png |
| ”Blur the background of photo.jpg to emphasize the subject” | Runs -i photo.jpg, 1 png |
| ”Give me 3 different Chinese ink landscapes” | Runs -n 3, 3 pngs concurrently |
| ”Composite the people in a.png and b.png into one photo” | Runs -i a.png -i b.png, 1 png |
Explicit invocation (more control)
When you don’t want the Agent to decide for itself, two explicit ways:-
Agents that support slash commands (e.g. Claude Code):
-
Any Agent / just tell it to run the script (most universal):
Where the generated image goes
- When
-ois a bare filename (e.g.-o dog.png), images are all saved into anano-banana-output/folder at the project root (created automatically), so you’ll find them right there in your project. - “Project root” = the first directory containing
.gitor.claudefound by walking up from the script’s own location — so no matter which directory the Agent runs from, images land inside the project, never in a temp directory you can’t find. - The script prints one full absolute path per image, e.g.
Image saved to /Users/you/project/nano-banana-output/dog.png. - By default it generates just 1 image;
-n 3produces 3 at once (max 5, anything more is clamped to 5), with a-1,-2,-3suffix added automatically. - When
-ois a path with a directory (e.g.-o images/dog.pngor an absolute path), it is saved at that exact path (relative paths are relative to the current working directory) and does not go intonano-banana-output/. - Image editing works the same way: the output is a new file and does not overwrite your original.
Nano Banana Pro has strict content-safety controls. If the script reports a
finishReason other than STOP or returns a rejection text, adjust your content accordingly and do not repeatedly retry the same violating prompt. See the error handling guide on the generation reference.