在 OpenClaw 中使用 Flux Kontext。
Flux Kontext 由 Black Forest Labs 出品,支援文字引導的圖像編輯和生成,並保持角色一致性。OpenClaw agent 透過 RunAPI 呼叫它,與聊天使用相同的 API key——發送提示詞,取得圖像 URL。
Use RunAPI to generate an image with Flux Kontext Pro.
Requirements:
- Call the RunAPI text_to_image endpoint at https://runapi.ai/v1/text_to_image
- Set model to "flux-kontext-pro"
- Use the RUNAPI_API_KEY environment variable for authorization
- The response is async — poll the task status endpoint until the task completes, then retrieve the image URL
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-kontext-pro",
"prompt": "a matte-black water bottle on a beige stone surface, soft side light, studio photography"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "flux-kontext-pro"
}
三步在 OpenClaw 中使用 Flux Kontext
設定 RunAPI
設定 RUNAPI_API_KEY 環境變數。若已在 OpenClaw 中將 RunAPI 設定為 provider 用於聊天,同一個 key 也適用於圖像生成,無需額外設定。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Flux Kontext
向 text_to_image 端點發送 POST 請求,將 model 設為 flux-kontext-pro,並附上描述所需圖像的文字提示詞。如需上下文內編輯,可選填 image_url。
text_to_image
取得結果
端點傳回任務 ID。輪詢任務狀態端點,直到狀態變為 completed,然後從回應中取得生成的圖像 URL。
task_id: tsk_abc123
Flux Kontext API 參數
| 參數 | 類型 | 說明 |
|---|---|---|
model |
string |
必填。flux-kontext-pro 或 flux-kontext-max。 |
prompt |
string |
用於生成或編輯的文字指令。 |
image_url |
string |
用於上下文內編輯的來源圖像 URL。 |
aspect_ratio |
string |
選填。輸出長寬比。 |
OpenClaw 上的 Flux Kontext 是什麼?
Flux Kontext 是 Black Forest Labs 出品的連續圖像編輯模型,使用者評價它在精確修改方面「優於 ChatGPT 和 Gemini」。你用純文字描述要更改的內容,它就只修改那個部分,其餘保持不變——換上新衣服時臉部不變,替換背景時產品位置不動。OpenClaw 代理透過 RunAPI text_to_image 端點呼叫它。
Flux Kontext 使用情境
保留主體的背景替換
在主體維持原位的情況下替換產品或人像背景——無需遮罩、無需修補,只需一條文字指令。
服裝與外觀變更
在保留臉部特徵的前提下,為角色更換服裝、髮色或配件,適用於時尚模擬稿和角色設計迭代。
招牌與標籤上的文字替換
替換現有圖像中招牌、產品標籤或店面上的文字——在提示詞中輸入新文字,Flux Kontext 就會就地渲染。
Flux Kontext + OpenClaw 常見問題
可以。在 OpenClaw 中將 RunAPI 設定為 OpenAI 相容 provider,然後以 flux-kontext-pro 為 model 呼叫 text_to_image 端點。用於聊天的同一個 RUNAPI_API_KEY 也可以處理圖像生成。
不需要。同一個 RUNAPI_API_KEY 適用於所有 RunAPI 模型——LLM、圖像、影片和音樂。一個 key,一個計費帳戶。
非同步。API 立即傳回任務 ID。輪詢任務狀態端點或使用 webhook 回呼接收已完成的圖像 URL。
Flux Kontext Pro 起價每張 2.5 美分。Flux Kontext Max 精度更高,價格也更高。請查看 RunAPI 定價頁面取得最新價格——按用量計費,無需訂閱。