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 slowly along a rain-soaked street as the camera pans right. Realistic style, natural rain sound, no subtitles, and no sudden cuts.",
"settings": {
"resolution": "720p",
"aspect_ratio": "21:9",
"duration": 3
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
string
required
Bearer authentication. Use
Bearer YOUR_ANYFAST_API_KEY.string
default:"application/json"
required
Request body format.
Request body
string
required
Video description. You can include both desired and unwanted content. Prompt limits depend on character type; see the prompt length section.
object
Output resolution, duration, and aspect ratio.
string
720p or 1080p. Explicitly setting a value is recommended.integer
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.
string
21:9, 16:9, 9:16, or 1:1. adaptive is also supported by the shared output settings.object
General task options.
boolean
default:false
Whether to additionally generate a watermarked version.
string
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.
string
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": ""
}
}
integer
Business status code; the success example is
0.string
API message.
string
Request tracing identifier, when returned.
string
System task ID. Save it for querying.
string
Current task status.
integer
Creation time as a Unix timestamp in milliseconds.
integer
Update time as a Unix timestamp in milliseconds.
string
Caller-defined task ID; may be empty if unset.
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 and preserve the person's identity and composition. The person smiles and raises a hand as a breeze moves their hair. Add natural wind sound. Use one continuous shot, no subtitles."
},
{
"type": "first_frame",
"url": "https://example.com/first-frame.jpg",
"id": "start"
}
],
"settings": {
"resolution": "720p",
"duration": 3
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
Request headers
string
required
Bearer authentication. Use
Bearer YOUR_ANYFAST_API_KEY.string
default:"application/json"
required
Request body format.
Request body
object[]
required
Prompt and keyframe images. Include a
prompt item. Image input supports up to 10 images.string
required
Use
prompt, first_frame, middle_frame, or last_frame for this workflow.string
Prompt text when
type is prompt. Use an asset ID as @id to reference an image in the prompt.string
Publicly accessible image URL, or a supported Base64 image value.
string
Optional unique asset ID used by the prompt. IDs must not repeat within a task.
object
Output settings.
string
720p or 1080p.integer
Integer from 3 to 30 seconds.
string
Optional output ratio. For keyframe input, use images with the intended composition; the example omits this field.
boolean
default:false
Whether to additionally generate a watermarked version.
string
Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
string
Optional callback URL; confirm current-channel support 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": ""
}
}
string
System task ID. Save it for querying.
string
Initial task status, such as
submitted.integer
Creation Unix timestamp in milliseconds.
integer
Update Unix timestamp in milliseconds.
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 the face, hairstyle, and clothes of the person in @actor. Use the action pacing from @motion. Show the person moving naturally in a bright training studio. Keep the camera steady and add no subtitles."
},
{
"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
string
required
Bearer authentication. Use
Bearer YOUR_ANYFAST_API_KEY.string
default:"application/json"
required
Request body format.
Request body
object[]
required
Prompt and reference assets. Include a prompt item. Asset IDs must be unique within a task.
string
required
Use
prompt, refer_image, first_frame, middle_frame, last_frame, feature_video, or base_video.string
Prompt text for a
prompt item. Use @id to specify how a reference asset should be used.string
Publicly accessible URL for an image or video asset. Images may also use supported Base64 content.
string
Unique asset ID used to reference an item from the prompt.
object
Output settings.
string
720p or 1080p.integer
Integer from 3 to 30 seconds. If omitted, use prompt duration, then
base_video duration, then default to 10 seconds.string
21:9, 16:9, 9:16, 1:1, or adaptive.boolean
default:false
Whether to additionally generate a watermarked version.
string
Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
string
Optional callback URL; confirm current-channel support 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": ""
}
}
string
System task ID. Save it for querying.
string
Initial task status, such as
submitted.integer
Creation Unix timestamp in milliseconds.
integer
Update Unix timestamp in milliseconds.
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 only the red ceramic cup in the person's hand to blue. Preserve the person's face, clothes, hand movement, background, camera motion, dialogue, and ambient sound. Do not add objects or subtitles."
},
{
"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
string
required
Bearer authentication. Use
Bearer YOUR_ANYFAST_API_KEY.string
default:"application/json"
required
Request body format.
Request body
object[]
required
Prompt and source video. Include a prompt item and at most one
base_video item.string
required
Use
prompt and base_video for this editing example. Other Omni reference asset types are listed in the Omni reference tab.string
required
Describe what to change and what to preserve. Use
@id to refer to the source video.string
required
Publicly accessible source-video URL.
string
required
Unique asset ID referenced by the prompt.
string
720p or 1080p.string
Set
adaptive to determine the ratio from the prompt or input video.integer
Optional integer from 3 to 30 seconds. If omitted, duration follows explicit prompt intent, then the source video, then defaults to 10 seconds.
boolean
default:false
Whether to additionally generate a watermarked version.
string
Optional caller-defined task ID. It does not replace the system task ID or guarantee duplicate-charge prevention.
string
Optional callback URL; confirm current-channel support 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": ""
}
}
string
System task ID. Save it for querying.
string
Initial task status.
integer
Creation Unix timestamp in milliseconds.
integer
Update Unix timestamp in milliseconds.
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
integer
Business status code; the success example is
0.string
API message.
object[]
Task records matching the supplied task IDs. The query response uses an array; the create response uses an object.
string
System task ID.
string
submitted, processing, succeeded, or failed.integer
Creation Unix timestamp in milliseconds.
integer
Last-update Unix timestamp in milliseconds.
object[]
Generated outputs, available when the task succeeds.
string
Output type. Select
video for the generated video.string
Video result URL.
string
Actual duration in seconds; may be a decimal string.
string
Watermarked result URL, present only when provided.
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.