视频生成
通过 Veo 3.1 视频生成接口,使用文本提示词或参考图片生成带原生音频的 AI 视频。支持文生视频、图生视频、首尾帧插值、参考图片(最多 3 张)、视频续写及 4K 输出。异步 Long-Running Operation 接口,提交后返回 Operation,需轮询直到 done=true。
Veo 3.1 是 Google DeepMind 推出的视频生成模型,可生成 4~8 秒、720p / 1080p / 4K 的视频,并原生支持同步语音与音效。支持以下生成模式:
- 文生视频:纯文本提示词生成
- 图生视频:以首帧图片为起点生成后续动作
- 首尾帧插值:从首帧过渡到尾帧
- 参考图片:最多 3 张参考图,指导人物、角色、服装、产品或风格
- 视频续写:基于此前 Veo 生成的视频继续延长场景
输出支持横屏(16:9)与竖屏(9:16)。
视频生成属于长耗时任务(Long-Running Operation):请求提交后立即返回 Operation,需轮询直到 done=true,再从结果中取出视频 URI 下载。
支持的模型
| 模型 ID(主) | 别名 | 版本 | 特点 | 适用场景 |
|---|---|---|---|---|
veo-3.1-generate-preview | veo-3.1-generate-001 | Veo 3.1 | 最高画质,支持 4K | 高质量创意内容、商业制作 |
veo-3.1-fast-generate-preview | veo-3.1-fast-generate-001 | Veo 3.1 Fast | 更快速度,最高 1080p | 快速迭代、批量生成 |
两套模型 ID 互为别名、等价可互换。模型通过请求路径中的 {model} 区分,Fast 版不支持 4K 输出。
Base URL
https://api.autorouter.top— Production
Authentication
BearerAuth: http (bearer)
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
Endpoints
POST /v1beta/models/{model}:predictLongRunning
创建视频生成任务
通过 instances + parameters 提交 Veo 视频生成请求。本接口为异步接口,创建成功后返回 Operation name,需通过查询 Operation 轮询任务状态。
路径格式:/v1beta/models/{model}:predictLongRunning
例如:
/v1beta/models/veo-3.1-generate-preview:predictLongRunning/v1beta/models/veo-3.1-fast-generate-preview:predictLongRunning
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | path | string | Yes | 模型名称,如 veo-3.1-generate-preview |
Headers
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Content-Type | string | Yes | application/json | 数据交换格式 |
Authorization | string | Yes | - | 鉴权信息,格式:Bearer sk-xxxxxx |
Request Body
Content-Type: application/json
请求由 instances 与 parameters 组成。image、lastFrame、referenceImages、video 均位于 instances[],不要放到 parameters 中。
Example:
{
"instances": [
{
"prompt": "A cinematic shot of a woman walking through Tokyo at night, neon lights reflecting on wet streets."
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "1080p",
"personGeneration": "allow_all",
"numberOfVideos": 1,
"seed": 123456
}
}Properties:
| Name | Type | Required | Default | Enum | Description |
|---|---|---|---|---|---|
instances | array | Yes | - | - | 输入实例列表,通常传入 1 个元素 |
instances[].prompt | string | Yes | - | - | 视频文本描述 |
instances[].image | object | No | - | - | 图生视频的初始图片(首帧) |
instances[].lastFrame | object | No | - | - | 首尾帧插值的最终图片,须与 image 配合使用 |
instances[].referenceImages | array | No | - | - | 参考图片列表,最多 3 张 |
instances[].video | object | No | - | - | 视频续写的输入视频,须为此前 Veo 生成结果 |
parameters | object | No | - | - | 生成参数 |
parameters.aspectRatio | string | No | 16:9 | 16:9、9:16 | 视频宽高比 |
parameters.durationSeconds | string | No | - | "4"、"6"、"8" | 视频时长(秒),类型为 string |
parameters.personGeneration | string | No | - | allow_all、allow_adult | 人物生成策略,见下方场景说明 |
parameters.resolution | string | No | 720p | 720p、1080p、4k | 输出分辨率;1080p / 4k 仅支持 8 秒;4k 仅标准版支持 |
parameters.numberOfVideos | integer | No | 1 | 1 | 生成视频数量,当前固定为 1 |
parameters.seed | integer | No | - | - | 随机种子,可提升结果一致性(不保证完全确定) |
instancesarray(必选)
输入实例列表。每次请求通常传入 1 个元素。prompt、image、lastFrame、referenceImages、video 均放在该数组元素中。
格式示例如下:
[
{
"prompt": "string",
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<BASE64_IMAGE>"
}
},
"lastFrame": {
"inlineData": {
"mimeType": "image/png",
"data": "<BASE64_IMAGE>"
}
},
"referenceImages": [
{
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<BASE64_IMAGE>"
}
},
"referenceType": "asset"
}
],
"video": {
"inlineData": {
"mimeType": "video/mp4",
"data": "<BASE64_VIDEO>"
}
}
}
]视频文本描述。可描述场景、人物、动作、镜头运动、光照、风格,以及对话、音效与音乐。建议英文以获得最佳效果。
音频提示示例:
- 对话:使用引号标注具体台词(如
"This must be the key," he murmured.) - 音效:明确描述声音(如
tires screeching loudly, engine roaring) - 环境音:描述环境声场(如
A faint, eerie hum resonates in the background)
图生视频的初始图片(首帧)。传入后模型以该图作为起始帧生成后续动作。
| Name | Type | Required | Description |
|---|---|---|---|
inlineData | object | Yes | 内联二进制数据 |
inlineData.mimeType | string | Yes | MIME 类型,如 image/png、image/jpeg |
inlineData.data | string | Yes | Base64 编码的图片数据 |
首尾帧插值的最终图片。结构与 image 相同(inlineData.mimeType + inlineData.data)。
- 须同时传入
image(首帧) - 位于
instances[],不要放到parameters中 - 使用首尾帧时,
parameters.durationSeconds须为"8"
参考图片列表,用于指导生成内容(人物、角色、服装、产品、风格等)。最多 3 张。
与 image 首帧不同:参考图不直接作为动画起始帧,而是影响生成内容的风格与主体。使用参考图片时,parameters.durationSeconds 须为 "8"。
| Name | Type | Required | Description |
|---|---|---|---|
image | object | Yes | 参考图片,结构同 instances[].image |
image.inlineData.mimeType | string | Yes | MIME 类型 |
image.inlineData.data | string | Yes | Base64 编码的图片数据 |
referenceType | string | Yes | 参考类型,官方示例为 asset |
视频续写的输入视频。输入须为此前 Veo 生成的结果。
| Name | Type | Required | Description |
|---|---|---|---|
inlineData | object | Yes | 内联二进制数据 |
inlineData.mimeType | string | Yes | 固定为 video/mp4 |
inlineData.data | string | Yes | Base64 编码的视频数据 |
限制:
- 仅支持
720p分辨率输出 - 每次续写增加约 7 秒,最多续写 20 次
- 输入视频最长 141 秒,最终视频最长可达 148 秒
- 输入视频比例须为
16:9或9:16
parametersobject(可选)
生成参数。
视频宽高比。默认 16:9。
16:9:横屏9:16:竖屏
视频时长(秒)。类型为 string,合法值:"4"、"6"、"8"。
以下场景须为 "8":
- 使用
1080p或4k分辨率 - 使用首尾帧(
image+lastFrame) - 使用参考图片(
referenceImages) - 视频续写(
video)
人物生成安全策略。不同生成模式推荐使用不同值:
| 场景 | personGeneration |
|---|---|
| 文生视频 | allow_all |
| 图生视频 | allow_adult |
| 首尾帧插值 | allow_adult |
| 参考图片 | allow_adult |
| 视频续写 | allow_all |
部分地区存在更严格限制,请根据实际返回错误调整。
输出分辨率。默认 720p。
720p:720P 视频1080p:1080P 视频(仅支持 8 秒时长)4k:4K 视频(仅标准版veo-3.1-generate-preview支持,须为 8 秒时长)
Fast 版(veo-3.1-fast-generate-preview)最高支持 1080p。视频续写仅支持 720p。
生成视频数量。Veo 3.1 当前每次请求生成 1 个视频。
随机种子,用于提高生成结果的一致性。不要将其理解为严格确定性保证。
Responses
200: 成功创建任务
Content-Type: application/json
请求示例
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "A cinematic shot of a majestic lion walking through the African savannah at sunset."
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "1080p",
"numberOfVideos": 1
}
}'响应示例
{
"name": "models/veo-3.1-generate-preview/operations/xxxxxxxx"
}响应字段说明:
| Name | Type | Description |
|---|---|---|
name | string | Operation 名称,作为后续查询依据 |
保存 name,用于轮询任务状态。
更多场景示例
以下示例使用 preview 模型 ID;也可将路径中的模型替换为对应的 001 别名(如
veo-3.1-generate-001)。
文生视频(Fast 模型,竖屏)
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-fast-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "A cinematic shot of waves rolling onto a moonlit beach."
}
],
"parameters": {
"aspectRatio": "9:16",
"durationSeconds": "8",
"resolution": "720p",
"personGeneration": "allow_all",
"numberOfVideos": 1
}
}'图生视频(首帧)
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "The woman slowly turns her head and smiles.",
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<BASE64_IMAGE>"
}
}
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "1080p",
"personGeneration": "allow_adult",
"numberOfVideos": 1
}
}'首尾帧插值
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "Create a cinematic transition between the two frames.",
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<FIRST_FRAME_BASE64>"
}
},
"lastFrame": {
"inlineData": {
"mimeType": "image/png",
"data": "<LAST_FRAME_BASE64>"
}
}
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "1080p",
"personGeneration": "allow_adult",
"numberOfVideos": 1
}
}'lastFrame 必须与 image 一起放在 instances[] 中,而不是 parameters。
参考图片生成
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "A cinematic fashion video featuring the same person and outfit.",
"referenceImages": [
{
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<DRESS_IMAGE_BASE64>"
}
},
"referenceType": "asset"
},
{
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<GLASSES_IMAGE_BASE64>"
}
},
"referenceType": "asset"
},
{
"image": {
"inlineData": {
"mimeType": "image/png",
"data": "<PERSON_IMAGE_BASE64>"
}
},
"referenceType": "asset"
}
]
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "1080p",
"personGeneration": "allow_adult",
"numberOfVideos": 1
}
}'最多 3 张参考图。
视频续写
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "Continue the scene as the butterfly enters the garden.",
"video": {
"inlineData": {
"mimeType": "video/mp4",
"data": "<PREVIOUS_VEO_VIDEO_BASE64>"
}
}
}
],
"parameters": {
"numberOfVideos": 1,
"resolution": "720p"
}
}'4K 文生视频
curl -X POST "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"instances": [
{
"prompt": "A cinematic shot of a majestic lion walking through the African savannah at sunset."
}
],
"parameters": {
"aspectRatio": "16:9",
"durationSeconds": "8",
"resolution": "4k",
"personGeneration": "allow_all",
"numberOfVideos": 1
}
}'GET /v1beta/{operation.name}
查询视频生成任务
将创建任务返回的 name 拼接到 Base URL 后查询 Operation 状态。
例如:
GET /v1beta/models/veo-3.1-generate-preview/operations/xxxxxxxx- 建议轮询间隔约 10 秒
done=false:任务仍在执行,继续轮询done=true:检查是否存在error;无错误则从response中取视频 URI
Path Params
| Name | Type | Required | Description |
|---|---|---|---|
operation.name | string | Yes | 创建任务时返回的 Operation 名称 |
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | 鉴权信息,格式:Bearer sk-xxxxxx |
Responses
200: 成功查询任务
Content-Type: application/json
请求示例
curl -X GET "https://api.autorouter.top/v1beta/models/veo-3.1-generate-preview/operations/xxxxxxxx" \
-H "Authorization: Bearer sk-xxxxxx"响应示例
{
"name": "models/veo-3.1-generate-preview/operations/xxxxxxxx",
"done": false
}响应字段说明:
| Name | Type | Description |
|---|---|---|
name | string | Operation 名称 |
done | boolean | 是否完成 |
metadata | object | 操作元数据 |
response | object | 成功结果,仅 done=true 且无 error 时存在 |
response.generateVideoResponse.generatedSamples | array | 生成的视频列表 |
response.generateVideoResponse.generatedSamples[].video.uri | string | 视频下载 URI |
error | object | 失败结果,仅失败时存在 |
error.code | integer | 错误码 |
error.message | string | 错误信息 |
error.status | string | 错误状态,如 INVALID_ARGUMENT |
doneboolean
任务是否完成:
false:处理中,继续轮询true:已结束。若存在error则失败;否则从response.generateVideoResponse.generatedSamples[0].video.uri获取视频 URI
建议轮询间隔约 10 秒,直到 done=true。
uristring
视频下载地址。获取后请尽快下载:
curl -L \
-o output.mp4 \
-H "Authorization: Bearer sk-xxxxxx" \
"${video_uri}"错误处理
HTTP 400 参数错误
| 场景 | 处理建议 |
|---|---|
未传 instances[].prompt | 补全必填字段 |
durationSeconds 传了数字而非字符串 | 改为 "4" / "6" / "8" |
1080p / 4k 搭配非 8 秒时长 | 将 durationSeconds 设为 "8" |
| 首尾帧 / 参考图片场景时长非 8 | 将 durationSeconds 设为 "8" |
lastFrame 放到了 parameters | 将 lastFrame 移到 instances[],与 image 同级 |
referenceImages 超过 3 张 | 减少至最多 3 张 |
4k 搭配 Fast 模型 | 改用标准版 veo-3.1-generate-preview,或降低至 1080p |
| 视频续写使用非 720p 分辨率 | 将 resolution 设为 720p |
| 视频续写输入非 Veo 生成结果 | 确保 video 为此前 Veo 生成的 MP4 |
personGeneration 与场景不匹配 | 文生/续写用 allow_all,图生/首尾帧/参考图用 allow_adult |
HTTP 401 / 403 鉴权错误
401 Unauthorized:API Key 无效或已过期403 Forbidden:API Key 无权访问此模型
HTTP 402 余额不足
返回余额不足错误。请前往 AutoRouter 控制台充值。
Operation error
当 done=true 且存在 error 时,任务失败:
| 原因 | 处理建议 |
|---|---|
| 内容安全策略拦截 | 调整 prompt,避免敏感内容 |
durationSeconds 值不在支持范围 | 使用 "4" / "6" / "8" |
| 视频续写超出限制 | 检查输入视频是否为 Veo 生成、时长 ≤ 141 秒、续写次数 ≤ 20 次 |
任务失败时 AutoRouter 会自动退款到你的账户。