在 OpenClaw 中使用 Imagen 4。
Imagen 4 是 Google DeepMind 的圖像生成模型,具備準確的文字渲染和高 prompt 保真度。OpenClaw agent 透過與聊天相同的 RunAPI 端點和 API key 呼叫它——無需安裝額外 skills。
Use RunAPI to generate an image with Google Imagen 4.
Requirements:
- Read the API key from RUNAPI_API_KEY. Do not hardcode the key.
- Send a POST request to https://runapi.ai/v1/text_to_image.
- Set the model to imagen-4.
- Write a descriptive prompt for the image you want.
- The response returns a task_id. Poll the task status endpoint until the task completes.
- When the task is complete, retrieve the image URL from the response.
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "imagen-4",
"prompt": "A ceramic coffee mug on a wooden table with morning light, the text HELLO printed on the side in serif font, photorealistic"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "imagen-4"
}
三步驟在 OpenClaw 中使用 Imagen 4
設定 RunAPI
設定 RUNAPI_API_KEY 環境變數。如果你已在 OpenClaw 中將 RunAPI 設定為聊天 provider,同一個 key 亦適用於圖像生成。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Imagen 4
向 text_to_image 端點發送 POST 請求,將 model 設為 imagen-4,並附上描述性 prompt。如有需要,可加入 aspect_ratio 或 negative_prompt。
POST /v1/text_to_image
取得結果
回應包含 task_id。輪詢 task status 端點直到狀態變為 completed。完成的回應包含生成的圖像 URL。
task_id: tsk_abc123
Imagen 4 API 參數
| 參數 | 類型 | 說明 |
|---|---|---|
model |
string |
必填。imagen-4、imagen-4-fast 或 imagen-4-ultra。 |
prompt |
string |
描述所需圖像的文字。 |
aspect_ratio |
string |
可選。例如 1:1、16:9、9:16。 |
negative_prompt |
string |
可選。在生成圖像中需要避免的內容。 |
OpenClaw 上的 Imagen 4 是什麼?
Imagen 4 是 Google DeepMind 的圖像模型,提供三檔——Fast 用於快速原型、Standard 用於生產環境、Ultra 用於最高細節——最便宜的檔位每張約 $0.02。OpenClaw agent 通過同一個 RunAPI key 呼叫所有三檔。
Imagen 4 使用場景
大規模快速原型
使用 Fast 檔以每張 $0.02 進行快速概念探索,在確定方向後再切換至 Standard 或 Ultra 檔,生成若干變體。
含可讀文字的 UI 與標籤設計
生成界面效果圖、產品標籤和標牌設計,其中嵌入的文字可清晰渲染並嚴格遵循提示詞。
寫實紋理與材質
創作寫實材質紋理、復古旅行明信片和充滿冒險感的攝影場景,光線和表面細節精準。
Imagen 4 + OpenClaw 常見問題
可以。OpenClaw agent 透過 RunAPI text_to_image 端點呼叫 Imagen 4。將 model 欄位設為 imagen-4,使用與聊天相同的 RUNAPI_API_KEY 發送請求即可。無需額外 skills 或插件。
不需要。同一個 RUNAPI_API_KEY 適用於所有 113+ 個模型——聊天、圖像、影片和音樂。一個 key,一個計費帳戶。
Imagen 4 是非同步的。初始請求返回狀態為 pending 的 task_id。輪詢 task status 端點直到任務完成,然後從回應中取得圖像 URL。RunAPI SDK 會自動處理輪詢。
Imagen 4 按用量付費,無最低月費。費用因版本而異:imagen-4-fast 最便宜,imagen-4 為標準,imagen-4-ultra 畫質最高。請查看 RunAPI 收費頁面了解每張圖片的最新價格。