# v1.6-pro/effects

{% columns %}
{% column width="66.66666666666666%" %}
{% hint style="info" %}
This documentation is valid for the following list of our models:

* `klingai/kling-video-v1.6-pro-effects`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/klingai/kling-video-v1.6-pro-effects" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

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).

<details>

<summary>Generated Video Examples (low-res GIF previews)</summary>

<table data-header-hidden><thead><tr><th width="165"></th><th width="149"></th><th></th></tr></thead><tbody><tr><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-128b85fb5ed2cd7afefc773d3d9a81580be0f1e2%2Fphoto1.jpeg?alt=media" alt="Photo #1" data-size="original"></td><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-934061f81fb0e5e67c39262f93712d6912979cbb%2Fphoto2.png?alt=media" alt="Photo #2" data-size="original"></td><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-212515ccd873b82715bcd6bf290f8cb36d614d4f%2Fkling-effects-heart-320.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;heart_gesture&#x22;" data-size="original"></td></tr></tbody></table>

| <img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-63e4541c62ab1053deba3f069692e28553feed8a%2Fkling-effects-hug-320.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;hug&#x22;" data-size="original">       | <img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-01656d31885d3b1b56215ece846c96d01da90979%2Fkling-effects-kiss-320.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;kiss&#x22;" data-size="original">           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-9af9b97b6a3ab5b6eb7b28515c748c91270416f1%2Fkling-effects-squish-320.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;squish&#x22;" data-size="original"> | <img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-f8c8cd3b30239f89caf070e7b27f2d4505c5920f%2Fkling-effects-expansion-320.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;expansion&#x22;" data-size="original"> |

Theoretically, you can get acceptable results for the `squish` and `expansion` effects even when using photos of animals, inanimate objects, or even landscapes. The output can be unusual, but the video will be generated.

<table data-header-hidden><thead><tr><th width="338.13336181640625"></th><th></th></tr></thead><tbody><tr><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-ecdbfd822a2425c3e238fe6221b08c3f569fbe04%2Fkling-standard-squish-320-tiger.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;squish&#x22;" data-size="original"></td><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-d1597a5bfabb3dc7bb5799fccfdbfe49a95eb88c%2Fkling-standard-squish-320-forest.gif?alt=media" alt="&#x22;effect_scene&#x22;: &#x22;squish&#x22;" data-size="original"></td></tr></tbody></table>

However, if you try to use such photos with the `hug`, `kiss`, or `heart_gesture effects`, you’ll receive an error saying `“Could not detect face in the image”` .

{% code overflow="wrap" %}

```json5
Processing complete:\n {'id': '50f3e8ae-3d88-482f-95ea-7faa4799f60f:kling-video/v1.6/pro/effects', 'status': 'error', 'error': {'detail': [{'loc': ['body', 'image_url'], 'msg': 'Could not detect face in the image', 'type': 'face_detection_error', 'input': 'https://rgo.ru/upload/s34web.imageadapter/668e00e0ed33855a9c79de12d2f88206/2131465.jpg'}]}}
```

{% endcode %}

</details>

## 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](https://docs.aimlapi.com/api-references/video-models/kling-ai/broken-reference).

## How to Make a Call

<details>

<summary>Step-by-Step Instructions</summary>

Generating a video using this model involves sequentially calling two endpoints:

* 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 video from the server using the generation ID received from the first endpoint.

Below, you can find both corresponding API schemas.

</details>

## API Schemas

{% hint style="success" %}
Now, all of our API schemas for video models use our new universal short URL — `https://api.aimlapi.com/v2/video/generations`.\
However, you can still call this model using the legacy URL that includes the vendor name.
{% endhint %}

### Create a video generation task and send it to the server

