在 Hermes Agent 中使用 Flux Kontext。
Black Forest Labs 的 Flux Kontext 支援文字引導的圖像編輯與生成,並具備角色一致性。Hermes Agent 透過 RunAPI 使用 custom:runapi provider 呼叫它——與聊天使用的 key 和 base URL 相同。
Use RunAPI to generate an image with Flux Kontext Pro through Hermes Agent.
Requirements:
- Use the custom:runapi provider already configured in Hermes Agent
- Call the RunAPI text_to_image endpoint at https://runapi.ai/v1/text_to_image
- Set model to "flux-kontext-pro"
- The RUNAPI_API_KEY environment variable provides 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"
}
三步驟在 Hermes Agent 中使用 Flux Kontext
設定 RunAPI
設定 RUNAPI_API_KEY 環境變數。如果你已在 Hermes Agent 中將 RunAPI 新增為 custom:runapi provider 用於聊天,則同一個 key 和 base_url 亦適用於圖像生成——無需額外設定。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Flux Kontext
向 text_to_image 端點發送 POST 請求,將 model 設為 flux-kontext-pro,並附上描述所需圖像的文字 prompt。如需上下文編輯,可選擇性傳入 image_url。
text_to_image
取得結果
端點返回 task ID。輪詢 task status 端點,直到狀態變為 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 |
可選。輸出長寬比。 |
Hermes Agent 上的 Flux Kontext 是什麼?
Flux Kontext 是 Black Forest Labs 基於 120 億參數整流流變換器構建的指令式圖像編輯器,支持多輪編輯——可以依序進行多次修改,模型在每一步都保留上一步的上下文。Hermes Agent 通過 RunAPI 自訂 provider 端點呼叫它,便於構建多步驟編輯工作流程。
Flux Kontext 使用場景
多輪編輯工作流
依次鏈接多個編輯步驟——生成圖像、調整光線、替換背景、添加文字——每一步在上一步結果的基礎上繼續。
風格轉換工作流程
在保留被攝對象構圖的前提下將照片轉換為油畫、素描或動漫風格,用於同一內容的風格變體創作。
天氣與光線調整
無需從頭重新生成整個場景,即可修改現有照片中的時間、天氣或光線設置。
Flux Kontext + Hermes Agent 常見問題
可以。在 Hermes Agent 中將 RunAPI 設定為 custom:runapi provider,然後以 model 設為 flux-kontext-pro 呼叫 text_to_image 端點。用於聊天的同一個 RUNAPI_API_KEY 亦適用於圖像生成。
不需要。同一個 RUNAPI_API_KEY 適用於所有 RunAPI 模型——LLM、圖像、影片和音樂。一個 key,一個計費帳戶。
非同步。API 立即返回 task ID。輪詢 task status 端點,或使用 webhook callback 接收已完成的圖像 URL。
Flux Kontext Pro 每張圖片起價 2.5 美分。Flux Kontext Max 畫質更高,價格亦較貴。請查看 RunAPI 收費頁面了解最新價格——按用量付費,無需訂閱。
立即在 Hermes Agent 中試用 Flux Kontext。
取得免費 RunAPI key,設定 custom:runapi provider,開始使用 Flux Kontext 生成圖像。