
flux-kontext
使用 Flux 1 Kontext Pro(Black Forest Labs 的精確局部影像編輯模型)在 RunComfy 上編輯圖片 — 內建模型官方提示模式,讓技能輸出比直接對同一模型下提示更精準。說明 Flux Kontext 的優勢(單參考精確局部編輯、強大的提示控制、一致的高保真輸出)、輸入結構(單張圖片 + 提示),以及何時改用 Nano Banana Edit / GPT Image 2 edit / Flux 2 Klein。透過本機 RunComfy CLI 呼叫 `runcomfy run blackforestlabs/flux-1-kontext/pro/edit`。觸發詞為「flux kontext」、「flux-kontext」、「flux 1 kontext」、「kontext」、「BFL kontext」,或任何明確要求使用此模型編輯的指令。
Edit images with Flux 1 Kontext Pro (Black Forest Labs' precise local image-edit model) on RunComfy — bundled with the model's documented prompting patterns so the skill gets sharper output than naive prompting against the same model. Documents Flux Kontext's strengths (single-reference precise local edits, strong prompt control, consistent high-fidelity outputs), the schema (single image + prompt), and when to route to Nano Banana Edit / GPT Image 2 edit / Flux 2 Klein instead. Calls `runcomfy run blackforestlabs/flux-1-kontext/pro/edit` through the local RunComfy CLI. Triggers on "flux kontext", "flux-kontext", "flux 1 kontext", "kontext", "BFL kontext", or any explicit ask to edit with this model.
Flux Kontext Pro — Pro Pack on RunComfy
runcomfy.com · 模型頁面 · GitHub
Black Forest Labs 的 Flux 1 Kontext Pro — 單參考精確局部影像編輯 — 託管於 RunComfy Model API。強大的提示控制、一致的輸出、高保真度。
npx skills add agentspace-so/runcomfy-skills --skill flux-kontext -g
何時選擇此模型(相較於同系列其他模型)
| 您想要 | 使用 |
|---|---|
| 單張影像精確局部編輯(「她現在拿著X」) | Flux Kontext |
| 高保真保留來源身份 | Flux Kontext |
| 批次編輯 1–20 張影像 | Nano Banana Edit |
| 編輯影像中的多語言/嵌入文字 | GPT Image 2 edit |
| 從頭生成,無來源影像 | Flux 2 Klein |
如果使用者明確提到「Flux Kontext」/「kontext」/「BFL Kontext」,無論如何都路由至此。
前置需求
- RunComfy CLI —
npm i -g @runcomfy/cli - RunComfy 帳號 —
runcomfy login會開啟瀏覽器裝置碼流程。 - CI / 容器環境 — 設定
RUNCOMFY_TOKEN=<token>取代runcomfy login。
端點 + 輸入結構
blackforestlabs/flux-1-kontext/pro/edit
| 欄位 | 型別 | 必填 | 預設值 | 備註 |
|---|---|---|---|---|
prompt |
string | 是 | — | 單一宣告式編輯指令。 |
image |
string | 是 | — | 單一來源影像 URL(可公開存取的 HTTPS)。 |
aspect_ratio |
enum | 否 | (輸入) | 從模型頁面支援的 W:H 選項中選擇。 |
seed |
int | 否 | — | 重複使用以比較變體。 |
此結構刻意精簡 — Kontext 依賴提示 + 單一參考。如需多影像或網路來源編輯,請路由至 Nano Banana Edit。
如何呼叫
預設 — 局部編輯,保留其他所有內容:
runcomfy run blackforestlabs/flux-1-kontext/pro/edit \
--input '{
"prompt": "保持人物的臉部、姿勢和服裝不變。在她的左手加一把橘色雨傘,並加上微笑。",
"image": "https://.../portrait.jpg"
}' \
--output-dir <絕對路徑>
使用 seed 以產生可重現的變體系列:
runcomfy run blackforestlabs/flux-1-kontext/pro/edit \
--input '{
"prompt": "保持瓶子、標籤和燈光不變。將標籤上的品牌文字從 \"ALPHA\" 改為 \"AURA\"。",
"image": "https://.../bottle.jpg",
"seed": 42
}' \
--output-dir <絕對路徑>
提示技巧 — 實際有效的方法
單一宣告式指令。 Kontext 在類似官方範例的提示上表現最佳:"She is now holding an orange umbrella and smiling"。使用祈使句,單一變更。
先保留。 以 "Keep [identity / pose / framing / brand] unchanged." 開頭,然後再進行變更。模型會優先遵循前面陳述的內容。
僅單一參考 — 選擇正確的那個。 此處無多影像分發。如果您有多個參考,請決定哪個是主要的並傳遞該參考。如需多影像流程,請路由至 Nano Banana Edit。
逐步進行小變更。 如果 Kontext 偏離,請將複合編輯拆分為連續的單一指令傳遞(傳遞 1:更改背景,傳遞 2:更改服裝)。
長寬比 — 從支援的列舉中選擇。 清單外的值會導致 422 或裁切。
反模式:
- 複合提示(「更改 A 並添加 B 並移除 C」)→ 偏離。
- 嘗試分發到多個來源影像 → 錯誤模型(使用 Nano Banana Edit)。
- 被動語態的提示 → 較不可靠。
- 要求沒有來源影像的新構圖 → 錯誤模型(使用 Flux 2 Klein t2i)。
適用場景
| 使用案例 | 為何選擇 Flux Kontext |
|---|---|
| 單次精確局部編輯 | 專為此設計;高保真度 |
| 透過目標變更保留來源身份 | 在明確指令下具有強大的保留能力 |
| 品牌資產文字或顏色替換 | 引號文字 + 保留前置效果良好 |
| 單張影像快速迭代 | 簡短提示 + 單一參考 = 快速結果循環 |
範例提示(經驗證可產生強勁結果)
頁面範例:
She is now holding an orange umbrella and smiling
保留主導的品牌編輯:
Keep the bottle silhouette, table, and lighting exactly as in the input.
Replace only the brand text on the label, from "ALPHA" to "AURA".
Same font weight, white on black, centered.
構圖微編輯:
Keep the person's face, pose, and clothing unchanged. Add a leather
shoulder bag, dark brown, hanging on the right shoulder.
限制
- 僅單一來源影像。 如需多影像流程,請使用 Nano Banana Edit(1–20)。
- RunComfy 官方文件較簡略 — 除了 prompt + image + aspect_ratio + seed 之外可能還有其他結構欄位;請查看模型頁面以取得最新欄位清單。
- 複合提示會偏離 — 請拆分為連續傳遞。
- 對於多語言/嵌入文字編輯,GPT Image 2 edit 通常表現較佳。
退出碼
| 碼 | 意義 |
|---|---|
| 0 | 成功 |
| 64 | CLI 參數錯誤 |
| 65 | 輸入 JSON 錯誤 / 結構不符 |
| 69 | 上游 5xx |
| 75 | 可重試:逾時 / 429 |
| 77 | 未登入或 token 被拒絕 |
完整參考:docs.runcomfy.com/cli/troubleshooting。
運作方式
此技能使用符合結構的 JSON 主體呼叫 runcomfy run blackforestlabs/flux-1-kontext/pro/edit。CLI 會 POST 到 https://model-api.runcomfy.net/v1/models/blackforestlabs/flux-1-kontext/pro/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 的請求,以防止惡意或失控模型輸出導致磁碟填滿。





