> ## 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/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/api-reference/webhooks.md)。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/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` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知生成失败 | 逐步延长间隔后重试 |
| `502` | 生成服务或网络错误 | 逐步延长间隔后重试 |
| `504` | 生成超时 | 重试；耗时较长的任务可改用回调模式 |

完整列表见[错误码](https://apixo.ai/docs/zh/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/models.md)
* [图像模型](https://apixo.ai/docs/zh/models/image)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh/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.