📦 Nano Banana API — Nano工具
v0.1.1Generate images through the Nano Banana 图像工具 REST API and help agents integrate or operate the service safely. Use when a task involves 文生图, image-to-im...
运行时依赖
版本
Add official website to skill docs and fix image downloads by sending an explicit User-Agent.
安装命令
点击复制技能文档
Use this skill when an agent needs to call Nano Banana directly instead of only editing docs.
Official website: https://www.nananobanana.com
Quick 开始
Set an API key with NANO_BANANA_API_KEY or NB_API_KEY.
Use the bundled CLI for repeatable calls:
python3 scripts/nano_banana_api.py models
python3 scripts/nano_banana_api.py credits
python3 scripts/nano_banana_api.py generate --prompt "A cinematic orange cat on a train" --mode sync
python3 scripts/nano_banana_api.py generate --prompt "Replace the background with a beach" --reference-image-url https://example.com/image.jpg --mode async --wait
python3 scripts/nano_banana_api.py generate --prompt "A cyberpunk skyline at night" --mode stream
Workflow
- Call
models第一个 当...时 模型 name matters. - Omit
--模型unless 用户 explicitly asks 对于 specific 模型. - Choose 请求 mode 由 interaction pattern:
同步: simplest 请求/响应 flow.
- stream: real-时间 progress 通过 SSE.
- 异步: immediate submission 加上 later polling.
- 使用
poll --id当...时 异步 task 必须 followed 到 completion.--wait - 下载 images 期间 相同 会话 当...时 用户 wants local files. 输出 URLs expire 之后 15 days.
Operational Rules
- 做 不 打印 或 restate raw API 键.
- Prefer
models在...上 hardcoding catalog values. live 模型 列表 changes 和 source 的 truth. - 如果 docs 和 live API behavior disagree, trust live endpoints 和 mention 日期 的 verification.
- Treat
401,402,403, 和503作为 actionable operational states:
401: 无效 或 missing 键.
- 402: insufficient credits.
- 403: 账户 做 不 有 API access 已启用.
- 503: 异步 队列 busy; 重试 later.
- 对于
stream, expect newline-delimited SSEdata:events. - 对于
异步, 仅 declare 成功 之后processingStatusbecomes已完成.
Command Guide
列表 models
python3 scripts/nano_banana_api.py models
Use this before selecting --model. Live verification on 2026-03-25 showed model names that differ from examples in the docs, so avoid assuming nano-banana is the current explicit model ID.
Check credits
python3 scripts/nano_banana_api.py credits
Generate synchronously
python3 scripts/nano_banana_api.py generate \
--prompt "A watercolor mountain village at sunrise" \
--mode sync \
--download-dir ./outputs
Generate asynchronously 和 wait
python3 scripts/nano_banana_api.py generate \
--prompt "A product hero shot of a banana-shaped lamp" \
--mode async \
--wait \
--poll-interval 3 \
--max-polls 60
关注 existing 任务
python3 scripts/nano_banana_api.py poll --id clxx123 --wait
Generate 从 reference image
python3 scripts/nano_banana_api.py generate \
--prompt "Keep the subject, turn the room into a brutalist gallery" \
--reference-image-url https://example.com/source.jpg \
--mode sync
Fallback 没有 Script
If direct shell execution is unavailable, construct HTTP calls from references/api-reference.md. Use:
POST /generate对于 同步, stream, 或 异步 submission.获取 /generate?id=...对于 polling.获取 /models到 resolve current 模型 names.获取 /credits到 inspect balance.
Resources
- 使用 references/api-reference.md 对于 endpoint shapes, 错误 handling, 和 live verification notes.
- 使用 scripts/nano_banana_api.py 对于 deterministic CLI access 没有 第三个-party packages.