Video modelsAdvanced usersUpdated
POST/v1/videos/generations

API console

POST/v1/videos/generations
View keys

Requests use the API key you enter and follow standard API billing.

Kling 4

Request ID kling-v4

Protocols

Authentication

Requests require an API key from API key management. For JSON requests, set Content-Type: application/json.

  • Authorization: Bearer YOUR_API_KEY

Request parameters

POST /v1/videos/generations

FieldTypeRequiredDescription
modelstringRequiredkling-v4. Use the model ID shown on this page.
promptstringConditionalDescribe the scene, action, and camera movement. Required for text or reference generation. Optional with a first frame.
contentarray<object>ConditionalList of reference assets and optional text items. Omit for text-only generation using prompt. Up to 8 images. Reference mode accepts up to five videos of 3–30 seconds each, up to 30 seconds in total. Editing or extension uses one video.
content[].typestringRequiredAccepted values are text, image_url, input_image, video_url, input_video.
content[].textstringConditionalProvide the prompt when the content item has type: "text".
content[].rolestringConditionalUse first_frame and last_frame. A last frame requires a first frame. Extension can use a single last_frame image as the target final frame. Use reference_image for a general reference image. Use reference_video for video inputs.
content[].asset_idstringConditionalUpload to POST /v1/videos/assets and use the returned id. Send kind (image, video) before file in the multipart form.
resolutionstringOptionalAccepted values are 720p, 1080p. Default: 720p.
ratiostringOptionalOutput aspect ratio. Also accepts the alias aspect_ratio. Accepted values are 16:9, 9:16, 1:1, 21:9. Reference mode also supports auto, its default. Omit for extension. Text-only generation defaults to 16:9.
durationintegerOptionalOutput length in seconds. Accepts whole seconds from 3 to 30. If omitted in edit mode, the source video determines duration. Other modes default to 5 seconds. For extension, this is the added clip length.
generate_audiobooleanOptionalAudio is always generated. Omit this field or set it to true.
omni_reference_task_typestringOptionalAccepted values are auto, reference, edit, extend. Defaults to auto, which infers the mode from the input media. Both edit and extend require one video.

Request examples

Set your API key in the local ICODEEASY_API_KEY environment variable and choose an endpoint that accepts direct HTTP calls. For endpoints that require a specific client, follow that client’s setup guide.

Replace example media URLs and asset IDs with your own valid assets.

Video Generations

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Slow camera push toward a paper lantern swaying gently by a lake.",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": true
}'

Video Generations · First frame

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Slow camera push toward a paper lantern swaying gently by a lake.",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": true,
  "content": [
    {
      "type": "image_url",
      "role": "first_frame",
      "asset_id": "YOUR_FIRST_FRAME_ASSET_ID"
    }
  ]
}'

Video Generations · First and last frames

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Slow camera push toward a paper lantern swaying gently by a lake.",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": true,
  "content": [
    {
      "type": "image_url",
      "role": "first_frame",
      "asset_id": "YOUR_FIRST_FRAME_ASSET_ID"
    },
    {
      "type": "image_url",
      "role": "last_frame",
      "asset_id": "YOUR_LAST_FRAME_ASSET_ID"
    }
  ]
}'

Video Generations · Reference video

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Match the camera motion from the reference video in a lakeside lantern scene.",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": true,
  "omni_reference_task_type": "reference",
  "content": [
    {
      "type": "video_url",
      "role": "reference_video",
      "asset_id": "YOUR_VIDEO_ASSET_ID"
    }
  ]
}'

Video Generations · Edit video

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Preserve the subject and change the setting to a lakeside at dusk.",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "generate_audio": true,
  "omni_reference_task_type": "edit",
  "content": [
    {
      "type": "video_url",
      "role": "reference_video",
      "asset_id": "YOUR_VIDEO_ASSET_ID"
    }
  ]
}'

Video Generations · Extend video

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/generations' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "model": "kling-v4",
  "prompt": "Continue the motion as the camera glides farther over the lake.",
  "resolution": "720p",
  "duration": 5,
  "generate_audio": true,
  "omni_reference_task_type": "extend",
  "content": [
    {
      "type": "video_url",
      "role": "reference_video",
      "asset_id": "YOUR_VIDEO_ASSET_ID"
    },
    {
      "type": "image_url",
      "role": "last_frame",
      "asset_id": "YOUR_LAST_FRAME_ASSET_ID"
    }
  ]
}'

Check video task

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/tasks/YOUR_TASK_ID' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY"

Download video

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/tasks/YOUR_TASK_ID/content' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -L \
  -o result.mp4

Delete a finished video task

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/tasks/YOUR_TASK_ID' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -i \
  -X DELETE

Upload an asset

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/assets' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -F 'kind=image' \
  -F '[email protected];type=image/png'

Upload an asset · Upload a video

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/assets' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -F 'kind=video' \
  -F '[email protected];type=video/mp4'

Delete an asset

bash
curl -sS 'https://api.icodeeasy.cc/v1/videos/assets/YOUR_ASSET_ID' \
  -H "Authorization: Bearer $ICODEEASY_API_KEY" \
  -i \
  -X DELETE

Responses and tasks

HTTP 202 · Task accepted

json
{
  "id": "vid_1785398400000000000",
  "object": "video.generation.job",
  "model": "kling-v4",
  "created_at": "2026-07-30T08:00:00Z",
  "status_url": "/v1/videos/tasks/vid_1785398400000000000",
  "content_url": "/v1/videos/tasks/vid_1785398400000000000/content",
  "status": "queued",
  "updated_at": "2026-07-30T08:00:00Z",
  "task_id": "vid_1785398400000000000"
}

HTTP 200 · Completed task lookup

json
{
  "id": "vid_1785398400000000000",
  "object": "video.generation.job",
  "model": "kling-v4",
  "created_at": "2026-07-30T08:00:00Z",
  "status_url": "/v1/videos/tasks/vid_1785398400000000000",
  "content_url": "/v1/videos/tasks/vid_1785398400000000000/content",
  "status": "succeeded",
  "updated_at": "2026-07-30T08:01:00Z",
  "url": "/v1/videos/tasks/vid_1785398400000000000/content"
}

Save id. With the same API key, send GET requests to status_url until status is succeeded or failed. On success, download from content_url and follow HTTP redirects. Both paths are relative to the API base URL.

FieldTypeDescription
id / task_idstringTask ID. In the creation response, task_id equals id.
statusstringTask state, one of queued, running, succeeded, or failed.
progressintegerGeneration progress. Omitted when the service has no progress value.
error.codestringError classification for failed tasks.

Common errors

HTTPError typeDescription
400invalid_requestCheck the model, parameter combination, and reference media.
401unauthorizedCheck whether the API key is missing, invalid, or disabled.
402insufficient_balanceThe balance is insufficient to submit the task.
404not_foundIf polling returns 404, keep the task ID and check the polling URL and API key for the account that created the task. It may already have finished. Do not resubmit on this basis.
409video_not_readyThe video is still being generated. Continue polling.
503submission_unknownThe submission outcome is unknown. Contact support to check whether a task was created before sending a new request.

Full integration guide · See the full API guide for request fields, task states, and response formats.

Capabilities and limits

  • text_to_video · Supported
  • image_to_video · Supported
  • first_frame · Supported
  • last_frame · Supported
  • reference_images · Supported
  • audio · Supported
  • Limits Resolutions: 720p, 1080p · Durations: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 · Aspect ratios: 16:9, 9:16, 1:1, 21:9 · Reference images: up to 8

Model Capability Catalog · View pricing