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

# Veo 3.1 API：Google 文生视频与画面帧控制

> Google 视频生成 API 用于文生视频、第一帧/最后一帧、参考引导和扩展工作流程

## 概览

Veo 3.1 是 Google 的视频生成模型，支持文生视频、首尾帧动画和参考素材引导生成，还可以延长已完成的 Veo 3.1 任务所生成的视频。在 APIXO Playground 试用后，可以按本页示例调用 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `veo-3-1` |
| 模式 | `lite`, `fast`, `quality`, `extend-fast`, `extend-quality` |
| 生成类型 | `TEXT_2_VIDEO`, `FIRST_AND_LAST_FRAMES_2_VIDEO`, `REFERENCE_2_VIDEO` |
| 扩展源 | 来自同一账户的已完成非延期 APIXO `veo-3-1` `taskId` |
| 提示词长度 | 1 至 10000 个字符 |
| 支持的持续时间 | `4`、`6`、`8` 秒 |
| 纵横比 | `16:9`, `9:16`, `auto` |
| 输出分辨率 | `720p`, `1080p`, `4k` |
| 第一帧/最后一帧输入 | 最多 2 个图像 URL |
| 参考输入 | 最多 3 个图像 URL；仅限 `fast` 模式；`REFERENCE_2_VIDEO` 仅支持 8 秒 |
| 输出 | `resultJson.resultUrls` 中的视频 URL |

## 接口与身份验证

API 基础地址：

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

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

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

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

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

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

## 异步请求示例

以下示例提交一个最简单的文生视频任务，响应中会返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/veo-3-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "lite",
      "prompt": "a cinematic flyover of a futuristic city at sunrise",
      "generationType": "TEXT_2_VIDEO",
      "duration": 6,
      "resolution": "1080p",
      "aspect_ratio": "16:9"
    }
  }'
```

成功响应：

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

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/veo-3-1?taskId=task_12345678" \
  -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/xxx.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965730929,
    "costTime": 120000
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates safety policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
```

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

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

## 请求体

### 文生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "lite",
    "prompt": "a cinematic flyover of a futuristic city at sunrise",
    "generationType": "TEXT_2_VIDEO",
    "duration": 6,
    "resolution": "1080p",
    "aspect_ratio": "16:9"
  }
}
```

### 视频的第一帧/最后一帧

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "quality",
    "prompt": "a calm ocean turning into a storm",
    "generationType": "FIRST_AND_LAST_FRAMES_2_VIDEO",
    "duration": 6,
    "resolution": "720p",
    "image_urls": [
      "https://example.com/frame_start.jpg",
      "https://example.com/frame_end.jpg"
    ],
    "aspect_ratio": "9:16"
  }
}
```

### 参考生成视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "fast",
    "prompt": "turn these references into a dynamic action shot",
    "duration": 8,
    "resolution": "720p",
    "generationType": "REFERENCE_2_VIDEO",
    "image_urls": [
      "https://example.com/ref1.jpg",
      "https://example.com/ref2.jpg"
    ],
    "aspect_ratio": "9:16"
  }
}
```

### 延长已完成的 Veo 3.1 任务

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "extend-quality",
    "taskId": "task_id_from_completed_veo31_task",
    "prompt": "extend this scene into a dramatic sunset over the city skyline",
    "watermark": "YourBrand"
  }
}
```

## 参数

