
nano-banana-edit
使用 RunComfy 上的 Google Nano Banana 2(圖像到圖像編輯端點)編輯圖片。說明 Nano Banana Edit 的優勢(保留主體身份、更換背景、使用空間語言進行局部編輯、最多 20 張圖片的批量編輯)、輸入結構,以及何時改用 GPT Image 2 edit / 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 — RunComfy 專業版
runcomfy.com · 編輯端點 · 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 <絕對路徑>
批量編輯,鎖定構圖:
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 <絕對路徑>
指定空間編輯(僅左側物體):
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 <絕對路徑>
提示技巧 — 實際有效的方法
先保留,後修改。 始終以 "Keep [identity / pose / clothing / brand / framing] unchanged." 開頭,然後用一句簡潔的句子說明修改內容。模型會優先處理開頭的保留指令;結尾的保留指令容易被忽略。
使用空間語言指定範圍。 「background only」、「the left object」、「the upper-right corner」、「above the headline」— 具體的空間範圍會被遵守。模糊的「make it more 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 | 未登入或 token 被拒絕 |
完整參考: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 可在退出前取消遠端請求。
安全性與隱私
- Token 儲存:
runcomfy login將 API token 寫入~/.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 的單一下載,以防止惡意或失控模型輸出導致磁碟空間耗盡。





