Skip to main content
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 the api.apiyi.com console) into nano-banana-pro/.env:
The script reads the key from this .env automatically — no extra configuration or environment variables needed.
.env holds your secret key. If you share this skill via a project repo, be sure to add .env to .gitignore and never commit it to git.

③ 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”.
Once installed, you’re ready — jump to How to use it for examples.

SKILL.md

Create nano-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):
name must be lowercase letters + hyphens and must not contain reserved words like claude / anthropic. On Agents that support slash commands, the directory name is the command — nano-banana-pro becomes /nano-banana-pro. ${CLAUDE_SKILL_DIR} is a skill-directory variable provided by Claude Code; on other Agents just use the script’s actual path.

scripts/nano_banana.py

Create nano-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:
The default model name is gemini-3-pro-image (the stable name). To use the original gemini-3-pro-image-preview, set APIYI_IMAGE_MODEL=gemini-3-pro-image-preview — both share the same price and are functionally equivalent.

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 the description 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:

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):
How to control aspect ratio and sharpness: use --aspect for the aspect ratio (e.g. --aspect 16:9, 10 options) and --size for the resolution (1K / 2K / 4K). Just say “make it portrait 9:16”, “square image”, or “render in 4K” and the Agent will add these flags automatically.

Where the generated image goes

  • When -o is a bare filename (e.g. -o dog.png), images are all saved into a nano-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 .git or .claude found 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 3 produces 3 at once (max 5, anything more is clamped to 5), with a -1, -2, -3 suffix added automatically.
  • When -o is a path with a directory (e.g. -o images/dog.png or an absolute path), it is saved at that exact path (relative paths are relative to the current working directory) and does not go into nano-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.