---
title: &quot;透過 RunAPI 在 Hermes Agent 中使用 Flux 2 — 圖片 API 指南&quot;
url: &quot;https://runapi.ai/zh-HK/hermes-flux-2.md&quot;
canonical: &quot;https://runapi.ai/zh-HK/hermes-flux-2&quot;
locale: &quot;zh-HK&quot;
model: &quot;flux-2&quot;
---

# 在 Hermes Agent 中使用 Flux 2。

Black Forest Labs 的 Flux 2 提供兩種品質層級 — Pro 以每張 5 美分快速生成，Flex 以 14 美分產出更高保真度。兩者都支援文生圖和多來源 remix，可選 1k 或 2k 解析度。Hermes Agent 透過 custom:runapi provider 呼叫 — 使用與聊天相同的 key 和 base URL。

## 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;flux-2-pro-text-to-image&quot;,
    &quot;prompt&quot;: &quot;a ceramic vase with dried flowers on a linen tablecloth, natural window light, 35mm film grain&quot;,
    &quot;aspect_ratio&quot;: &quot;3:4&quot;,
    &quot;output_resolution&quot;: &quot;2k&quot;
  }&#39;

```

### Response

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

```

## How it works

1. **設定 RunAPI** — 設定 RUNAPI_API_KEY 環境變數。如果您已在 Hermes Agent 中將 RunAPI 新增為 custom:runapi provider 用於聊天，同一個 key 和 base_url 也適用於 Flux 2 圖片生成 — 無需額外設定。
2. **呼叫 Flux 2** — 向 text_to_image 端點發送 POST 請求，model 設為 flux-2-pro-text-to-image。加入 prompt，並可選擇性設定 aspect_ratio（1:1、4:3、16:9 等）和 output_resolution（1k 或 2k）。若要進行多來源 remix，改用 remix_image 端點搭配 source_image_urls。
3. **取得結果** — 端點會回傳一個任務 ID。輪詢任務狀態端點，直到狀態變為 completed，然後從回應中取得生成的圖片 URL。RunAPI SDK 和 CLI 會自動處理輪詢。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | 必填。flux-2-pro-text-to-image、flux-2-flex-text-to-image、flux-2-pro-remix-image 或 flux-2-flex-remix-image。 |
| `prompt` | `string` | 要生成的圖片文字描述。 |
| `aspect_ratio` | `string` | 選填。輸出長寬比：1:1、4:3、3:4、16:9、9:16、3:2 或 2:3。Remix 端點還接受 auto。 |
| `output_resolution` | `string` | 選填。1k（預設）或 2k。較高解析度的每張圖片費用較高。 |
| `source_image_urls` | `array` | remix_image 必填。要混合或轉換的來源圖片 URL 陣列。 |
| `callback_url` | `string` | 選填。用於非同步完成通知的 Webhook URL。 |

## FAQ

### Flux 2 Pro 和 Flux 2 Flex 有什麼不同？

Pro 是更快速、更實惠的層級，每張 1k 圖片 5 美分。Flex 產出更高保真度的輸出，每張 1k 圖片 14 美分。兩者共用相同的 API 參數，並透過 custom:runapi provider 支援 text_to_image 和 remix_image 端點。

### Hermes Agent 可以呼叫 Flux 2 remix_image 端點嗎？

可以。使用 model flux-2-pro-remix-image 或 flux-2-flex-remix-image 搭配 remix_image 端點。在 source_image_urls 中傳入圖片 URL 陣列，並附上文字 prompt。custom:runapi provider 處理請求的方式與 text_to_image 相同。

### Flux 2 的輸出解析度會影響定價嗎？

會。每個變體按圖片計費，依解析度定價。例如，Flux 2 Pro 在 1k 時 5 美分，2k 時 7 美分。Flux 2 Flex 在 1k 時 14 美分，2k 時 24 美分。請查看 RunAPI 定價頁面了解最新費率。

### 我需要為 Flux 2 圖片生成單獨設定 provider 嗎？

不需要。您為聊天設定的 custom:runapi provider 已適用於 Flux 2 和所有其他 RunAPI 模型。同一個 RUNAPI_API_KEY、base_url 和 provider 名稱可處理 LLM、圖片、影片和音樂請求。

### RunAPI 上的 Flux 2 和 Flux Kontext 有什麼不同？

Flux Kontext 專精於使用單張輸入圖片進行文字引導編輯和角色一致性。Flux 2 專注於文生圖和多來源 remix，提供可選的 Pro/Flex 品質層級和 1k/2k 解析度選項。兩者都是 Black Forest Labs 的產品，共用同一個 RunAPI key 和計費。


## Links

- [Hermes Agent 設定指南 →](https://runapi.ai/zh-HK/hermes-agent)
- [Flux 2 模型 →](https://runapi.ai/zh-HK/models/flux-2)
- [Model catalog](https://runapi.ai/zh-HK/models)
- [API docs](https://runapi.ai/zh-HK/docs)
