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).
Setup your API Key
If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.
How to Make a Call
API Schemas
Create a video generation task and send it to the server
The duration of the generated video in seconds. Possible values: 5, 10
For hug, kiss, and heart_gesture effects, pass an array containing exactly two image URLs. For squish or expansion, only one image URL is required.
The effect scene to use for the video generation
POST /v2/generate/video/kling/generation HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 116
{
"model": "klingai/kling-video-v1.6-pro-effects",
"duration": 5,
"image_url": "https://example.com",
"effect_scene": "hug"
}
No content
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.
GET /v2/generate/video/kling/generation HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
No content
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.
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()
Last updated
Was this helpful?