Skip to content

任务:生成视频

luma 视频接口,用于基于提示词生成短视频。


概览

  • 请求方法:POST
  • 请求路径:/luma/generations
  • 内容类型:application/json
  • 分类:视频模型(Video)/luma视频

认证方式

  • Header:Authorization: Bearer <token>

请求参数

JSON 请求体字段

字段类型必填描述
user_promptstring提示词
expand_promptboolean是否开启 prompt 优化
image_urlstring参考图,支持第三方图片地址或 Base64
image_end_urlstring关键帧,支持第三方图片地址或 Base64
notify_hookstring回调地址
loopboolean是否循环首尾呼应
aspect_ratiostring视频尺寸比,支持 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())

返回字段说明

字段类型描述
idstring任务 ID
statestring任务状态
created_atstring任务创建时间
requestobject请求信息
request.promptstring原始提示词
request.aspect_ratiostring请求中的视频尺寸比

返回示例(200)

json
{
  "id": "e70fdf3c-ce95-4dd1-a967-220ce957aff5",
  "state": "pending",
  "created_at": "2024-12-24T18:01:25.319129Z",
  "request": {
    "prompt": "美人鱼",
    "aspect_ratio": "16:9"
  }
}