This documentation is valid for the following list of our models:
klingai/kling-video-v1.6-pro-effects
Model Overview
A specialized video model that generates short clips based on reference images of people, applying one of several preset scenarios: two people hugging, kissing, or making a heart shape with their hands (requires 2 reference images), or a single person being humorously squished like clay or inflated like a balloon (requires 1 reference image).
Generated Video Examples
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our .
How to Make a Call
Generating a video using this model involves making two sequential API calls:
The first one is for creating and sending a video generation task to the server (returns a generation ID).
The second one is for requesting the generated or extended video from the server using the generation ID received from the first endpoint.
Below, you can find both corresponding API schemas.
API Schema
Create a video generation task and send it to the server
Retrieve the generated video from the server
After sending a request for video generation, this task is added to the queue. Based on the service's load, the generation can be completed in seconds or take a bit more.
Code Example (Python)
In this example, we'll try to make two people from different photos (provided via URLs) form a romantic heart shape with their hands. No prompt is required — the effect is selected by setting the appropriate value for the effect_scene parameter.
For effects that involve two images, the first one will always appear on the left side of the video, and the second one on the right. Therefore, to achieve the most natural-looking result, you may sometimes need to swap the image order.
Input image preview
The code below creates a video generation task, then automatically polls the server every 10 seconds until it finally receives the video URL.
import requests
import time
base_url = "https://api.aimlapi.com/v2"
api_key = "<YOUR_AIMLAPI_KEY>"
ref_img_url1 = "https://images.pexels.com/photos/733872/pexels-photo-733872.jpeg"
ref_img_url2 = "https://storage.googleapis.com/falserverless/juggernaut_examples/QEW5VrzccxGva7mPfEXjf.png"
# Creating and sending a video generation task to the server
def generate_video():
url = f"{base_url}/generate/video/kling/generation"
headers = {
"Authorization": f"Bearer {api_key}",
}
data = {
"model": "klingai/kling-video-v1.6-pro-effects",
"image_url": [ref_img_url1, ref_img_url2],
"duration": 5,
"effect_scene": "heart_gesture"
}
response = requests.post(url, json=data, headers=headers)
if response.status_code >= 400:
print(f"Error: {response.status_code} - {response.text}")
else:
response_data = response.json()
#print(response_data)
return response_data
# Requesting the result of the task from the server using the generation_id
def get_video(gen_id):
url = f"{base_url}/generate/video/kling/generation"
params = {
"generation_id": gen_id,
}
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.get(url, params=params, headers=headers)
return response.json()
def main():
# Running video generation and getting a task id
gen_response = generate_video()
gen_id = gen_response.get("id")
print("Gen_ID: ", gen_id)
# Trying to retrieve the video from the server every 10 sec
if gen_id:
start_time = time.time()
timeout = 600
while time.time() - start_time < timeout:
response_data = get_video(gen_id)
if response_data is None:
print("Error: No response from API")
break
status = response_data.get("status")
print("Status:", status)
if status == "waiting" or status == "active" or status == "queued" or status == "generating":
print("Still waiting... Checking again in 10 seconds.")
time.sleep(10)
else:
print("Processing complete:/n", response_data)
return response_data
print("Timeout reached. Stopping.")
return None
if __name__ == "__main__":
main()
Response
Gen_ID: 91bc5296-f0f9-4336-ab6a-60f993cbb971:kling-video/v1.6/pro/effects
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: generating
Still waiting... Checking again in 10 seconds.
Status: completed
Processing complete:/n {'id': '91bc5296-f0f9-4336-ab6a-60f993cbb971:kling-video/v1.6/pro/effects', 'status': 'completed', 'video': {'url': 'https://cdn.aimlapi.com/eagle/files/koala/cSlcOq_yBcuGDvbf9BjGU_output.mp4', 'content_type': 'video/mp4', 'file_name': 'output.mp4', 'file_size': 8554108}}