## POST /v2/video/generations

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/video/generations":{"post":{"operationId":"_v2_video_generations","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","enum":["klingai/kling-video-v1.6-pro-effects"]},"image_url":{"anyOf":[{"type":"string","format":"uri"},{"type":"array","items":{"type":"string","format":"uri"}}],"description":"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."},"effect_scene":{"type":"string","enum":["magic_fireball","pet_moto_rider","media_interview","pet_lion","pet_delivery","pet_chef","santa_gifts","santa_hug","girlfriend","boyfriend","heart_gesture_1","pet_wizard","smoke_smoke","thumbs_up","instant_kid","dollar_rain","cry_cry","building_collapse","gun_shot","mushroom","double_gun","pet_warrior","lightning_power","jesus_hug","shark_alert","long_hair","lie_flat","polar_bear_hug","brown_bear_hug","jazz_jazz","office_escape_plow","fly_fly","watermelon_bomb","pet_dance","boss_coming","wool_curly","iron_warrior","pet_bee","marry_me","swing_swing","day_to_night","piggy_morph","wig_out","car_explosion","ski_ski","tiger_hug","siblings","construction_worker","let's_ride","snatched","magic_broom","felt_felt","jumpdrop","celebration","splashsplash","hula","surfsurf","fairy_wing","angel_wing","dark_wing","skateskate","plushcut","jelly_press","jelly_slice","jelly_squish","jelly_jiggle","pixelpixel","yearbook","instant_film","anime_figure","rocketrocket","bloombloom","dizzydizzy","fuzzyfuzzy","squish","expansion","hug","kiss","heart_gesture","fight"],"description":"Video effect scene type"},"duration":{"type":"integer","description":"The length of the output video in seconds.","enum":[5,10],"default":"5"}},"required":["model","image_url","effect_scene"],"title":"klingai/kling-video-v1.6-pro-effects"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"The ID of the generated video."},"status":{"type":"string","enum":["queued","generating","completed","error"],"description":"The current status of the generation task."},"video":{"type":"object","nullable":true,"properties":{"url":{"type":"string","format":"uri","description":"The URL where the file can be downloaded from."}},"required":["url"]},"error":{"type":"object","nullable":true,"properties":{"name":{"type":"string"},"message":{"type":"string"}},"required":["name","message"],"description":"Description of the error, if any."},"meta":{"type":"object","nullable":true,"properties":{"usage":{"type":"object","nullable":true,"properties":{"credits_used":{"type":"number","description":"The number of tokens consumed during generation."}},"required":["credits_used"]}},"description":"Additional details about the generation."}},"required":["id","status"]}}}}}}}}}
```

### Retrieve the generated video from the server

After sending a request for video generation, this task is added to the queue. This endpoint lets you check the status of a video generation task using its `id`, obtained from the endpoint described above.\
If the video generation task status is `completed`, the response will include the final result — with the generated video URL and additional metadata.

## GET /v2/video/generations

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"<YOUR_AIMLAPI_KEY>","type":"http","description":"Bearer key","in":"header"}}},"paths":{"/v2/video/generations":{"get":{"operationId":"_v2_video_generations","parameters":[{"name":"generation_id","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"The ID of the generated video."},"status":{"type":"string","enum":["queued","generating","completed","error"],"description":"The current status of the generation task."},"video":{"type":"object","nullable":true,"properties":{"url":{"type":"string","format":"uri","description":"The URL where the file can be downloaded from."}},"required":["url"]},"error":{"type":"object","nullable":true,"properties":{"name":{"type":"string"},"message":{"type":"string"}},"required":["name","message"],"description":"Description of the error, if any."},"meta":{"type":"object","nullable":true,"properties":{"usage":{"type":"object","nullable":true,"properties":{"credits_used":{"type":"number","description":"The number of tokens consumed during generation."}},"required":["credits_used"]}},"description":"Additional details about the generation."}},"required":["id","status"]}}}}}}}}}
```

## Code Example

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.

{% hint style="info" %}
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.
{% endhint %}

{% hint style="info" %}
In videos featuring a single person (the `squish` and `expansion` effects), an audio track is also generated — a mix of music and material interaction sounds, such as rubber squeaks and similar effects.
{% endhint %}

<details>

<summary>Input image preview</summary>

<table><thead><tr><th width="362"></th><th></th></tr></thead><tbody><tr><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-128b85fb5ed2cd7afefc773d3d9a81580be0f1e2%2Fphoto1.jpeg?alt=media" alt="Photo #1" data-size="original"></td><td><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-934061f81fb0e5e67c39262f93712d6912979cbb%2Fphoto2.png?alt=media" alt="Photo #2" data-size="original"></td></tr></tbody></table>

</details>

The code below creates a video generation task, then automatically polls the server every **10** seconds until it finally receives the video URL.

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
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()
        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("Generation ID:  ", gen_id)

    # Trying to retrieve the video from the server every 15 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")
            
            if status in ["queued", "generating"]:
                print(f"Status: {status}. Checking again in 15 seconds.")
                time.sleep(15)
            else:
                print("Processing complete:\n", response_data)
                return response_data
   
        print("Timeout reached. Stopping.")
        return None

if __name__ == "__main__":
    main()
```

{% endcode %}
{% endtab %}
{% endtabs %}

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
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}}
```

{% endcode %}

</details>

<details>

<summary>Generated Video (GIF Preview)</summary>

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-58298dd25e3f2899b058d044eabd0b3bf968c67a%2Fkling-effects-heart.gif?alt=media" alt=""><figcaption></figcaption></figure>

</details>
