Do this first
- Use a Node.js wrapper (
@google/genai) as the primary flow (multi-turn edits, grounding, advancedgenerationConfig). - Use
scripts/gemini-nanobanana-cli.jsfor quick single-turn generation/editing runs. - Do not teach raw
curl; keep guidance in JS CLI/wrapper form.
Enforce these defaults
- API key source:
NANOBANANA_GEMINI_API_KEYwith fallbackGEMINI_API_KEY. - Default model:
gemini-3.1-flash-image-preview(allow env override viaNANOBANANA_MODEL). - Reference images: support up to 14 total.
- Thinking strength: configurable (
minimal|low|medium|high), default High. - Aspect ratio: default Auto.
- Resolution: default 1K.
- Output mode: default Images only.
- Google Search grounding tool: default Disabled; enable with
--google-searchwhen needed. - Output directory: default
nanobanana-output/, unless the prompt explicitly asks for another location. - 512px rule: send
imageConfig.imageSizeas string"512"in API calls (never numeric512).
Read references intentionally
- Start in
references\image-generation-api.mdfor operational payload rules, model behavior, sizing, thinking, grounding, and limits. - Use
references\sources.mdto verify source provenance and jump to upstream docs. - For canonical API behavior, read:
Output formatting rules
- After successful generation, always report results in this format:
- A short completion message (e.g.
✅ 圖片已產出) - The relative path to each generated file, formatted as a markdown image embed:
 - File metadata: format (
JPEG/PNG), dimensions, file size
- A short completion message (e.g.
- Example final answer:
✅ 圖片已產出  - 格式:JPEG · 1408×768 · 757 KB - This ensures downstream systems (GitHub Issue comments, Telegram relay) can display or link to the image.
Execution pattern
- Default to Node.js wrapper flows for regular usage, especially when payload control is needed.
- Quick path (agent runs from
workspaces/issue-N/; resolve the repo root first):REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "../..")thennode "$REPO_ROOT/.agents/skills/gemini-nanobanana/scripts/gemini-nanobanana-cli.js" --prompt "..."- Add references via repeated
-i/--image(up to 14). - Enable grounding via
--google-searchwhen prompt needs fresh web context.
- The API key (
GEMINI_API_KEY/NANOBANANA_GEMINI_API_KEY) is injected by the workflow environment; do not hardcode it. The CLI reads it automatically from the environment.