图生视频
Kling 4.0 Flash 的 image_to_video:以一张图片为首帧生成视频。
Kling 4.0 Flash 用你的图片作为视频的首帧,生成接下来的画面。
创建任务
POST
https://api.nanoapi.ai/v1/tasks用所有模型共用的创建任务接口,model 传 "kling-4.0-flash",mode 传 "image_to_video"。
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer <API Key>,见鉴权 |
Content-Type | 是 | application/json |
Idempotency-Key | 否 | 每个新任务一个唯一字符串,建议用 UUID(1–255 个字符),见防止重复创建 |
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | kling-4.0-flash |
mode | string | 是 | image_to_video |
image_urls | string[] | 是 | 只能传 1 张图片,作为首帧;传 2 张及以上返回 400 invalid_request。见素材 |
prompt | string | 否 | 描述画面如何变化,最长 8000 字符。可以用 @Image1 指代图片,见引用素材 |
aspect_ratio | string | 是 | 画面比例:auto、21:9、16:9、9:16 或 1:1。auto 跟随首帧的比例 |
resolution | string | 是 | 720p |
duration | integer | 是 | 输出时长(秒),3–20,按此计费,见价格 |
webhook_url | string | 否 | 任务成功或失败时通知该地址:https,最长 2048 字符,不能指向内网、回环或保留地址。见回调 |
一张首帧,5 秒:
curl https://api.nanoapi.ai/v1/tasks \
-H "Authorization: Bearer $NANOAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-flash",
"mode": "image_to_video",
"image_urls": ["https://example.com/first_frame.jpg"],
"prompt": "The cat slowly turns its head and looks at the camera",
"aspect_ratio": "auto",
"resolution": "720p",
"duration": 5
}'响应:200 OK,返回新建的任务(字段说明)。保存 data.id,用它获取结果;任务创建后仍可能失败,见错误。
{
"code": 200,
"message": "success",
"data": {
"object": "task",
"id": "tk_01jbm3r8x5c2v9b6n4q7w1e3t5",
"model": "kling-4.0-flash",
"status": "queued",
"error": null,
"created_at": "2026-11-18T08:30:00Z"
}
}价格
费用 = 输出时长 duration × 每秒单价正在读取当前价格…
计费秒数即请求的 duration。Kling 4.0 Flash 所有模式的价格见 Kling 4.0 Flash → 价格。当前单价见 GET /v1/products(产品 kling_flash,prices 中 mode 为 image_to_video 的行),以任务的 billing.frozen 为准;冻结和扣费规则见计费。
错误
见 Kling 4.0 Flash → 错误。本模式的参数规则见上面的参数表。