身份验证
将 API Key 作为 Bearer Token 发送。请求包含 JSON 正文时,还需携带 Content-Type: application/json。
HTTP headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json视频生成是异步任务。建议每 5-10 秒轮询一次 status;更短的间隔只会增加负载,不会让任务更快完成。
创建视频任务
POST
https://ltx-2ai.com/api/video/ltx-2/generate创建 LTX-2 任务并立即返回 task_id。本页覆盖文生视频和图生视频请求。
生成模式
文生视频
只发送 prompt,不发送 image;输出画幅由 aspect_ratio 控制。
图生视频
发送 prompt 和公网可访问的图片 URL;输出画幅由输入图片决定。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| type | string | 否 | 可选:text-to-video 或 image-to-video。省略时,提供 image 即自动选择图生视频。 |
| prompt | string | 是 | 视频描述,长度 3-2000 个字符;两种模式均必填。 |
| image | string | 否 | 公网图片 URL。图生视频必填;同时兼容 image_url 和 imageUrl。 |
| resolution | string | 否 | 480p、720p 或 1080p,默认 720p。 |
| aspect_ratio | string | 否 | 文生视频支持 16:9 或 9:16,默认 16:9。 |
| duration | integer | 否 | 视频时长 5-20 秒,默认 5 秒。 |
| seed | integer | 否 | 随机种子;使用 -1 获得随机结果。 |
| public | boolean | 否 | 任务是否可以出现在公共画廊。 |
请求示例
cURL
curl --request POST \
--url https://ltx-2ai.com/api/video/ltx-2/generate \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"type": "image-to-video",
"prompt": "The subject turns toward the camera and smiles naturally",
"image": "https://example.com/input.jpg",
"resolution": "720p",
"duration": 5,
"seed": -1
}'响应示例
200 OK
{
"code": 200,
"message": "success",
"data": {
"task_id": "n50abc123def456ltx2",
"status": "IN_PROGRESS",
"consumed_credits": 24
}
}查询任务状态
GET
https://ltx-2ai.com/api/video/ltx-2/status通过 GET 查询参数发送 task_id,也支持使用 JSON 正文的 POST 请求。任务为 IN_PROGRESS 时继续轮询。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| task_id | string | 是 | generate 接口返回的任务 ID。 |
请求示例
cURL
curl --request GET \
--url 'https://ltx-2ai.com/api/video/ltx-2/status?task_id=n50abc123def456ltx2' \
--header 'Authorization: Bearer YOUR_API_KEY'响应示例
200 OK
{
"code": 200,
"message": "success",
"data": {
"task_id": "n50abc123def456ltx2",
"status": "SUCCESS",
"consumed_credits": 24,
"error_message": null,
"created_at": "2026-08-07T12:00:00Z",
"request": {
"type": "image-to-video",
"prompt": "The subject turns toward the camera and smiles naturally",
"image": "https://example.com/input.jpg",
"resolution": "720p",
"duration": 5
},
"response": [
"https://cdn.example.com/video.mp4"
]
}
}状态值
IN_PROGRESS视频正在排队或渲染,请继续轮询。
SUCCESS生成完成,response 数组中包含视频 URL。
FAILED生成失败,请查看 error_message;任务服务会退回已扣积分。
错误响应
| HTTP | 说明 |
|---|---|
| 400 | 缺少必填参数或参数无效。 |
| 401 | Bearer API Key 缺失或无效。 |
| 404 | 找不到该 task_id 对应的任务。 |
| 405 | 接口不支持当前 HTTP 方法。 |
| 500 | 生成或状态查询暂时异常,请稍后重试或联系支持。 |
