视频生成 (CogVideoX)
CogVideoX AI 视频生成模型,支持文本生成视频。
API 端点
POST
/videos/generations创建视频生成任务
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 必填 | 模型名称:CogVideoX |
prompt | string | 必填 | 视频描述文本 |
请求示例
请求示例
{
"model": "CogVideoX",
"prompt": "一只橘猫在花园里追逐蝴蝶,阳光明媚,慢动作镜头"
}响应示例
响应示例
{
"id": "video-123",
"created": 1677652288,
"model": "CogVideoX",
"task_status": "processing",
"video_url": null
}代码示例
Python
import requests
url = "https://your-proxy-domain.com/v1/videos/generations"
headers = {
"Authorization": "Bearer your-api-key",
"Content-Type": "application/json"
}
data = {
"model": "CogVideoX",
"prompt": "一只橘猫在花园里追逐蝴蝶,阳光明媚,慢动作镜头"
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print(result)
# 轮询检查视频生成状态
task_id = result.get("id")
# 使用 task_id 查询生成结果JavaScript
const response = await fetch('https://your-proxy-domain.com/v1/videos/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'CogVideoX',
prompt: '一只橘猫在花园里追逐蝴蝶,阳光明媚,慢动作镜头'
})
});
const result = await response.json();
console.log(result);
// 轮询检查视频生成状态
const taskId = result.id;
// 使用 taskId 查询生成结果cURL
curl https://your-proxy-domain.com/v1/videos/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"model": "CogVideoX",
"prompt": "一只橘猫在花园里追逐蝴蝶,阳光明媚,慢动作镜头"
}'