---
title: &quot;透過 RunAPI 在 Hermes Agent 中使用 GPT Image — 圖片 API 指南&quot;
url: &quot;https://runapi.ai/zh-TW/hermes-gpt-image.md&quot;
canonical: &quot;https://runapi.ai/zh-TW/hermes-gpt-image&quot;
locale: &quot;zh-TW&quot;
model: &quot;gpt-image&quot;
---

# 在 Hermes Agent 中使用 GPT Image。

GPT Image 2 是 OpenAI 專用的圖片生成模型 — 文生圖和基於指令的圖片編輯，支援最高 4K 輸出解析度和透明背景。Hermes Agent 透過與聊天相同的 RunAPI custom provider 和 API key 呼叫，無需 ComfyUI 或 GPU 設定。

## API example

```bash
curl -X POST https://runapi.ai/v1/text_to_image \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;gpt-image-2-text-to-image&quot;,
    &quot;prompt&quot;: &quot;A product photo of a glass perfume bottle on a marble surface, transparent background, studio lighting, the label reads AURORA in gold serif font&quot;,
    &quot;output_resolution&quot;: &quot;2k&quot;,
    &quot;aspect_ratio&quot;: &quot;3:4&quot;
  }&#39;

```

### Response

```json
{
  &quot;task_id&quot;: &quot;tsk_abc123&quot;,
  &quot;status&quot;: &quot;pending&quot;,
  &quot;model&quot;: &quot;gpt-image-2-text-to-image&quot;
}

```

## How it works

1. **設定 RunAPI** — 在 shell 設定檔中設定 RUNAPI_API_KEY 環境變數。如果 custom:runapi provider 已在 Hermes Agent 中設定用於聊天，同一個 key 和 base_url 也適用於 GPT Image — 無需額外設定。
2. **呼叫 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。
3. **取得結果** — API 會立即回傳 task_id。輪詢任務狀態端點，直到狀態變為 completed，然後從回應中取得輸出圖片 URL。GPT Image 2 通常在 10–30 秒內完成，視解析度而定。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `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。 |

## FAQ

### 可以在 Hermes Agent 中使用 GPT Image 2 嗎？

可以。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 和 GPT-4o Image 有什麼不同？

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 支援透明背景嗎？

支援。GPT Image 2 可在 prompt 中指示時輸出帶有透明背景的圖片。這對需要合成的商品照片、標誌和 UI 元素很有用。在 prompt 中描述透明度 — 例如「product shot on transparent background」。

### GPT Image 2 和 GPT-4o Image 的定價有什麼不同？

GPT Image 2 按每張圖片依輸出解析度計費：1k、2k 或 4k。GPT-4o Image 按每張圖片依輸出數量計費 — 單次請求生成 2 或 4 張圖片時每張費用更高。兩者都採用按量付費，無月度最低消費。請查看 RunAPI 定價頁面了解最新費率。

### Hermes Agent 可以用 GPT Image 2 代替 ComfyUI 編輯圖片嗎？

可以。使用 edit_image 端點搭配 model 設為 gpt-image-2-image-to-image。在 source_image_urls 中傳入來源圖片，並用自然語言描述編輯內容 — 「remove the background」、「add sunglasses」、「change the text to HELLO」。無需 ComfyUI 工作流圖、無需 GPU 實例、無需修補遮罩。


## Links

- [Hermes Agent 設定指南 →](https://runapi.ai/zh-TW/hermes-agent)
- [GPT Image 模型 →](https://runapi.ai/zh-TW/models/gpt-image)
- [Model catalog](https://runapi.ai/zh-TW/models)
- [API docs](https://runapi.ai/zh-TW/docs)
