在 Hermes Agent 中使用 Qwen 2 Image。
Qwen 2 Image 是阿里巴巴的圖像生成和編輯模型。Hermes Agent 透過 RunAPI custom provider 端點呼叫它——發送提示詞,取得圖像 URL。透過三種模型變體支援文生圖、圖像編輯和圖像重混。
Use RunAPI to generate an image with Qwen 2 Image.
Requirements:
- Call the RunAPI text_to_image endpoint at https://runapi.ai/api/v1/task/text_to_image.
- Set the model to "qwen-2-text-to-image".
- Read the API key from the RUNAPI_API_KEY environment variable.
- Use the custom:runapi provider configured in Hermes Agent.
- The response returns a task_id. Poll the task status endpoint until the task completes, then retrieve the image URL from the output.
- For image editing, use model "qwen-2-edit-image" and include an image_url field.
- For remixing, use model "qwen-2-remix-image" and include an image_url field.
curl -X POST https://runapi.ai/api/v1/task/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-2-text-to-image",
"prompt": "A traditional Chinese ink painting of misty mountains at dawn, elegant brushwork"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "qwen-2-text-to-image"
}
三步在 Hermes Agent 中使用 Qwen 2 Image
設定 RunAPI
設定 RunAPI API key 為環境變數。若尚未在 Hermes Agent 中新增 RunAPI 作為 custom provider,請參考 Hermes Agent 設定指南,使用 base_url https://runapi.ai/v1 新增 custom:runapi。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Qwen 2 Image
將提示詞貼到 Hermes Agent,或直接呼叫 text_to_image 端點。將 model 欄位設為 qwen-2-text-to-image(生成)、qwen-2-edit-image(編輯)或 qwen-2-remix-image(重混)。
text_to_image
取得結果
端點傳回任務 ID。輪詢任務狀態端點,直到狀態變為 completed,然後從輸出中讀取圖像 URL。RunAPI SDK 會自動處理輪詢。
task_id: tsk_abc123
Qwen 2 Image API 參數
| 參數 | 類型 | 說明 |
|---|---|---|
model |
string |
必填。qwen-2-text-to-image、qwen-2-edit-image 或 qwen-2-remix-image。 |
prompt |
string |
文字描述或編輯指令。 |
image_url |
string |
編輯或重混模式的來源圖像。 |
size |
string |
選填。輸出尺寸。 |
Hermes Agent 上的 Qwen 2 Image 是什麼?
Qwen 2 Image 是阿里巴巴的圖像模型,透過單一 API 提供三種模式——生成、編輯和混音。Hermes Agent 透過 custom:runapi provider 呼叫它。它能處理複雜的多物件場景,原生理解中文、英文和混合語言文字的提示詞,特別適合多語言內容流程。
Qwen 2 Image 使用情境
代理工作流程中的迭代圖像編輯
在單次 Hermes Agent 執行中串接多個 Qwen 2 編輯步驟——生成初始圖像,再依序套用一系列文字引導的更改,如替換背景、調整顏色或添加元素。
新創公司的低成本圖像生成
將 Qwen 2 Image 作為高量圖像生成任務(如商品模擬稿、社群媒體內容或開發期間的佔位圖片)的高性價比替代方案。
雙語內容製作
無需翻譯即可從中英文提示詞生成圖像,在單一工作流程中為雙語行銷活動或本地化商品頁面製作視覺素材。
Qwen 2 Image + Hermes Agent 常見問題
可以。Hermes Agent 支援自訂 OpenAI 相容 provider。將 RunAPI 新增為 custom:runapi,設定 base_url 為 https://runapi.ai/v1,key_env 為 RUNAPI_API_KEY,api_mode 為 chat_completions。然後以 qwen-2-text-to-image 為 model 呼叫 text_to_image 端點。
不需要。用於聊天模型的同一個 RUNAPI_API_KEY 也可以呼叫 Qwen 2 Image 和 RunAPI 目錄中的所有其他模型。一個 key,一個餘額,一個控制台。
非同步。端點立即傳回任務 ID。輪詢任務狀態端點或使用 webhook 回呼了解圖像是否已就緒。RunAPI SDK 和 CLI 會自動處理輪詢。
Qwen 2 Image 按任務計費。請查看 RunAPI 定價頁面取得最新價格。沒有月度訂閱或最低消費——只為完成的生成付費。