model or model_name in the request body. Configure output with settings and general options with options.
- Text to video
- Image to video
- Omni reference
- Video editing
- Query task
- Input requirements
Create task
POST /kling/v2/text-to-video/kling-4.0cURL
curl --request POST \
--url 'https://www.anyfast.ai/kling/v2/text-to-video/kling-4.0' \
--header 'Authorization: Bearer YOUR_ANYFAST_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "A red car drives in rain as the camera pans right. Realistic style, natural sound.",
"settings": {
"resolution": "720p",
"aspect_ratio": "21:9",
"duration": 3
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
Request body
Video description. You can include both desired and unwanted content. Prompt limits depend on character type; see the prompt length section.
Integer from 3 to 30 seconds. Explicitly setting a value is recommended. If omitted, the prompt duration is used when clear; otherwise the default is 10 seconds.
Caller-defined task identifier. Keep it unique within the current user scope. It does not replace the system task ID or guarantee duplicate-charge prevention.
Task-status callback URL defined by the official protocol. Confirm support on the current channel before use.
Create response
200
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "asyntask_EXAMPLE",
"status": "submitted",
"create_time": 1793672435967,
"update_time": 1793672435967,
"external_id": ""
}
}
Create task
POST /kling/v2/image-to-video/kling-4.0cURL
curl --request POST \
--url 'https://www.anyfast.ai/kling/v2/image-to-video/kling-4.0' \
--header 'Authorization: Bearer YOUR_ANYFAST_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"type": "prompt",
"text": "Start from @start. Preserve identity; the person smiles and raises a hand in a breeze."
},
{
"type": "first_frame",
"url": "https://example.com/first-frame.jpg",
"id": "start"
}
],
"settings": {
"resolution": "720p",
"duration": 3
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
Request body
Prompt and keyframe images. Include a
prompt item. Image input supports up to 10 images.Optional output ratio. For keyframe input, use images with the intended composition; the example omits this field.
Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
Create response
200
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "asyntask_EXAMPLE",
"status": "submitted",
"create_time": 1793672435967,
"update_time": 1793672435967,
"external_id": ""
}
}
Keyframe types
| Type | Use | Fields |
|---|---|---|
prompt | Describe action, camera, and sound | text |
first_frame | First-frame image | url, optional id |
middle_frame | Intermediate keyframe | url, optional id |
last_frame | Last-frame image | url, optional id |
Create task
POST /kling/v2/omni-video/kling-4.0cURL
curl --request POST \
--url 'https://www.anyfast.ai/kling/v2/omni-video/kling-4.0' \
--header 'Authorization: Bearer YOUR_ANYFAST_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"type": "prompt",
"text": "Preserve @actor identity; use @motion pacing in a bright studio."
},
{
"type": "refer_image",
"url": "https://example.com/character.jpg",
"id": "actor"
},
{
"type": "feature_video",
"url": "https://example.com/motion.mp4",
"id": "motion"
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "1:1",
"duration": 3
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
Request body
Prompt and reference assets. Include a prompt item. Asset IDs must be unique within a task.
Use
prompt, refer_image, first_frame, middle_frame, last_frame, feature_video, or base_video.Publicly accessible URL for an image or video asset. Images may also use supported Base64 content.
Integer from 3 to 30 seconds. If omitted, use prompt duration, then
base_video duration, then default to 10 seconds.Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
Create response
200
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "asyntask_EXAMPLE",
"status": "submitted",
"create_time": 1793672435967,
"update_time": 1793672435967,
"external_id": ""
}
}
Reference content types
| Type | Use | Main fields |
|---|---|---|
prompt | Describe generation or editing requirements | text |
refer_image | Appearance, scene, or style reference | url, id |
first_frame | First-frame constraint | url, id |
middle_frame | Intermediate keyframe constraint | url, id |
last_frame | Last-frame constraint | url, id |
feature_video | Motion or other feature reference | url, id |
base_video | Source video for editing | url, id |
element and voice assets for previously created characters and voices. These require corresponding assets and management capabilities; this reference does not describe those management APIs.Duration selection
Duration is determined in this order: explicitsettings.duration, clear duration intent in the prompt, base_video duration, then the 10-second default. Submit at most one base_video.Create task
POST /kling/v2/omni-video/kling-4.0Submit the source clip as base_video. Describe both the change and the content that should remain unchanged.cURL
curl --request POST \
--url 'https://www.anyfast.ai/kling/v2/omni-video/kling-4.0' \
--header 'Authorization: Bearer YOUR_ANYFAST_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"type": "prompt",
"text": "Edit @base: change the red cup to blue; preserve everything else."
},
{
"type": "base_video",
"url": "https://example.com/source-video.mp4",
"id": "base"
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "adaptive"
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
Request body
Use
prompt and base_video for this editing example. Other Omni reference asset types are listed in the Omni reference tab.Optional integer from 3 to 30 seconds. If omitted, duration follows explicit prompt intent, then the source video, then defaults to 10 seconds.
Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
Create response
200
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "asyntask_EXAMPLE",
"status": "submitted",
"create_time": 1793672435967,
"update_time": 1793672435967,
"external_id": ""
}
}
settings.duration when you need to control the output length. The example omits it so the source video duration is used when no explicit duration intent is present in the prompt.Query tasks
GET /kling/v2/tasks?task_ids=YOUR_TASK_IDUse the system task ID from the create response’s data.id. Query with the same AnyFast API key used to create the task. The query path does not require a model name or upstream task ID.cURL
curl --request GET \
--url 'https://www.anyfast.ai/kling/v2/tasks?task_ids=YOUR_TASK_ID' \
--header 'Authorization: Bearer YOUR_ANYFAST_API_KEY'
Query response
200
{
"code": 0,
"message": "",
"data": [
{
"id": "asyntask_EXAMPLE",
"status": "succeeded",
"create_time": 1793672435967,
"update_time": 1793672563000,
"outputs": [
{
"type": "video",
"url": "https://example.com/generated-video.mp4",
"duration": "3.042"
}
]
}
]
}
Response fields
Task records matching the supplied task IDs. The query response uses an array; the create response uses an object.
Image requirements
| Property | Requirement |
|---|---|
| Formats | JPG, JPEG, PNG |
| Maximum size | 30 MB per image |
| Dimensions | At least 300 px wide and 300 px high |
| Aspect ratio | 2:5–5:2 |
| Count | Up to 10 images |
Video requirements
| Property | Requirement |
|---|---|
| Formats | MP4, MOV |
| Maximum size | 300 MB per video |
| Duration | Each video and total input-video duration must be 3–30 seconds |
| Dimensions | 700–4553 px wide and high; up to 8,294,400 total pixels |
| Aspect ratio | 2:5–5:2 |
| Input frame rate | 24–60 fps |
| Output frame rate | 24 fps |
Omni reference limits
- Images, videos, elements, and voices combined: up to 15 assets.
- With no video-character elements, up to 5 reference videos.
- With video-character elements, the combined number of video-character elements and reference videos must not exceed 5.
- Total input-video duration includes feature reference videos, the video being edited, and video-character elements.
- Submit at most one
base_videoper task.
Prompt length
The limits apply to a text-to-videoprompt or the prompt item’s text in contents:| Text | Limit |
|---|---|
| English only | 26,000 characters |
| Non-English only | 11,000 characters |
| Mixed text | English characters ÷ 26,000 + non-English characters ÷ 11,000 ≤ 1 |
Creation is asynchronous. A successful create response means the task was accepted; query the returned
data.id to retrieve its status and result.