跳转到主要内容
开始前,请注册 API易,获取 API 密钥 https://api.apiyi.com/token (复制令牌)

同步调用说明

VEO 3.1 支持同步调用方式,使用对话补全接口 /v1/chat/completions,适合需要实时交互的场景。
调用方式对比:
  • 同步调用:适合实时交互,支持流式输出,可以看到生成进度
  • 异步调用:适合批量处理,提交任务后轮询获取结果,详见 API 参考

快速开始

1

准备 API 密钥

前往 API易控制台 获取 API 密钥
2

发送请求

使用对话补全接口生成视频,支持流式和非流式两种方式
3

获取结果

实时获取生成进度和视频链接

认证方式

所有 API 请求都需要在请求头中包含 API 密钥:
Authorization: sk-your-api-key
安全提醒: 请勿在客户端代码中暴露 API 密钥。建议在服务端环境变量中存储。

示例 1:文生视频

最简单的方式,使用文本描述生成视频:
curl --location --request POST 'https://api.apiyi.com/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: sk-your-api-key' \
--data-raw '{
    "messages": [{"role": "user", "content": "画只猪在天上飞"}],
    "model": "veo-3.1",
    "stream": true,
    "n": 2
}'

参数说明

参数类型必填说明
messagesarray对话消息数组,包含用户的提示词
modelstring使用的模型名称,如 veo-3.1
streamboolean是否开启流式输出,默认 false
ninteger生成视频数量,默认 1,最大 4
模型选择: 默认为竖屏,使用 veo-3.1-landscape 可生成横屏视频,使用 -fast 后缀可使用快速模型。

示例 2:帧转视频(Frame-to-Video)

使用一张或两张图片作为关键帧生成视频:
curl --location --request POST 'https://api.apiyi.com/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: sk-your-api-key' \
--data-raw '{
    "messages": [{
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "根据两张图片生成一个完整的过渡视频"
            },
            {
                "type": "image_url",
                "image_url": {
                    "url": "开始帧图片URL或base64"
                }
            },
            {
                "type": "image_url",
                "image_url": {
                    "url": "结束帧图片URL或base64(可选)"
                }
            }
        ]
    }],
    "model": "veo-3.1-landscape-fast-fl",
    "stream": true,
    "n": 1
}'

图片参数说明

  • 开始帧图片:必传,仅限一张
  • 结束帧图片:可选,如果不传则自动生成过渡效果
  • 图片格式:支持 URL 或 base64 编码

流式响应说明

开启流式输出后(stream: true),系统会实时返回生成进度和结果:

响应示例

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"```json\n{\n    \"prompt\": \"画只猪在天上飞\",\n    \"mode\": \"竖屏模式\"\n}\n```\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"> ⌛️ 视频正在生成中,请耐心等待...\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"> 🏃 进度:9.0%\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"> 🏃 进度:18.0%\n\n"},"finish_reason":null}]}

...

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"> 🏃 进度:90.2%\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{"content":"> ✅ 第1个视频生成成功,[点击这里](https://veo-video.gptkey.asia/assets/flow/xxx.mp4) 查看视频~~~\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1762181811,"model":"veo-3.1-fast","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":16,"completion_tokens":292,"total_tokens":308}}

data: [DONE]

响应说明

生成速度

VEO 3.1 生成速度: 比 Sora 2 快 50%!
  • 快速模型 (-fast):约 30-60 秒
  • 标准模型:约 1-2 分钟

下一步