视频 stream 与后台调用 · cogvideo-basic
/v1/responsesstream:true 返回进度和最终视频链接,以 response.completed 结束;background:true 返回 resp_ ID 供后续查询。流中没有实时视频帧。
同步 · 直接返回结果 · 本次请求等待处理并直接返回 JSON 或文件。
鉴权
使用客户 API Key。 获取与配置 →
Authorization: Bearer YOUR_API_KEY选择模型
查看该模型的能力与限制 →请求参数
长视频请求使用 stream=true 或 background=true。视频专用字段为本站扩展,不使用 chat/completions 协议。
- 不能同时提供 input_reference, image_url.
- 当 model = "cogvideo-basic": seconds: 1–5 或 ^[1-5]$;duration: 1–5 或 ^[1-5]$;不能 提供 reference_images;不能 提供 metadata,且 提供 metadata.reference_images.
- 当 model = "cogvideo-short": seconds 仅接受 8, "8";duration 仅接受 8, "8";size 必须为 "720x1280";resolution 必须为 "720p";aspect_ratio 必须为 "9:16";不能 提供 input_reference;不能 提供 image_url;不能 提供 reference_images;不能 提供 metadata,且 提供 metadata.reference_images;否则 size 仅接受 "1920x1080", "1080x1920", "1080x1080", "1440x1080", "1080x1440";resolution 必须为 "1080p".
- 必须选择且只选择一种输入方案: input 或 prompt.
modelstring必填本站公开调用名称,具体能力与限制见指南。
"cogvideo-fast""cogvideo-pro""cogvideo-basic""cogvideo-short"promptstring必填,不能为空白,最多 4096 个 Unicode 字符。
最少字符: 1 · 最多字符: 4096 · 匹配规则: "\\S"
secondsoneOf整数或整数字符串。fast/pro/basic 默认 5 秒,short 固定 8 秒;basic 最多 5 秒,参考生视频至少 3 秒。
展开结构
任选一种结构 · 1
integer
最小值: 1 · 最大值: 10
任选一种结构 · 2
string
匹配规则: "^(10|[1-9])$"
durationoneOfseconds 的兼容名称,两种写法同时出现时必须一致。
展开结构
任选一种结构 · 1
integer
最小值: 1 · 最大值: 10
任选一种结构 · 2
string
匹配规则: "^(10|[1-9])$"
sizestringfast/pro/basic 仅接受 1080p 尺寸,short 仅接受 720x1280;具体枚举见指南。
"1920x1080""1080x1920""1080x1080""1440x1080""1080x1440""720x1280"resolutionstringfast/pro/basic 为 1080p,short 为 720p。
"1080p""720p"aspect_ratiostring画面比例;图片默认 1:1,普通视频默认 16:9,short 固定 9:16。
"16:9""9:16""1:1""4:3""3:4"input_referencestring单张参考图片 URL / data URL;multipart 使用一个文件,最多 20 MiB。
匹配规则: "^(https?://|data:image/)"
image_urlstring单张 HTTP(S) 图片 URL 或图片 Base64 data URL。
匹配规则: "^(https?://|data:image/)"
reference_imagesarray非空参考图 URL / data URL 数组;与单图输入互斥。
最少条数: 1
展开结构
string — HTTP(S) 图片地址或 Base64 图片 Data URL。
匹配规则: "^(https?://|data:image/)"
generation_modestring仅参考生视频使用,默认 pro_ad。
"speed""pro""pro_ad"metadataobject视频扩展参数对象;multipart 表单使用 JSON 编码字符串。
展开结构
modestring必须与提供的图片输入匹配。
"text_to_video""image_to_video""reference_to_video"resolutionstring"1080p""720p"aspect_ratiostring"16:9""9:16""1:1""4:3""3:4"reference_imagesarray最少条数: 1
展开结构
string — HTTP(S) 图片地址或 Base64 图片 Data URL。
匹配规则: "^(https?://|data:image/)"
generation_modestring仅用于参考图模式。
"speed""pro""pro_ad"默认: "pro_ad"
不接受未列出的字段。
ninteger每次仅生成一个产物。
固定值: 1 · 默认: 1
sample_countinteger仅接受 1,不支持多产物。
固定值: 1 · 默认: 1
inputoneOf提示词文本或由 input_text/input_image 等内容组成的消息数组,与 prompt 互斥。
展开结构
任选一种结构 · 1
string
最少字符: 1
任选一种结构 · 2
array
最少条数: 1
streambooleantrue 返回视频任务进度和最终视频链接。
默认: false
backgroundbooleantrue 时立即返回 Response ID,之后查询结果。
默认: false
storeboolean宿主接受的 Responses 协议字段。
任选一种结构 · 1
- 不能同时提供 prompt.
object
必需字段:input
条件约束(JSON Schema)
{
"required": [
"input"
],
"not": {
"required": [
"prompt"
]
}
}任选一种结构 · 2
- 不能同时提供 input.
object
必需字段:prompt
条件约束(JSON Schema)
{
"required": [
"prompt"
],
"not": {
"required": [
"input"
]
}
}同时满足的规则 · 1
- 不能同时提供 input_reference, image_url.
object
条件约束(JSON Schema)
{
"not": {
"required": [
"input_reference",
"image_url"
]
}
}同时满足的规则 · 2
- 当 model = "cogvideo-basic": seconds: 1–5 或 ^[1-5]$;duration: 1–5 或 ^[1-5]$;不能 提供 reference_images;不能 提供 metadata,且 提供 metadata.reference_images.
object
条件约束(JSON Schema)
{
"if": {
"properties": {
"model": {
"const": "cogvideo-basic",
"type": "string"
}
}
},
"then": {
"properties": {
"seconds": {
"oneOf": [
{
"type": "integer",
"minimum": 1,
"maximum": 5
},
{
"type": "string",
"pattern": "^[1-5]$"
}
]
},
"duration": {
"oneOf": [
{
"type": "integer",
"minimum": 1,
"maximum": 5
},
{
"type": "string",
"pattern": "^[1-5]$"
}
]
}
},
"not": {
"anyOf": [
{
"required": [
"reference_images"
]
},
{
"required": [
"metadata"
],
"properties": {
"metadata": {
"required": [
"reference_images"
]
}
}
}
]
}
}
}同时满足的规则 · 3
- 当 model = "cogvideo-short": seconds 仅接受 8, "8";duration 仅接受 8, "8";size 必须为 "720x1280";resolution 必须为 "720p";aspect_ratio 必须为 "9:16";不能 提供 input_reference;不能 提供 image_url;不能 提供 reference_images;不能 提供 metadata,且 提供 metadata.reference_images;否则 size 仅接受 "1920x1080", "1080x1920", "1080x1080", "1440x1080", "1080x1440";resolution 必须为 "1080p".
object
条件约束(JSON Schema)
{
"if": {
"properties": {
"model": {
"const": "cogvideo-short",
"type": "string"
}
}
},
"then": {
"properties": {
"seconds": {
"enum": [
8,
"8"
]
},
"duration": {
"enum": [
8,
"8"
]
},
"size": {
"const": "720x1280",
"type": "string"
},
"resolution": {
"const": "720p",
"type": "string"
},
"aspect_ratio": {
"const": "9:16",
"type": "string"
}
},
"not": {
"anyOf": [
{
"required": [
"input_reference"
]
},
{
"required": [
"image_url"
]
},
{
"required": [
"reference_images"
]
},
{
"required": [
"metadata"
],
"properties": {
"metadata": {
"required": [
"reference_images"
]
}
}
}
]
}
},
"else": {
"properties": {
"size": {
"enum": [
"1920x1080",
"1080x1920",
"1080x1080",
"1440x1080",
"1080x1440"
],
"type": "string"
},
"resolution": {
"const": "1080p",
"type": "string"
}
}
}
}不接受未列出的字段。
响应
返回 Response 对象或 Responses SSE;必须检查最终响应状态,不能只根据 HTTP 状态判断成功。
Content-Type application/json
idstringobjectstringstatusstringmetadataobject视频扩展参数对象;multipart 表单使用 JSON 编码字符串。
展开结构
task_idstringoutputarray展开结构
contentarray展开结构
typestringtextstring包含私有分享链接的 HTML 视频元素。持有链接即可访问,请保护该链接。