文生视频
Sora 文生视频接口,用于将文本提示生成短视频。
概览
- 请求方法:
POST - 请求路径:
/v1/videos - 内容类型:
application/json - 分类:视频模型(Video)/sora视频
认证方式
- Header:
Authorization: Bearer <token>
请求参数
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| prompt | string | 是 | 生成视频的文本提示 |
| model | string | 否 | 模型名称,支持 sora-2、sora-2-pro,默认 sora-2 |
| seconds | string | 否 | 视频时长,字符串类型,支持 4、8、12,默认 4 |
| size | string | 否 | 视频尺寸,支持 720x1280、1280x720、1024x1792、1792x1024,1792 尺寸仅支持 sora-2-pro |
请求示例
curl 示例
bash
curl -X POST "https://api.gpt.ge/v1/videos" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_TOKEN" \
-d '{
"prompt": "一只凶猛的老虎破门闯入农家小院,土狗吓得跑开,猫咪跳出来击败吓跑老虎。",
"model": "sora-2",
"seconds": "8",
"size": "1280x720"
}'JavaScript (fetch) 示例
javascript
fetch('https://api.gpt.ge/v1/videos', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
body: JSON.stringify({
prompt: '一只凶猛的老虎破门闯入农家小院,土狗吓得跑开,猫咪跳出来击败吓跑老虎。',
model: 'sora-2',
seconds: '8',
size: '1280x720'
})
})
.then(res => res.json())
.then(console.log)Python 示例(requests)
python
import requests
resp = requests.post(
'https://api.gpt.ge/v1/videos',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
json={
'prompt': '一只凶猛的老虎破门闯入农家小院,土狗吓得跑开,猫咪跳出来击败吓跑老虎。',
'model': 'sora-2',
'seconds': '8',
'size': '1280x720'
}
)
print(resp.json())返回字段说明
| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | 视频任务 ID |
| object | string | 返回对象类型,一般为 video |
| created_at | integer | 创建时间戳 |
| status | string | 任务状态 |
| completed_at | null | 完成时间,未完成时为 null |
| error | null | 错误信息,成功时为 null |
| expires_at | null | 过期时间,当前返回 null |
| model | string | 使用的模型 |
| progress | integer | 任务进度 |
| remixed_from_video_id | null | remix 源视频 ID,当前未使用时为 null |
| seconds | string | 视频时长 |
| size | string | 视频尺寸 |
返回示例(200)
json
{
"id": "video_68f082321ed08193a4eaf01376fa10bc0284bd663de64dc5",
"object": "video",
"created_at": 1760592434,
"status": "queued",
"completed_at": null,
"error": null,
"expires_at": null,
"model": "sora-2",
"progress": 0,
"remixed_from_video_id": null,
"seconds": "8",
"size": "1280x720"
}