
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 · Model page · 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": "Keep the person'\''s face, pose, and clothing unchanged. Add an orange umbrella in her left hand and a slight smile.",
"image": "https://.../portrait.jpg"
}' \
--output-dir <absolute/path>
使用 seed 以產生可重現的變體系列:
runcomfy run blackforestlabs/flux-1-kontext/pro/edit \
--input '{
"prompt": "Keep the bottle, label, and lighting unchanged. Replace the brand text on the label from \"ALPHA\" to \"AURA\".",
"image": "https://.../bottle.jpg",
"seed": 42
}' \
--output-dir <absolute/path>
提示技巧 — 實際有效的方法
單一宣告式指令。 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 的單一下載,以防止惡意或失控的模型輸出導致磁碟空間耗盡。





