Skip to main content
This page provides a ready-to-use Agent Skill: drop it into the coding agent you already use, and you can call APIYI’s Nano Banana 2 Lite (gemini-3.1-flash-lite-image) with natural language (or explicit commands) to generate and edit images. The whole thing is just two files — copy and go.
If you need higher quality or 2K/4K, see the Nano Banana 2 Agent Skill (up to 4K) or the Nano Banana Pro Agent Skill (ultimate quality). This page is Lite (fastest and cheapest, focused on 1K, $0.025/image per-call).

What this skill does

A single merged skill — the script auto-detects whether images are passed to decide between “text-to-image” and “image editing”:

Text-to-Image

Prompt only → generate a brand-new image, supporting 14 aspect ratios, 1K canvas, ~4s per image.

Image Editing

Pass one image + instruction → local edits, style transfer, background replacement, etc.

Multi-Image Compositing

Pass multiple images + one instruction → compositing, comparison, outfit swaps, and more.
Nano Banana 2 Lite is built for speed and cost: ~4s per image, ~2.7x faster than Nano Banana 2, token-based averaging ~$0.018/call in practice (40% of Google’s rate) and per-call $0.025/image — ideal for high concurrency, rapid iteration, and volume.

Which agents can use it

A Skill is essentially just a folder: a description written for the agent (SKILL.md) + a script that does the work. So any coding agent that can read local files and run the command line can use it — e.g. 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 internet access (the script connects directly to api.apiyi.com). That’s it — no specific agent required.

Install in three steps

① Create the folder, paste the files

Create a skill folder and add the two files below (full contents in the next two sections):

② Write your Key in the same folder

In nano-banana-lite/.env, add your APIYI API Key (created in the api.apiyi.com console):
The script reads the Key from this .env automatically — no extra config or environment variables needed.
.env holds your secret key. If this skill will be shared with a project repo, be sure to add .env to .gitignore and never commit it to git.

③ Hand it to the agent

  • Agents with skill auto-discovery (like Claude Code): put the whole nano-banana-lite/ folder into its skills directory — user-level ~/.claude/skills/ or project-level .claude/skills/ (shared with the repo).
  • Other agents: place it per their own skill/plugin conventions; or simplest of all — just tell the agent “read the SKILL.md in this folder and follow it”.
Once installed, jump to How to use for examples.

SKILL.md

Create nano-banana-lite/SKILL.md with the full contents below (the description states “what it does + when to use”, which the agent uses to auto-trigger):
name must be lowercase letters + hyphens and must not contain reserved words like claude / anthropic. In agents with slash commands, the folder name is the command name — nano-banana-lite means /nano-banana-lite. ${CLAUDE_SKILL_DIR} is the skill-directory variable Claude Code provides; other agents just use the script’s actual path.

scripts/nano_banana_lite.py

Create nano-banana-lite/scripts/nano_banana_lite.py using the Gemini native format (identical to this site’s text-to-image / image-editing code, verified working). Pure Python standard library — no pip install needed:
The model name defaults to gemini-3.1-flash-lite-image. Lite is focused on the 1K canvas — keep --size at 1K; for 2K/4K or stronger quality, use the Nano Banana 2 / Pro skills (you can also switch model via the APIYI_IMAGE_MODEL environment variable).

Why a single sentence generates an image

Many people wonder: I didn’t type a command, so how does saying “draw a cat” produce an image? Here’s how: when the agent starts, it first reads the description in each skill’s SKILL.md (a short piece of metadata stating “what this skill does and when to use it”). When your request matches that description’s scenario (e.g. “draw/generate/render an image”, “change this image to…”), the agent automatically decides to invoke this skill, reads the full SKILL.md, and runs the script — all without you memorizing any commands. 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 100% control, use the explicit invocation below.

How to use

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 options:
  • Agents with slash commands (like Claude Code):
  • Any agent / just tell it to run the script (most universal):
Controlling the ratio: use --aspect to pick the aspect ratio (1 of 14, including the ultra-tall/ultra-wide 1:4 / 4:1 / 1:8 / 8:1). Lite is focused on the 1K canvas, so no resolution needs to be specified. Just say “portrait 9:16” or “make an ultra-wide banner” and the agent will add the aspect parameter automatically.

Where the generated images are

  • When -o is just a filename (e.g. -o dog.png), images are saved to the nano-banana-output/ folder at the project root (auto-created), so you can find them right there in the project.
  • The “project root” = the first directory containing .git or .claude found by walking up from the script — no matter which directory the agent runs in, images land inside the project, not in a temp directory where you’d lose them.
  • The script prints one full absolute path per image, e.g. Image saved to /Users/you/project/nano-banana-output/dog.png.
  • By default only 1 image is generated; -n 3 outputs 3 at once (max 5, auto-capped above that), with -1, -2, -3 suffixes added to the filename.
  • When you pass a path with a directory (e.g. -o images/dog.png or an absolute path), it saves to your given path (relative paths relative to the current working directory), not into nano-banana-output/.
  • Image editing works the same way: the output is a new file and never overwrites your original.
Nano Banana 2 Lite has strict content-safety controls. If the script reports finishReason other than STOP or returns a rejection text, adjust the content per the message — don’t repeatedly retry the same violating prompt.