| Method | Endpoint | Description |
|---|
| POST | /api/v1/generateTask/kling-2-1 | 创建生成任务 |
| GET | /api/v1/statusTask/kling-2-1 | 查询任务状态 |
所有请求需在请求头中携带 API 密钥:
Authorization: Bearer YOUR_API_KEY
请求体
{
"request_type": "async",
"callback_url": "https://...",
"provider": "auto",
"input": {
"mode": "standard-image-to-video",
"prompt": "...",
"duration": 5,
"image_urls": ["..."],
"aspect_ratio": "16:9",
"negative_prompt": "...",
"cfg_scale": 0.5
}
}
async(轮询)或 callback(webhook)
回调 URL,当 request_type=callback 时必填(条件必填)
路由策略:auto、value 或 official
模型输入参数
mode
string
默认值:"standard-image-to-video"
必填
生成模式(见下方选项)
16:9、9:16 或 1:1(master-text-to-video 必填)(条件必填)
模式选项:
standard-image-to-video — Standard 级图生视频,需 1 张图
pro-image-to-video — Pro 级图生视频,支持 1-2 张(尾帧)
master-text-to-video — Master 级文生视频
master-image-to-video — Master 级图生视频,需 1 张图
Standard 图生视频
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-1" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_type": "async",
"provider": "value",
"input": {
"mode": "standard-image-to-video",
"prompt": "animate this still life scene with subtle camera movement",
"duration": 5,
"image_urls": ["https://example.com/std_ref.jpg"],
"negative_prompt": "blur, low quality",
"cfg_scale": 0.6
}
}'
Pro 图生视频(含尾帧)
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-1" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_type": "callback",
"callback_url": "https://your-server.com/callback",
"provider": "official",
"input": {
"mode": "pro-image-to-video",
"prompt": "city skyline timelapse from day to night",
"duration": 10,
"image_urls": [
"https://example.com/pro_start.jpg",
"https://example.com/pro_end.jpg"
],
"cfg_scale": 0.4
}
}'
Master 文生视频
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-1" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_type": "async",
"input": {
"mode": "master-text-to-video",
"prompt": "a futuristic drone flying through neon-lit streets at night",
"duration": 5,
"aspect_ratio": "9:16",
"negative_prompt": "grainy, noisy, static",
"cfg_scale": 0.3
}
}'
POST /api/v1/generateTask/kling-2-1
成功时返回 taskId,用于后续查询状态。
成功:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678"
}
}
错误:
{
"code": 400,
"message": "Insufficient credits",
"data": null
}
GET /api/v1/statusTask/kling-2-1
通过 taskId 查询任务执行状态与结果。
curl -X GET "https://api.apixo.ai/api/v1/statusTask/kling-2-1?taskId=task_12345678" \
-H "Authorization: Bearer YOUR_API_KEY"
成功:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "success",
"resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/video.mp4\"]}",
"createTime": 1767965610929,
"completeTime": 1767965652317,
"costTime": 41388
}
}
失败:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "failed",
"failCode": "CONTENT_VIOLATION",
"failMsg": "Content does not meet safety guidelines"
}
}
状态响应字段
当前任务状态:pending、processing、success 或 failed。
包含 resultUrls 数组的 JSON 字符串。仅在成功时存在。使用 JSON.parse() 解析。
错误码。仅当 state 为 failed 时存在。详见错误码。
可读的错误信息。仅当 state 为 failed 时存在。
错误码
| Code | Description |
|---|
| 400 | 参数无效或请求错误 |
| 401 | API 密钥无效或缺失 |
| 429 | 超过速率限制 |
| Fail Code | Description |
|---|
CONTENT_VIOLATION | 内容违反安全准则 |
INVALID_IMAGE_URL | 无法访问提供的图片 URL |
速率限制
| Limit | Value |
|---|
| Requests | 10000 / minute |
| Concurrent tasks | 1000 |
超出限制返回 429 错误。请稍后重试。
- 生成时间:
- 5 秒视频:约 60-90 秒
- 10 秒视频:约 90-120 秒
- 提交任务后等待 60 秒,再每隔 5 秒轮询
- 回调模式:视频生成耗时,强烈建议使用
callback 模式。
- 视频有效期:结果 URL 有效期为 15 天。请及时下载。
- 内容审核:prompt 需符合内容安全准则。
- 层级选择:
standard:性价比高,适合批量
pro:支持首尾帧控制,适合精确创作
master:质量最高,适合专业生产
- 尾帧功能:
pro 模式支持 2 张图,第一张为起始帧,第二张为结束帧。
- 负面 prompt:用
negative_prompt 排除不想要的元素。
- CFG Scale:
- 值越高:越严格遵循 prompt,创意可能减少
- 值越低:越有创意,可能偏离 prompt
- 建议:0.3-0.7
- 图片格式:
image_urls 支持 JPG、PNG、WebP,单张最大 10MB。
视频生成比图像耗时更长 — 生产环境请使用 callback 模式。结果 URL 15 天后失效,请及时下载重要输出。