> ## 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.

# FLUX 3 Video API：文生视频、图生视频与视频续写

> 使用 FLUX 3 生成一个 5–20 秒的视频。可从提示开始，为一两个图像帧添加动画，或扩展一段公共 MP4 视频。

## 概览

使用`flux-3`生成MP4。从 [单独提示开始](#copy-paste-async-quickstart)，[为一张图像设置动画](#image-to-video)，或 [提供开始帧和结束帧](#image-to-video-with-start-and-end-frames)。要继续您已有的素材，请使用 [视频扩展请求](#video-extend)。对于静态图像输出，请使用 [FLUX 3 Image](https://apixo.ai/docs/zh/models/image/flux-3-image.md)。

| 功能 | 值 |
| - | - |
| 模型 ID | `flux-3` |
| 模式 | `text-to-video`, `image-to-video`, `video-extend` |
| 提示词长度 | 1 至 5000 个字符 |
| 时长 | 5-20 秒 |
| 可选分辨率 | `720p`, `1080p` |
| 纵横比 | `21:9`, `2:1`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16` |
| 图生视频源 | 1 个图像 URL，或 2 个图像 URL（分别用于开始帧和结束帧） |
| 视频扩展源 | 恰好 1 个公共 MP4 URL，大小不超过 50 MB，时长不超过 15 秒 |
| 音频 | 默认启用 `sound: true` |
| 输出 | MP4 视频网址位于 `resultJson.resultUrls` |

## 接口与身份验证

API 基础地址：

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

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/flux-3` | 提交视频生成任务 |
| `GET` | `/statusTask/flux-3?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

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

提交任务时，还需要设置以下请求头：

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

## 异步请求示例

文本转视频作业仅需要 `mode` 和 `prompt`。此请求使用持续时间（5 秒）、分辨率（720p）、宽高比（9:16）和声音（开启）的默认值。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic macro shot of glass sculptures forming from liquid light"
    }
  }'
```

成功响应：

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

从您提交的响应中保存 `data.taskId` 并在状态查询请求中使用它。

## 轮询结果

```bash theme={null}
TASK_ID="paste-your-returned-task-id"
curl -X GET "https://api.apixo.ai/api/v1/statusTask/flux-3?taskId=$TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

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

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/flux-3.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965680929,
    "costTime": 70000
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "INVALID_PARAMETER",
    "failMsg": "One or more input parameters are invalid.",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 请求体

### 文生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a wide cinematic desert highway at sunrise, gentle aerial camera movement",
    "duration": 8,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "sound": true
  }
}
```

### 图生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "animate the portrait with a subtle smile and soft studio camera drift",
    "image_urls": [
      "https://example.com/source.png"
    ],
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "9:16",
    "sound": true
  }
}
```

### 指定首帧和尾帧的图生视频

在 `image_urls` 中首先放置开始图像，然后放置结束图像。在 `prompt` 中描述两者之间的运动。提交前将示例 URL 替换为公开可访问的图像 URL。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "transition smoothly from the empty room into the decorated final scene",
    "image_urls": [
      "https://example.com/start-frame.png",
      "https://example.com/end-frame.png"
    ],
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "sound": false
  }
}
```

### 视频扩展

将示例 URL 替换为一个公共 MP4 文件，最长 15 秒，大小不超过 50 MB。`duration` 字段设置请求的输出时长（5–20 秒）。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "video-extend",
    "prompt": "continue the camera move forward as the scene opens into a bright atrium",
    "video_urls": [
      "https://example.com/source.mp4"
    ],
    "duration": 8,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "sound": true
  }
}
```

## 参数

**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*

FLUX 3 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-video`、`image-to-video`、`video-extend`。

**prompt** `string` *required*

用文字描述要生成的视频。长度须为 1 至 5000 个字符。提示词为空时，请求会被拒绝。

**duration** `integer|string` (default: 5)

输出持续时间（以秒为单位）。支持从 `5` 到 `20` 的整数或整数字符串。小数无效。

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

输出分辨率。可选值为 `720p`、`1080p`。

**aspect\_ratio** `string` (default: 9:16)

