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

# 在 OpenClaw 中使用 Flux 2。

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

## 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 環境變數。如果您已在 OpenClaw 中將 RunAPI 設定為聊天用的 provider，同一個 key 也適用於 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 參數，並支援 text_to_image 和 remix_image 端點。

### 可以用 Flux 2 remix 多張來源圖片嗎？

可以。使用 remix_image 端點搭配 model flux-2-pro-remix-image 或 flux-2-flex-remix-image。在 source_image_urls 中傳入來源圖片 URL 陣列，並附上描述期望輸出的文字 prompt。

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

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

### Flux 2 和 Flux Kontext 有什麼不同？

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

### Flux 2 是非同步還是同步的？

非同步。API 會立即回傳任務 ID。輪詢任務狀態端點或設定 callback_url webhook 來接收完成的圖片 URL。RunAPI SDK 和 CLI 會自動處理輪詢。


## Links

- [OpenClaw 設定指南 →](https://runapi.ai/zh-TW/openclaw)
- [Flux 2 模型 →](https://runapi.ai/zh-TW/models/flux-2)
- [Model catalog](https://runapi.ai/zh-TW/models)
- [API docs](https://runapi.ai/zh-TW/docs)