**request\_type** `string` *required* (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*

Veo 3.1 的输入参数。

**属性**

**mode** `string` *required*

模型模式。支持的值：`lite`、`fast`、`quality`、`extend-fast`、`extend-quality`。`REFERENCE_2_VIDEO` 仅支持 `fast`。

**taskId** `string`

仅用于 `extend-fast` 和 `extend-quality`。使用 APIXO 任务 ID，由同一账号完成的非扩展 `/generateTask/veo-3-1` 任务返回。

**prompt** `string` *required*

描述视频的文字提示。支持 1-10000 个字符。

**generationType** `string`

`lite`、`fast` 和 `quality` 生成模式所需。支持的值：`TEXT_2_VIDEO`、`FIRST_AND_LAST_FRAMES_2_VIDEO`、`REFERENCE_2_VIDEO`。`extend-fast` 和 `extend-quality` 不使用。

**duration** `integer`

可选视频时长（以秒为单位）。支持的值：`4`、`6`、`8`。默认值为 `8`。对于 `REFERENCE_2_VIDEO`，仅支持 `8`。

**resolution** `string`

可选输出分辨率。支持的值：`720p`、`1080p`、`4k`。默认值为 `720p`。

**aspect\_ratio** `string`

输出画面的宽高比。可选值为 `16:9`、`9:16`、`auto`。

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

用于图像引导工作流程的图像 URL。对于 `FIRST_AND_LAST_FRAMES_2_VIDEO` 和 `REFERENCE_2_VIDEO` 是必需的。支持最多 2 张图像用于首帧/末帧生成，最多支持 3 张图像用于参考生成。

**watermark** `string`

可选水印文本。

**seed** `integer`

用于可重复生成尝试的可选随机种子。

> [!WARNING]
>
> `REFERENCE_2_VIDEO` 需要 `mode: "fast"`。使用最多 3 可公开访问的图像 URL 来生成参考。仅支持`8`秒。

> [!WARNING]
>
> `extend-fast` 和 `extend-quality` 需要 `input.taskId`。基础任务必须是同一账户拥有的已完成且非扩展的 Veo 3.1 任务。扩展任务不能作为另一个扩展请求的基础任务。

使用可公开访问且可直接访问的图像 URL。对于图像引导工作流程，建议使用 JPG、JPEG 和 PNG 格式，大小不超过 10 MB。

## 响应格式

### 提交任务时的响应

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

**code** `integer`

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

**message** `string`

状态说明。

**data.taskId** `string`

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

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

包含生成视频 URL 的 JSON 字符串。当 `state` 为 `success` 时返回。

**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/veo-3-1" \
  -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": "fast",
      "prompt": "a product reveal shot with smooth camera motion and dramatic lighting",
      "generationType": "TEXT_2_VIDEO",
      "duration": 6,
      "resolution": "1080p",
      "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)。

Veo 3.1 按生成或扩展的视频任务计费。生成模式下，所选的 `mode` 和 `resolution` 决定单价；扩展模式在定价页面有独立的按任务计费标准。

当前定价不随 `duration` 变化；`4`、`6` 和 `8` 秒请求对于给定的 `mode` + `resolution` 使用相同的每视频价格。

| 生成模式 | `720p` | `1080p` | `4k` |
| - | - | - | - |
| `lite` | `$0.15 / video` | `$0.25 / video` | `$0.75 / video` |
| `fast` | `$0.30 / video` | `$0.375 / video` | `$0.90 / video` |
| `quality` | `$1.60 / video` | `$1.80 / video` | `$2.40 / video` |

用于比较的市场参考定价：

| 生成模式 | `720p` | `1080p` | `4k` |
| - | - | - | - |
| `lite` | `$3.20 / video` | `$3.20 / video` | `$4.80 / video` |
| `fast` | `$1.20 / video` | `$1.20 / video` | `$2.40 / video` |
| `quality` | `$3.20 / video` | `$3.20 / video` | `$4.80 / video` |

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟可能因提示复杂性、图像输入、所选路线和当前队列负载而异。

| 模式 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `lite` | 1-3 分钟 | 任务创建 60 至 90 秒后 | 5-10s |
| `fast` | 1-3 分钟 | 任务创建 60 至 90 秒后 | 5-10s |
| `quality` | 1-3 分钟 | 任务创建 90 秒后 | 5-10s |
| `extend-fast` | 1-3 分钟 | 任务创建 30 至 60 秒后 | 5-10s |
| `extend-quality` | 1-3 分钟 | 任务创建 60 至 90 秒后 | 5-10s |

> [!TIP]
>
> 对于生产环境的视频工作负载，建议使用回调模式以避免频繁轮询。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 无效的请求体、缺少参数、不支持的模式、不支持的生成类型或无效的图像输入 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误 | 逐步延长间隔后重试 |
| `502` | 服务错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `SensitiveContent` | 提示或图像输入被安全检查拒绝 | 更改提示或输入图像 |
| `PromptInvalid` | 提示词无效或被拒绝 | 修改提示词后重试 |
| `ImageFormatIncorrect` | 不接受输入图像格式 | 使用公共 JPG、JPEG 或 PNG URL |
| `MissingParameter` | 缺少必需的参数 | 检查`mode`、`prompt`、`generationType`和条件`image_urls` |
| `RateLimited` | 请求频率达到上限 | 按指数退避策略重试 |
| `Timeout` | 任务超时 | 重试、降低输入复杂度或使用回调模式 |
| `Unknown error` | 任务因未知原因失败 | 稍后重试或通过 `taskId` 联系支持人员 |

### 常见验证问题

| 问题 | 解决办法 |
| - | - |
| 缺少 `mode` | 将`mode`设置为`lite`、`fast`、`quality`、`extend-fast`或`extend-quality` |
| 缺少 `generationType` | 对于 `lite`、`fast` 和 `quality`，设置支持的生成类型值之一 |
| 缺少扩展 `taskId` | 为了 `extend-fast` 和 `extend-quality`，提供 APIXO `taskId` 从已完成的非扩展 Veo 3.1 任务 |
| 扩展扩展任务 | 使用已完成的非扩展 Veo 3.1 任务作为基本任务 |
| `REFERENCE_2_VIDEO` 与 `lite` 或 `quality` | 使用`mode: "fast"` |
| `REFERENCE_2_VIDEO` 的持续时间不是 `8` | 使用`duration: 8` |
| 图片太多 | 使用最多 2 个图像来生成第一帧/最后一帧，或使用最多 3 个图像来生成参考图像 |
| 空图像 URL | 提供非空、可公开访问的图像 URL |

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

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/veo-3-1.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_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)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [在 APIXO Playground 尝试 Veo 3.1](https://apixo.ai/models/veo-3-1)
* [API定价](https://apixo.ai/pricing/api)


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