输出画面的宽高比。可选值为 `21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。

**sound** `boolean` (default: true)

是否生成同步音频。支持的值：`true`、`false`。音频不另外加收费用。

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

参考图像 URL。`image-to-video` 模式下必需。提供 1 个可公开访问的图像 URL，或 2 个可公开访问的图像 URL，其中第一个为起始帧，第二个为结束帧。

**video\_urls** `string[]`

源视频 URL。`video-extend` 模式下必需。准确提供 1 个公共 MP4 URL。源视频大小不得超过 50 MB，时长不得超过 15 秒。

### 模式选项

| 模式 | 所需媒体 | 使用案例 |
| - | - | - |
| `text-to-video` | 无 | 根据提示生成视频 |
| `image-to-video` | `image_urls` 与 1 或 2 个 URL | 对一张图像进行动画处理，或在开始帧和结束帧之间生成运动 |
| `video-extend` | `video_urls` 恰好包含 1 个 MP4 URL | 继续现有的短视频 |

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/flux-3` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`processing_r2`、`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/flux-3" \
  -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-video",
      "prompt": "turn the product photo into a premium reveal shot with slow camera motion",
      "image_urls": [
        "https://example.com/product.png"
      ],
      "duration": 5,
      "resolution": "720p",
      "aspect_ratio": "9:16",
      "sound": true
    }
  }'
```

回调传递使用与状态响应相同的最终有效负载形状。详情请参阅 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md) 了解交付要求和重试行为。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

FLUX 3 按输出秒数计费。所选的 `mode` 和 `resolution` 决定每秒单价，`duration` 决定计费秒数。`text-to-video` 与 `image-to-video` 共享相同的生成定价；开始/结束帧的图像到视频使用 `image-to-video` 价格。`video-extend` 使用扩展价格。

| 模式 | 分辨率 | APIXO 价格 | 总计示例 |
| - | - | -: | -: |
| `text-to-video`或`image-to-video` | `720p` | `$0.17 / second` | 5s: `$0.85` |
| `text-to-video`或`image-to-video` | `1080p` | `$0.29 / second` | 10s: `$2.90` |
| `video-extend` | `720p` | `$0.41 / second` | 5s: `$2.05` |
| `video-extend` | `1080p` | `$0.53 / second` | 10s: `$5.30` |

公式：

```text theme={null}
total cost = duration * selected mode and resolution unit price
```

使用 `sound: true` 生成音频不会增加单独的费用。有关最新发布的定价，请参阅[API定价](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟可能因提示复杂性、所选模式、媒体可访问性、持续时间、分辨率和当前队列负载而异。

| 请求结构 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `5-8`秒剪辑 | 60s-120s | 任务创建 60 秒后 | 5s-10s |
| `9-15`秒剪辑 | 120s-240s | 任务创建 90 秒后 | 10s |
| `16-20`秒剪辑 | 240s+ | 任务创建 120 秒后 | 10s-15s |

> [!TIP]
>
> 对于生产视频工作负载，请使用回调模式以避免在生成仍在运行时频繁轮询。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体无效、缺少 `mode`、缺少 `prompt`、媒体输入无效、无效 `duration`、无效 `resolution` 或无效 `aspect_ratio` | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 此API键无法访问模型 | 检查账户权限 |
| `404` | 轮询时未找到任务 | 检查`taskId` |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 内部错误或未知任务失败 | 重试后退或联系支持人员（如果问题仍然存在） |
| `502` | 生成服务或网络错误 | 逐步延长间隔后重试 |
| `503` | 服务暂时不可用 | 稍后重试 |
| `504` | 生成超时 | 稍后重试或对长时间运行的作业使用回调模式 |

### 验证说明

| 参数 | 后端行为 |
| - | - |
| `input.mode` | 必需的。使用`text-to-video`、`image-to-video`或`video-extend`。 |
| `input.prompt` | 必需的字符串。不能为空且不能超过 5000 个字符。 |
| `input.duration` | 可选。默认为 `5`。接受从 `5` 到 `20` 的整数或整数字符串；小数被拒绝。 |
| `input.resolution` | 可选。使用 `720p`（默认）或 `1080p`。 |
| `input.aspect_ratio` | 可选。默认为 `9:16`。如果提供的话，必须是 `21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16` 之一。 |
| `input.sound` | 可选。默认为 `true`。必须是布尔值。 |
| `input.image_urls` | `image-to-video` 所需。必须包含 1 或 2 非空可公开访问的图像 URL。 |
| `input.video_urls` | `video-extend` 所需。必须恰好包含 1 非空的公共 MP4 URL；源文件大小不得超过 50 MB 且时长不得超过 15 秒。 |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/flux-3.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_urls`, `video_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [视频模型](https://apixo.ai/docs/zh/models/video)
* [提交生成任务](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)
* [在 APIXO Playground 尝试 FLUX 3](https://apixo.ai/models/flux-3)
* [API定价](https://apixo.ai/pricing/api)


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