Kling 4.0 Flash Keyframe To Video
Endpoint
POST /jobs/createTask
Full URL: https://modelfold.ai/v1/jobs/createTask
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
Output resolution is always 720p. Duration is 3–20 seconds. When a first frame is provided, the output follows that image's aspect ratio; aspect_ratio is only used when no first frame is sent (default 16:9).
Query Task Status
After submitting a task, you can check the task progress and retrieve generation results via the unified query endpoint:
- Get Task Details — Learn how to check the task status and obtain the generated results
TIP
In the production environment, it is recommended to use the callBackUrl parameter to receive the automatic notification upon completion of the generation, rather than polling the status endpoint.
Related Resources
- Market Overview — View all available models
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The name of the model used to generate the task. This field is required. - This endpoint requires the kling-4.0/flash-keyframe-to-video model Default:"kling-4.0/flash-keyframe-to-video"。 Allowed values:kling-4.0/flash-keyframe-to-video。 Example:kling-4.0/flash-keyframe-to-video。 |
callBackUrl | string | No | The URL to receive generation task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when generation completes - Callback includes generated content URLs and task information - Your callback endpoint should accept POST requests with JSON payload containing results - Alternatively, use the Get Task Details endpoint to poll task status - To ensure callback security, see Webhook Verification Guide for signature verification implementation Example: https://your-domain.com/api/callback。 |
input | object | Yes | Input parameters for the generation task. |
input.prompt | string | Yes | Video description. Required. Maximum 8000 characters. When first_frame_url is provided, mention it as @first_frame. Middle frames and a last frame are not supported on Kling 4.0 Flash — sending keyframes or last_frame is rejected. minLength: 1. maxLength: 8000. Example:Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.<br>REFERENCES: @first_frame is the exact opening frame.。 |
input.duration | integer | No | Output video duration in seconds. Integer from 3 to 20. Default: 5. Default:5。 minimum: 3. maximum: 20. Example:5。 |
input.resolution | string | No | Output resolution. Kling 4.0 Flash only supports 720p. Default: 720p. Default:"720p"。 Allowed values:720p。 Example:720p。 |
input.aspect_ratio | string | No | Output aspect ratio. 16:9, 9:16, 1:1, or 21:9. There is no auto. Only used when first_frame_url is omitted (text-to-video); default 16:9. When a first frame is provided, the output follows that image's aspect ratio. Allowed values:16:9 / 9:16 / 1:1 / 21:9。 Example:16:9。 |
input.first_frame_url | string | No | Optional first-frame image URL. Mention it in the prompt as @first_frame. If omitted, the request is plain text-to-video. Middle frames (keyframes) and a last frame (last_frame) are not supported. pattern: ^https?://. |
Request Example
curl -X POST "https://modelfold.ai/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0/flash-keyframe-to-video",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\nREFERENCES: @first_frame is the exact opening frame.",
"first_frame_url": "https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}'import os
import requests
resp = requests.post(
"https://modelfold.ai/v1/jobs/createTask",
headers={
"Authorization": "Bearer " + os.environ["MODELFOLD_API_KEY"],
"Content-Type": "application/json",
},
json={
"model": "kling-4.0/flash-keyframe-to-video",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\nREFERENCES: @first_frame is the exact opening frame.",
"first_frame_url": "https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
},
},
)
print(resp.json())const resp = await fetch("https://modelfold.ai/v1/jobs/createTask", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.MODELFOLD_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "kling-4.0/flash-keyframe-to-video",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\nREFERENCES: @first_frame is the exact opening frame.",
"first_frame_url": "https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}),
});
console.log(await resp.json());package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"model":"kling-4.0/flash-keyframe-to-video","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\nREFERENCES: @first_frame is the exact opening frame.","first_frame_url":"https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png","duration":5,"resolution":"720p","aspect_ratio":"16:9"}}`)
req, _ := http.NewRequest("POST", "https://modelfold.ai/v1/jobs/createTask", body)
req.Header.Set("Authorization", "Bearer " + os.Getenv("MODELFOLD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String body = "{\"model\":\"kling-4.0/flash-keyframe-to-video\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\\nREFERENCES: @first_frame is the exact opening frame.\",\"first_frame_url\":\"https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png\",\"duration\":5,\"resolution\":\"720p\",\"aspect_ratio\":\"16:9\"}}";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://modelfold.ai/v1/jobs/createTask"))
.header("Authorization", "Bearer " + System.getenv("MODELFOLD_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());
}
}<?php
$ch = curl_init('https://modelfold.ai/v1/jobs/createTask');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv("MODELFOLD_API_KEY"),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{"model":"kling-4.0/flash-keyframe-to-video","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\\nREFERENCES: @first_frame is the exact opening frame.","first_frame_url":"https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png","duration":5,"resolution":"720p","aspect_ratio":"16:9"}}',
]);
echo curl_exec($ch);
curl_close($ch);using System;
using System.Net.Http;
using System.Text;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://modelfold.ai/v1/jobs/createTask");
req.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("MODELFOLD_API_KEY"));
req.Content = new StringContent("{\"model\":\"kling-4.0/flash-keyframe-to-video\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\\nREFERENCES: @first_frame is the exact opening frame.\",\"first_frame_url\":\"https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png\",\"duration\":5,\"resolution\":\"720p\",\"aspect_ratio\":\"16:9\"}}", Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());{
"model": "kling-4.0/flash-keyframe-to-video",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “ModelFold AI” patch.\nREFERENCES: @first_frame is the exact opening frame.",
"first_frame_url": "https://static.aiquickdraw.com/tools/example/1793862976499_p1yBE2dY.png",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}Response
200 — Request Successful
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | See the response field; handle the returned status before retrying. |
msg | string | 否 | Response message, error description when failed 示例:success。 |
data | object | 是 | — |
data.taskId | string | 是 | Task ID, can be used with Get Task Details endpoint to query task status |
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_kling-4.0-flash-keyframe-to-video_abc123"
}
}Callback
videoTaskCompleted
Callback URL: {request.body#/callBackUrl} (the callBackUrl in the request body).
The system POSTs this callback to callBackUrl when the kling-4.0/flash-keyframe-to-video task succeeds or fails.
Callback body parameters
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | Unified callback code: 200 for success, 501 for failure. Allowed values:200 / 501。 Example:200。 |
msg | string | 是 | Unified callback message. Allowed values:Playground task completed successfully. / Playground task failed.。 Example:Playground task completed successfully.。 |
data | object | 是 | Task result. On success, resultJson contains resultUrls. On failure, failCode and failMsg are present and resultJson is omitted. |
data.completeTime | integer | 否 | Task completion timestamp in milliseconds. Use this as the completion time. |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. |
data.createTime | integer | 否 | Task creation timestamp in milliseconds. |
data.model | string | 是 | The model used for the task. Allowed values:kling-4.0/flash-keyframe-to-video。 Example:kling-4.0/flash-keyframe-to-video。 |
data.param | string | 是 | JSON string of the submitted task: model, callBackUrl, and input. input matches this endpoint's parameters (prompt, duration, resolution, aspect_ratio, first_frame_url). |
data.resultJson | string | 否 | JSON string of the generation result. Present only when state is success. For this model it contains resultUrls, an array of .mp4 URLs. |
data.state | string | 是 | Terminal task state. Allowed values:success / fail。 Example:success。 |
data.taskId | string | 是 | The unique task identifier. Same as data.taskId returned by Create Task. |
data.updateTime | integer | 否 | Task update timestamp in milliseconds. May equal createTime; use completeTime as the completion time. |
data.failCode | string | 否 | Failure code, a numeric string such as "400" or "500". Present only when state is fail. |
data.failMsg | string | 否 | Failure reason. Present only when state is fail. For this model this may be a frame-count error (duration 5s allows at most 6 frames (first + keyframes + last), got 7), a missing first_frame_url, an undeclared @first_frame / @keyframe_N / @last_frame mention, or an upstream original message about image fetch/moderation/size. |
Task completed successfully
{
"code": 200,
"data": {
"completeTime": 1792670085074,
"costTime": 718,
"createTime": 1792669367000,
"model": "kling-4.0/flash-keyframe-to-video",
"param": "{\"input\":\"{\\\"duration\\\":10,\\\"keyframe_urls\\\":[],\\\"prompt\\\":\\\"女孩出门\\\",\\\"resolution\\\":\\\"720p\\\"}\",\"callBackUrl\":\"https://webhook.uutool.cn/bfa7de80-8dd8-4844-9e34-4032ddbbf3c1\",\"model\":\"kling-4.0/flash-keyframe-to-video\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/k/ce115adfa78260a99009eebddac1d187_1_1792670083_1582.mp4\"]}",
"state": "success",
"taskId": "ce115adfa78260a99009eebddac1d187",
"updateTime": 1792669367000
},
"msg": "Playground task completed successfully."
}Task failed
{
"code": 501,
"data": {
"completeTime": 1792670085074,
"costTime": 718,
"createTime": 1792669367000,
"failCode": "400",
"failMsg": "duration 5s allows at most 6 frames (first + keyframes + last), got 7",
"model": "kling-4.0/flash-keyframe-to-video",
"param": "{\"input\":\"{\\\"duration\\\":5,\\\"first_frame_url\\\":\\\"https://example.com/first.png\\\",\\\"keyframe_urls\\\":[\\\"https://example.com/k1.png\\\",\\\"https://example.com/k2.png\\\",\\\"https://example.com/k3.png\\\",\\\"https://example.com/k4.png\\\",\\\"https://example.com/k5.png\\\"],\\\"last_frame_url\\\":\\\"https://example.com/last.png\\\",\\\"prompt\\\":\\\"女孩出门\\\",\\\"resolution\\\":\\\"720p\\\"}\",\"callBackUrl\":\"https://webhook.uutool.cn/bfa7de80-8dd8-4844-9e34-4032ddbbf3c1\",\"model\":\"kling-4.0/flash-keyframe-to-video\"}",
"state": "fail",
"taskId": "ce115adfa78260a99009eebddac1d187",
"updateTime": 1792669367000
},
"msg": "Playground task failed."
}