在 OpenClaw 中使用 Qwen 2 Image。
Qwen 2 Image 是阿里巴巴的圖像生成和編輯模型。OpenClaw agent 透過與聊天相同的 RunAPI 端點呼叫它——發送提示詞,取得圖像 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.
- 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"
}
三步在 OpenClaw 中使用 Qwen 2 Image
設定 RunAPI
將 RunAPI API key 設定為環境變數。若尚未在 OpenClaw 中新增 RunAPI 作為 provider,請先參考 OpenClaw 設定指南。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Qwen 2 Image
將提示詞貼到 OpenClaw,或直接呼叫 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 |
選填。輸出尺寸。 |
OpenClaw 上的 Qwen 2 Image 是什麼?
Qwen 2 Image 是阿里巴巴的圖像模型,透過單一 API 涵蓋生成、編輯和混音三種模式。它擅長多語言提示詞理解(尤其是中英文),能很好地處理複雜的多物件場景,並支援以自然語言描述要更改內容的指令式編輯。OpenClaw 代理透過同一個 RunAPI 端點呼叫三種模式。
Qwen 2 Image 使用情境
多語言行銷活動
從中文、英文或混合語言文字撰寫的提示詞生成圖像,用於雙語行銷素材,無需事先翻譯提示詞。
指令式圖像編輯
用純文字描述更改內容來修改現有圖像——替換背景、添加物件、調整光線或移除元素,無需開啟編輯器。
針對特定領域微調開源權重模型
將 Qwen 2 Image 的輸出用作訓練資料或基準,在針對特定領域圖像任務(如商品型錄或品牌內容)微調開源 Qwen 模型時使用。
Qwen 2 Image + OpenClaw 常見問題
可以。OpenClaw 支援自訂 OpenAI 相容 provider。新增 RunAPI,設定 baseUrl 為 https://runapi.ai/v1 和你的 RUNAPI_API_KEY,然後以 qwen-2-text-to-image 為 model 呼叫 text_to_image 端點。同一個 provider 同時處理聊天和圖像生成。
不需要。用於聊天模型的同一個 RUNAPI_API_KEY 也可以呼叫 Qwen 2 Image 和 RunAPI 目錄中的所有其他模型。一個 key,一個餘額,一個控制台。
非同步。端點立即傳回任務 ID。輪詢任務狀態端點或使用 webhook 回呼了解圖像是否已就緒。RunAPI SDK 和 CLI 會自動處理輪詢。
Qwen 2 Image 按任務計費。請查看 RunAPI 定價頁面取得最新價格。沒有月度訂閱或最低消費——只為完成的生成付費。