Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Kling 4.0 Image to Video

Model id: kling-video/v4/image-to-video. Kling 4.0 image-to-video animates a first frame, optionally toward a last frame, into 3-30 second videos at 720p or 1080p.

This documentation is valid for the following list of our models:

  • kling-video/v4/image-to-video

Model Overview

Kling 4.0 image-to-video animates a first frame, optionally toward a last frame, into 3-30 second videos at 720p or 1080p.

Setup your API Key

If you don't have an API key yet, use our Quickstart guide.

How to Make a Call

Step-by-Step Instructions

Generating a video involves sequentially calling two endpoints:

  • Create and submit a video generation task. The response contains a generation ID.

  • Poll the retrieval endpoint with that generation ID until the status is completed.

API Schemas

Create a video generation task and send it to the server

post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 2500Optional

Text prompt for video generation. Mutually exclusive with multi_prompt.

image_urlstring · uriRequired

First frame of the video: a URL or a Base64 data URI. Max 30MB, at least 300px per side, aspect ratio 0.4-2.5. The output aspect ratio follows the input frames.

tail_image_urlstring · uriOptional

Last frame of the video (optional), with the same limits as image_url.

durationintegerOptional

Video duration in seconds (3-30). With multi_prompt the video length is the sum of the shot durations instead.

Default: 5
resolutionstring · enumOptional

The resolution of the output video, where the number refers to the short side in pixels.

Default: 1080pPossible values:
Responses
200

Successful response.

application/json
idstringRequired

The ID of the generated video.

Example: 60ac7c34-3224-4b14-8e7d-0aa0db708325
statusstring · enumRequired

The current status of the generation task.

Example: completedPossible values:
videoany ofOptional
or
or
any · nullableOptional
post/v2/video/generations
curl --request POST \
  --url 'https://api.aimlapi.com/v2/video/generations' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{"model": "kling-video/v4/image-to-video", "prompt": "Describe what you want the model to generate.", "image_url": "https://example.com/input.jpg", "duration": 5}'
200

Successful response.

{
  "id": "60ac7c34-3224-4b14-8e7d-0aa0db708325",
  "status": "completed",
  "video": {
    "url": "https://cdn.aimlapi.com/generations/hedgehog/1759866285599-0cdfb138-c03a-49d4-a601-4f6413e27b15.mp4"
  },
  "error": {
    "name": "text",
    "message": "text"
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}

Retrieve the generated video from the server

Poll this endpoint with the generation_id returned by the submit request. When the status is completed, the response includes the generated video URL.

get
Authorizations
AuthorizationstringRequired

Bearer key

Query parameters
generation_idstringRequiredExample: <REPLACE_WITH_YOUR_GENERATION_ID>
Responses
200Success
application/json
idstringRequired

The ID of the generated video.

Example: 60ac7c34-3224-4b14-8e7d-0aa0db708325
statusstring · enumRequired

The current status of the generation task.

Example: completedPossible values:
get/v2/video/generations
curl -L \
  --request GET \
  --url 'https://api.aimlapi.com/v2/video/generations?generation_id=<REPLACE_WITH_YOUR_GENERATION_ID>' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>'
200Success
{
  "id": "60ac7c34-3224-4b14-8e7d-0aa0db708325",
  "status": "completed",
  "video": {
    "url": "https://cdn.aimlapi.com/generations/hedgehog/1759866285599-0cdfb138-c03a-49d4-a601-4f6413e27b15.mp4"
  },
  "error": {
    "name": "text",
    "message": "text"
  },
  "meta": {
    "usage": {
      "credits_used": 120000
    }
  }
}

Code Example

The examples submit a generation task and poll every 15 seconds until the final result is available.

Response

Last updated

Was this helpful?