在 Hermes Agent 中使用 Imagen 4。
Imagen 4 是 Google DeepMind 的圖像生成模型,具有精準的文字渲染和高提示詞保真度。Hermes Agent 透過與聊天相同的 RunAPI custom provider 端點呼叫它,無需 ComfyUI 或 GPU 設定。
Use RunAPI to generate an image with Google Imagen 4 from Hermes Agent.
Requirements:
- Read the API key from RUNAPI_API_KEY. Do not hardcode the key.
- Use the custom:runapi provider already configured in Hermes Agent.
- 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"
}
三步在 Hermes Agent 中使用 Imagen 4
設定 RunAPI
設定 RUNAPI_API_KEY 環境變數。若已在 Hermes Agent 中將 RunAPI 設定為 custom:runapi provider 用於聊天,同一個 key 和 base_url 也適用於圖像生成。
export RUNAPI_API_KEY=runapi_xxx
呼叫 Imagen 4
向 text_to_image 端點發送 POST 請求,將 model 設為 imagen-4,並附上描述性提示詞。視需要加入 aspect_ratio 或 negative_prompt。
POST /v1/text_to_image
取得結果
回應包含一個 task_id。輪詢任務狀態端點,直到狀態變為 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 |
選填。生成圖像中需要避免的內容。 |
Hermes Agent 上的 Imagen 4 是什麼?
Google DeepMind 的 Imagen 4 在頭對頭比較中名列前茅,文字渲染更乾淨,提示詞遵循比大多數競品更嚴格。其三層系統(Fast、Standard、Ultra)讓你能針對每張圖像選擇成本與品質的權衡,而非為所有圖像固定同一品質等級。Hermes Agent 透過 RunAPI custom provider 呼叫它——無需 Vertex AI 專案或 GCP 帳號。
Imagen 4 使用情境
適合團隊使用的圖像生成
非技術型團隊成員也能調整提示詞並生成可用圖像——Imagen 4 嚴格遵循提示詞,無需提示詞工程專業知識。
探險與編輯風格攝影
生成編輯品質的攝影作品——風景、美食、建築、生活風格——具備精確的光線、景深和自然色調。
成本最佳化批次生成
在單一工作流程中混用層級——草稿輪次用 Fast(每張 $0.02),最終精選用 Ultra——在不犧牲最終輸出品質的前提下控制批次成本。
Imagen 4 + Hermes Agent 常見問題
可以。Hermes Agent 透過 RunAPI text_to_image 端點呼叫 Imagen 4。將 model 欄位設為 imagen-4,並使用為 custom:runapi provider 設定的同一個 RUNAPI_API_KEY 發送請求。無需 ComfyUI 或 GPU 租用。
不需要。同一個 RUNAPI_API_KEY 適用於聊天、圖像、影片和音樂的 113+ 個模型。一個 key,一個計費帳戶。
非同步。初始請求傳回狀態為 pending 的 task_id。輪詢任務狀態端點直到任務完成,然後從回應中取得圖像 URL。RunAPI SDK 會自動處理輪詢。
Imagen 4 按用量計費,無月度最低消費。價格因方案而異:imagen-4-fast 最便宜,imagen-4 為標準方案,imagen-4-ultra 品質最高。請查看 RunAPI 定價頁面取得最新每張價格。
立即在 Hermes Agent 中試用 Imagen 4。
取得免費 RunAPI key,設定 custom:runapi provider,開始使用 Google Imagen 4 生成圖像。