在 Hermes Agent 中使用 GPT Image。
GPT Image 2 是 OpenAI 專用的圖片生成模型 — 文生圖和基於指令的圖片編輯,支援最高 4K 輸出解析度和透明背景。Hermes Agent 透過與聊天相同的 RunAPI custom provider 和 API key 呼叫,無需 ComfyUI 或 GPU 設定。
Use RunAPI to generate an image with OpenAI GPT Image 2 from Hermes Agent.
Requirements:
- Use the RunAPI API at https://runapi.ai/v1/text_to_image.
- Read the API key from RUNAPI_API_KEY environment variable.
- Use the custom:runapi provider already configured in Hermes Agent.
- Set the model to "gpt-image-2-text-to-image".
- Write a descriptive prompt. GPT Image 2 follows natural language instructions closely — describe layout, style, text overlays, and transparency needs.
- Optionally set output_resolution to 1k, 2k, or 4k. Default is 1k.
- The response returns a task_id. Poll the task status endpoint until the task completes, then retrieve the output URL.
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-text-to-image",
"prompt": "A product photo of a glass perfume bottle on a marble surface, transparent background, studio lighting, the label reads AURORA in gold serif font",
"output_resolution": "2k",
"aspect_ratio": "3:4"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "gpt-image-2-text-to-image"
}
三步驟在 Hermes Agent 中使用 GPT Image
設定 RunAPI
在 shell 設定檔中設定 RUNAPI_API_KEY 環境變數。如果 custom:runapi provider 已在 Hermes Agent 中設定用於聊天,同一個 key 和 base_url 也適用於 GPT Image — 無需額外設定。
export RUNAPI_API_KEY=runapi_xxx
呼叫 GPT Image 2
向 text_to_image 端點發送 POST 請求,model 設為 gpt-image-2-text-to-image。加入帶有版面和風格指示的描述性 prompt。將 output_resolution 設為 2k 或 4k 以獲得更高細節。若要編輯現有圖片,使用 edit_image 端點搭配 gpt-image-2-image-to-image 並提供 source_image_urls。
POST /v1/text_to_image
取得結果
API 會立即回傳 task_id。輪詢任務狀態端點,直到狀態變為 completed,然後從回應中取得輸出圖片 URL。GPT Image 2 通常在 10–30 秒內完成,視解析度而定。
task_id: tsk_abc123
GPT Image API 參數
| 參數 | 類型 | 說明 |
|---|---|---|
model |
string |
必填。gpt-image-2-text-to-image 用於生成,gpt-image-2-image-to-image 用於編輯。 |
prompt |
string |
必填。期望圖片的自然語言描述。支援版面、文字疊加和風格的詳細指示。 |
output_resolution |
string |
選填。輸出解析度 — 1k(預設)、2k 或 4k。較高解析度的每張圖片費用較高。 |
aspect_ratio |
string |
選填。預設為 auto。支援 1:1、3:2、2:3、4:3、3:4、16:9、9:16 等。 |
source_image_urls |
array |
edit_image 端點必填。一個或多個要編輯的來源圖片 URL。 |
Hermes Agent 上的 GPT Image 是什麼?
GPT Image 2 將提示詞視為製作簡報,而非鬆散的關鍵字清單。它在生成前包含一個推理步驟,有助於遵循版面、文字位置和構圖的結構化指示。使用者發現它最適合搭配較簡單、結構清晰的提示詞——複雜的多輪次修改可能引入雜訊模式。Hermes Agent 透過 RunAPI custom provider 呼叫它。
GPT Image 使用情境
透明背景商品攝影
在透明背景上生成商品照,用於合成行銷素材、型錄或電商商品列表,無需手動遮罩。
社群媒體活動圖形
創建含嵌入文字、品牌色彩和多張活動圖像間一致風格的社群媒體視覺素材——在提示詞中指定確切文字。
影片轉換用電影靜幀
生成適合影片的首幀和電影靜幀,可作為影片生成工作流程的關鍵幀,或作為獨立的編輯插圖。
GPT Image + Hermes Agent 常見問題
可以。Hermes Agent 透過 RunAPI text_to_image 端點呼叫 GPT Image 2。將 model 欄位設為 gpt-image-2-text-to-image,使用與 custom:runapi provider 設定相同的 RUNAPI_API_KEY 發送請求。無需 ComfyUI 或 GPU 租用。
GPT Image 2 是 OpenAI 專用的圖片生成模型,品質更高,支援 4K 輸出和透明背景。GPT-4o Image 在聊天情境中生成圖片,但僅限於 1:1、3:2 或 2:3 長寬比。兩者都可透過 RunAPI 使用 — 使用 gpt-image-2-text-to-image 進行獨立生成,使用 gpt-4o-image 進行聊天整合的圖片輸出。
支援。GPT Image 2 可在 prompt 中指示時輸出帶有透明背景的圖片。這對需要合成的商品照片、標誌和 UI 元素很有用。在 prompt 中描述透明度 — 例如「product shot on transparent background」。
GPT Image 2 按每張圖片依輸出解析度計費:1k、2k 或 4k。GPT-4o Image 按每張圖片依輸出數量計費 — 單次請求生成 2 或 4 張圖片時每張費用更高。兩者都採用按量付費,無月度最低消費。請查看 RunAPI 定價頁面了解最新費率。
可以。使用 edit_image 端點搭配 model 設為 gpt-image-2-image-to-image。在 source_image_urls 中傳入來源圖片,並用自然語言描述編輯內容 — 「remove the background」、「add sunglasses」、「change the text to HELLO」。無需 ComfyUI 工作流圖、無需 GPU 實例、無需修補遮罩。
立即在 Hermes Agent 中試用 GPT Image。
取得免費的 RunAPI key,設定 custom:runapi provider,即可開始使用 OpenAI GPT Image 2 生成和編輯圖片。