
nano-banana-edit
使用 RunComfy 上的 Google Nano Banana 2(图生图编辑端点)编辑图像。本文档介绍了 Nano Banana Edit 的优势(保持主体身份、替换背景、使用空间语言进行局部编辑、最多 20 张图像的多图像批量编辑)、模式,以及何时改用 GPT Image 2 编辑 / Flux Kontext / Nano Banana 2 t2i。通过本地 RunComfy CLI 调用 `runcomfy run google/nano-banana-2/edit`。触发词为“nano banana edit”、“edit with nano banana”、“image edit nano banana”或任何明确要求使用此模型进行编辑的请求。
Edit images with Google Nano Banana 2 (image-to-image edit endpoint) on RunComfy. Documents Nano Banana Edit's strengths (preserve subject identity, swap background, localize edits with spatial language, multi-image batch edits up to 20 inputs), the schema, and when to route to GPT Image 2 edit / Flux Kontext / Nano Banana 2 t2i instead. Calls `runcomfy run google/nano-banana-2/edit` through the local RunComfy CLI. Triggers on "nano banana edit", "edit with nano banana", "image edit nano banana", or any explicit ask to edit with this model.
Nano Banana Edit — Pro Pack on RunComfy
runcomfy.com · Edit endpoint · GitHub
Google Nano Banana 2 Edit — Gemini 系列闪速级图像模型的图生图编辑端点,托管在 RunComfy Model API 上。每次调用最多支持 20 张输入图像,用于批量编辑和多参考变体。
npx skills add agentspace-so/runcomfy-skills --skill nano-banana-edit -g
何时选择此模型(与同类模型对比)
| 需求 | 使用 |
|---|---|
| 保持主体身份,替换背景或服装 | Nano Banana Edit |
| 在单次批量中一致地编辑最多 20 张图像 | Nano Banana Edit |
| 使用空间语言将编辑定位到“仅 X” | Nano Banana Edit |
| 编辑图像中的多语言文本(标志、标签) | GPT Image 2 edit |
| 单参考 + 精确局部编辑(“她现在拿着 X”) | Flux Kontext |
| 从头生成新图像 | Nano Banana 2 t2i(同类技能) |
如果用户明确提到“nano banana edit”/“edit with nano banana”,则无论其他情况都路由至此。
前提条件
- RunComfy CLI —
npm i -g @runcomfy/cli - RunComfy 账户 —
runcomfy login会打开浏览器设备码流程。 - CI / 容器 — 设置
RUNCOMFY_TOKEN=<token>代替runcomfy login。
端点 + 输入模式
google/nano-banana-2/edit
| 字段 | 类型 | 必需 | 默认值 | 说明 |
|---|---|---|---|---|
prompt |
string | 是 | — | 编辑指令。以保留开头,以更改结尾。 |
image_urls |
array | 是 | — | 1–20 个可公开获取的 HTTPS URL。 |
number_of_images |
int | 否 | 1 | 每次调用 1–4 个输出。 |
seed |
int | 否 | — | 可复现性。 |
aspect_ratio |
enum | 否 | auto |
auto(跟随输入)或固定比例 — 锁定以实现批量一致性。 |
resolution |
enum | 否 | 1K |
0.5K / 1K / 2K / 4K。 |
output_format |
enum | 否 | png |
png / jpeg / webp。 |
safety_tolerance |
int | 否 | 4 | 1(严格)– 6(宽松)。 |
limit_generations |
bool | 否 | — | 如果为 true,则限制每轮仅生成一个输出。 |
enable_web_search |
bool | 否 | false | 网络搜索(额外成本/延迟)。 |
如何调用
单图像背景替换,保持身份:
runcomfy run google/nano-banana-2/edit \
--input '{
"prompt": "Keep the subject identity, pose, and clothing unchanged. Convert the background into a rainy neon cyberpunk street.",
"image_urls": ["https://.../portrait.jpg"]
}' \
--output-dir <absolute/path>
锁定构图的批量编辑:
runcomfy run google/nano-banana-2/edit \
--input '{
"prompt": "Replace the watermark in the bottom-right with the text \"AURA\" in clean white sans-serif. Keep everything else exactly as in the input.",
"image_urls": ["https://.../sku-1.jpg", "https://.../sku-2.jpg", "https://.../sku-3.jpg"],
"aspect_ratio": "1:1",
"resolution": "1K"
}' \
--output-dir <absolute/path>
定向空间编辑(仅左侧对象):
runcomfy run google/nano-banana-2/edit \
--input '{
"prompt": "Remove the leftmost object only. Keep the right two objects, the table, and the lighting unchanged.",
"image_urls": ["https://.../still-life.jpg"]
}' \
--output-dir <absolute/path>
提示技巧 — 实际有效的方法
先保留,后更改。 始终以 "Keep [identity / pose / clothing / brand / framing] unchanged." 开头。然后用一句清晰的句子说明更改内容。模型会优先处理开头声明的部分;末尾的保留指令会被忽略。
使用空间语言定位。 “仅背景”、“左侧对象”、“右上角”、“标题上方” — 具体的空间范围会被遵守。“让它更 X” 是模糊的,会导致偏移。
批量一致性 — 编辑系列时,锁定 aspect_ratio 和 resolution。在整个批次中使用相同的提示语法,使每个输出看起来像兄弟版本,而不是重新混合。
小步迭代。 如果一次编辑出现偏移,分成两步:第一步仅更改背景,第二步更换主体的服装。编辑更干净,总成本相同(假设分辨率相似)。
多图像变体 — 最多传入 20 张输入以获得一致的批次。适用于 SKU 图库、A/B 测试、角色表变体。
反模式:
- 冗长的复合指令(“更改 A 和 B 和 C 和 D”)— 每增加一个范围,偏移风险增加。
- 被动语态的编辑指令(“背景应该被更改”)— 请使用祈使句。
- 缺少保留目标 — 模型会微妙地重写面部/品牌。
- 与输入不匹配的宽高比 — 导致裁剪或拉伸。
优势场景
| 用例 | 为什么选择 Nano Banana Edit |
|---|---|
| SKU 图库 — 同一产品在不同背景上 | 批量 20 张,保持身份,锁定构图 |
| 网红/发言人背景替换 | 跨编辑保持身份能力强 |
| 局部对象移除/添加 | 遵守空间语言 |
| 广告创意的 A/B 变体 | 种子锁定 + 多个 number_of_images |
| 品牌资产重新本地化 | 相同构图,文本/调色板替换 |
示例提示(已验证可产生强结果)
背景替换(页面示例):
Keep the subject identity unchanged. Convert the background into a rainy
neon cyberpunk street.
定向文本替换:
Keep the bottle, label, and lighting exactly as in the input.
Replace only the brand text on the label from "ALPHA" to "AURA",
same font weight, centered, white on black.
多图像批量一致性:
For each input image: keep the subject's pose and identity unchanged.
Convert the background to a soft warm-grey studio sweep with subtle
floor shadow. Center the subject at the same fraction of frame as the
input.
限制
- 每次调用 1–20 张输入图像 — 第一张被视为主要图像;其余提供辅助线索。
- 每次调用 1–4 个输出。
- 长复合提示会偏移 — 分成多次传递。
- 网络搜索增加延迟和成本 — 仅在需要时启用。
- 对于多语言图像内文本编辑,GPT Image 2 edit 更优。
退出码
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 64 | CLI 参数错误 |
| 65 | 输入 JSON 错误 / 模式不匹配 |
| 69 | 上游 5xx 错误 |
| 75 | 可重试:超时 / 429 |
| 77 | 未登录或令牌被拒绝 |
完整参考:docs.runcomfy.com/cli/troubleshooting。
工作原理
该技能使用符合模式的 JSON 主体调用 runcomfy run google/nano-banana-2/edit。CLI 将 POST 请求发送到 https://model-api.runcomfy.net/v1/models/google/nano-banana-2/edit,轮询请求,获取结果,并将任何 .runcomfy.net/.runcomfy.com URL 下载到 --output-dir。Ctrl-C 在退出前取消远程请求。
安全与隐私
- 令牌存储:
runcomfy login将 API 令牌写入~/.config/runcomfy/token.json,权限模式为 0600(仅所有者读写)。在 CI/容器中设置RUNCOMFY_TOKEN环境变量以完全绕过文件。 - 输入边界:用户提示通过
--input作为 JSON 字符串传递给 CLI。CLI 不会对提示进行 shell 扩展;它直接将 JSON 主体通过 HTTPS 传输到 Model API。提示内容没有 shell 注入风险。 - 第三方内容:您传递的图像/蒙版/视频 URL 由 RunComfy 模型服务器获取,而不是由您机器上的 CLI 获取。将外部 URL 视为不可信;基于图像的提示注入是任何图像编辑/视频编辑模型的已知风险。
- 出站端点:仅
model-api.runcomfy.net(请求提交)和*.runcomfy.net/*.runcomfy.com(生成输出的下载白名单)。无遥测,无回调。 - 生成文件大小上限:CLI 会中止任何超过 2 GiB 的单个下载,以防止恶意或失控模型输出导致磁盘填满。





