> ## Documentation Index
> Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Runway Gen4 Image Turbo API：快速文字生成圖片

> Fast Runway Gen4 影像生成 API，用於文生圖和參考引導影像工作流程

## 概覽

Runway Gen4 Image Turbo 是一種更快的影像生成模型，用於提示驅動的影像和參考引導的生成。它保持與 Runway Gen4 Image 相同的公共參數形狀，且每張影像的價格為固定值。

| 功能 | 值 |
| - | - |
| 模型 ID | `runway-gen4-image-turbo` |
| 模式 | `text-to-image`, `image-to-image` |
| 提示詞 | 必填，且必須是非空字串 |
| 參考圖片 | `image-to-image` 所需；`text-to-image` 可選；1-3 公開影像 URL（如果提供） |
| 縱橫比 | `1:1`, `16:9`, `9:16`, `4:3`, `3:4` |
| 解析度輸入 | `720p`, `1080p` |
| 種子 | 從 `1` 到 `2147483647` 的整數 |

## 端點與身分驗證

API 基底網址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/runway-gen4-image-turbo` | 提交影像生成任務 |
| `GET` | `/statusTask/runway-gen4-image-turbo?taskId={taskId}` | 查詢任務狀態並取得結果 |

每個請求都必須附上 APIXO API 金鑰：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

送出任務時，還需設定以下請求標頭：

```http theme={null}
Content-Type: application/json
```

## 非同步請求範例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/runway-gen4-image-turbo" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "A futuristic city tram at sunrise, editorial photography",
      "aspect_ratio": "16:9",
      "resolution": "1080p"
    }
  }'
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

## 輪詢結果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/runway-gen4-image-turbo?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/runway-gen4-image-turbo.png\"]}",
    "createTime": 1782980000000,
    "completeTime": 1782980015000,
    "costTime": 15000
  }
}
```

## 請求體

### 文生圖

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "A futuristic city tram at sunrise, editorial photography",
    "aspect_ratio": "16:9",
    "resolution": "1080p"
  }
}
```

### 帶有可選參考的文本到影像

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "Use this reference composition and render it in rainy neon lighting",
    "image_urls": [
      "https://example.com/reference-1.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "1080p"
  }
}
```

### 圖生圖

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-image",
    "prompt": "Preserve the tram design and render it as a premium concept image",
    "image_urls": [
      "https://example.com/reference-1.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "1080p"
  }
}
```

## 參數

**request\_type** `string` (default: async)

取得結果的方式。選擇 `async` 時，透過 `statusTask` 輪詢結果；選擇 `callback` 時，透過 Webhook 接收結果。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必填。請提供可從網際網路存取的 HTTPS 網址，以接收任務的最終結果。詳見 [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

**input** `object` *required*

Runway Gen4 Image Turbo 的輸入參數。

**屬性**

**mode** `string` (default: text-to-image)

生成模式。支援的值：`text-to-image`、`image-to-image`。如果省略，APIXO 會在 `image_urls` 非空時使用 `image-to-image`；否則使用 `text-to-image`。

**prompt** `string` *required*

描述所需影像的文字提示。提示必須是修剪空格後的非空字串。

**image\_urls** `string[]`

參考影像 URL。`image-to-image` 所需。`text-to-image` 可選。在任何模式下提供時，此陣列必須包含 1 到 3 公共、可直接存取的影像 URL。

**aspect\_ratio** `string` (default: 4:3)

輸出畫面的長寬比。可用值為 `1:1`、`16:9`、`9:16`、`4:3`、`3:4`。

**resolution** `string` (default: 1080p)

接受輸出解析度輸入以實現請求相容性。支援的值：`720p`、`1080p`。

**seed** `integer`

選填的隨機種子，必須是 `1` 至 `2147483647` 的 JSON 整數。小數值及加上引號的字串無效。

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/runway-gen4-image-turbo` 會傳回任務 ID：

**code** `integer`

API 狀態碼。`200` 表示任務已受理。

**message** `string`

狀態說明。

**data.taskId** `string`

任務的唯一 ID，用於查詢任務狀態。

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

目前的任務狀態，可能的值為 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

當 `state` 為 `success` 時傳回。解析此 JSON 字串後，即可從 `resultUrls` 取得生成的圖片連結。

**failCode** `string`

供程式判讀的錯誤碼，僅在 `state` 為 `failed` 時傳回。

**failMsg** `string`

失敗原因說明，僅在 `state` 為 `failed` 時傳回。

**createTime** `integer`

任務建立時的 Unix 時間戳記，單位為毫秒。

**completeTime** `integer`

任務完成時的 Unix 時間戳記，單位為毫秒。任務完成後才會傳回。

**costTime** `integer`

處理時間，以毫秒為單位。有計時資料時才會傳回。

## Webhook 回呼模式

若希望後端自動收到最終結果，可使用回呼模式，無須輪詢。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/runway-gen4-image-turbo" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "image-to-image",
      "prompt": "Create a premium vehicle concept using this reference",
      "image_urls": [
        "https://example.com/reference-1.png"
      ],
      "aspect_ratio": "16:9"
    }
  }'
```

Webhook 的接收條件與重試規則請見 [Webhook 文件](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/pricing.md#credit-conversion-and-rounding)。

Runway Gen4 Image Turbo 以每張影像的統一價格計費。`text-to-image`和`image-to-image`使用相同的公共APIXO價格。

| 單位 | APIXO 價格 |
| - | - |
| 每個生成的影像 | `$0.035 / image` |

## 耗時與輪詢

實際延遲可能會因提示複雜性、參考影像可存取性和目前佇列負載而異。

| 工作量 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| 影像生成 | 10s-30s | 任務建立 10 秒後 | 3s-5s |
| 參考引導生成 | 15s-35s | 任務建立 15 秒後 | 3s-5s |

> [!TIP]
>
> 對於生產映像工作負載，請使用回呼模式以避免在生成仍在運行時頻繁輪詢。

## 驗證說明

| 參數 | 後端行為 |
| - | - |
| `input.mode` | 選填。支援的值為 `text-to-image` 和 `image-to-image`。若省略，非空`image_urls`選擇`image-to-image`；否則`text-to-image`。 |
| `input.prompt` | 必需的字串。修剪空白後不能為空。 |
| `input.image_urls` | `image-to-image` 所需。`text-to-image` 可選。如果存在，則必須是包含 1-3 非空字串 URL 的陣列。 |
| `input.aspect_ratio` | 選填。預設值為 `4:3`。必須使用下列其中一個值：`1:1`、`16:9`、`9:16`、`4:3`、`3:4`。 |
| `input.resolution` | 選填。預設值為 `1080p`。必須使用下列其中一個值：`720p`、`1080p`。 |
| `input.seed` | 選填的 JSON 整數。必須從 `1` 到 `2147483647`。 |

## 錯誤與排查

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 無效的請求主體、模式、參數值或輸入影像 URL | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤或未知生成失敗 | 逐步拉長間隔後重試 |
| `502` | 產生服務或網路錯誤 | 逐步拉長間隔後重試 |
| `504` | 生成超時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

完整列表見[錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)。

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/image/runway-gen4-image-turbo.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_urls`。請保留使用者指定的檔案順序。模型參數由 API 驗證。

## 相關連結

* [生成 API 總覽](https://apixo.ai/docs/zh-hant/models.md)
* [影像模型](https://apixo.ai/docs/zh-hant/models/image)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)
* [參數規範](https://apixo.ai/docs/zh-hant/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh-hant/concepts/routing-strategies.md)
* [API定價](https://apixo.ai/pricing/api)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.