任务:生成视频
luma 视频接口,用于基于提示词生成短视频。
概览
- 请求方法:
POST - 请求路径:
/luma/generations - 内容类型:
application/json - 分类:视频模型(Video)/luma视频
认证方式
- Header:
Authorization: Bearer <token>
请求参数
JSON 请求体字段
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
| user_prompt | string | 是 | 提示词 |
| expand_prompt | boolean | 否 | 是否开启 prompt 优化 |
| image_url | string | 否 | 参考图,支持第三方图片地址或 Base64 |
| image_end_url | string | 否 | 关键帧,支持第三方图片地址或 Base64 |
| notify_hook | string | 否 | 回调地址 |
| loop | boolean | 否 | 是否循环首尾呼应 |
| aspect_ratio | string | 否 | 视频尺寸比,支持 1:1, 4:3, 3:4, 16:9, 9:16 |
请求示例
curl 示例
bash
curl -X POST "https://api.gpt.ge/luma/generations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_TOKEN" \
-d '{
"user_prompt": "cat dance",
"expand_prompt": true,
"image_url": "https://example.com/reference.png",
"image_end_url": "https://example.com/keyframe.png",
"notify_hook": "https://example.com/hook",
"loop": true,
"aspect_ratio": "16:9"
}'JavaScript (fetch) 示例
javascript
fetch('https://api.gpt.ge/luma/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
body: JSON.stringify({
user_prompt: 'cat dance',
expand_prompt: true,
image_url: 'https://example.com/reference.png',
image_end_url: 'https://example.com/keyframe.png',
notify_hook: 'https://example.com/hook',
loop: true,
aspect_ratio: '16:9'
})
})
.then(res => res.json())
.then(console.log)Python 示例(requests)
python
import requests
resp = requests.post(
'https://api.gpt.ge/luma/generations',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
},
json={
'user_prompt': 'cat dance',
'expand_prompt': True,
'image_url': 'https://example.com/reference.png',
'image_end_url': 'https://example.com/keyframe.png',
'notify_hook': 'https://example.com/hook',
'loop': True,
'aspect_ratio': '16:9'
}
)
print(resp.json())返回字段说明
| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | 任务 ID |
| state | string | 任务状态 |
| created_at | string | 任务创建时间 |
| request | object | 请求信息 |
| request.prompt | string | 原始提示词 |
| request.aspect_ratio | string | 请求中的视频尺寸比 |
返回示例(200)
json
{
"id": "e70fdf3c-ce95-4dd1-a967-220ce957aff5",
"state": "pending",
"created_at": "2024-12-24T18:01:25.319129Z",
"request": {
"prompt": "美人鱼",
"aspect_ratio": "16:9"
}
}