> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.deerapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling Generate With References

> Use DeerAPI to call the Kling Generate With References endpoint with request details, response details, examples, and an OpenAPI playground.

## Overview

Use this endpoint to call the Kling Generate With References workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.

## Before you start

Use the DeerAPI base URL and pass your API Key in the `Authorization` header:

```text theme={null}
https://api.deerapi.com
```

```text theme={null}
Authorization: Bearer $DEERAPI_KEY
```

## Model selection

Choose a current model ID from the [live pricing page](https://api.deerapi.com/pricing). Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.

## Implementation notes

* Use the OpenAPI playground for the exact request fields accepted by this endpoint.
* Keep API Keys on the server side when you build production applications.
* Log the request ID from failed calls so support can investigate the request.
* Retry `429`, `500`, and `503` responses with exponential backoff.


## OpenAPI

````yaml /api/openapi/image/kling/post-multi-img-gen.openapi.json POST /kling/v1/images/generations
openapi: 3.1.0
info:
  title: Multi-Image to Image API
  version: 1.0.0
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/images/generations:
    post:
      summary: Multi-Image to Image
      operationId: multi_image_to_image
      parameters:
        - name: Content-Type
          in: header
          required: false
          description: Content type of the request body.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Kling Image Generation API request body definition
              required:
                - subject_image_list
              properties:
                model_name:
                  type: string
                  description: Model to use for multi-image generation.
                  enum:
                    - kling-v2
                  default: kling-v2
                prompt:
                  type: string
                  description: >-
                    Text prompt describing the desired output. Max 2500
                    characters.
                subject_image_list:
                  type: array
                  description: List of subject reference images. Minimum 2, maximum 4.
                  items:
                    type: object
                    description: Information for a single subject image
                    required:
                      - subject_image
                    properties:
                      subject_image:
                        type: string
                        description: >-
                          Image URL or raw Base64 string (no `data:` prefix).
                          Supported formats: JPG, JPEG, PNG. Max 10 MB, minimum
                          300 px per side, aspect ratio between 1:2.5 and 2.5:1.
                  default:
                    - {}
                scence_image:
                  type: string
                  description: >-
                    Optional scene reference image. Same format and size
                    constraints as subject images.
                style_image:
                  type: string
                  description: >-
                    Optional style reference image. Same format and size
                    constraints as subject images.
                'n':
                  type: integer
                  description: Number of images to generate.
                  default: 1
                aspect_ratio:
                  type: string
                  description: Aspect ratio of the generated image (width:height).
                  enum:
                    - '16:9'
                    - '9:16'
                    - '1:1'
                    - '4:3'
                    - '3:4'
                    - '3:2'
                    - '2:3'
                    - '21:9'
                  default: '16:9'
                callback_url:
                  type: string
                  description: >-
                    Webhook URL for task status notifications. The server sends
                    a callback when the task status changes.
                external_task_id:
                  type: string
                  description: >-
                    Optional user-defined task ID for your own tracking. Does
                    not replace the system-generated task ID. Must be unique per
                    account.
              default:
                subject_image_list:
                  - {}
            examples:
              Default:
                summary: Default
                value:
                  model_name: kling-v2
                  prompt: cute cat
                  subject_image_list:
                    - subject_image: >-
                        https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                    - subject_image: >-
                        https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                    - subject_image: >-
                        https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                    - subject_image: >-
                        https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
            example:
              model_name: kling-v2
              prompt: cute cat
              subject_image_list:
                - subject_image: >-
                    https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                - subject_image: >-
                    https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                - subject_image: >-
                    https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
                - subject_image: >-
                    https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: Error code; specifically define the error code
                  message:
                    type: string
                    description: error message
                  request_id:
                    type: string
                    description: >-
                      Request ID, system-generated, for tracking requests,
                      troubleshooting issues
                  data:
                    type: object
                    required:
                      - task_id
                      - task_status
                      - created_at
                      - updated_at
                    properties:
                      task_id:
                        type: string
                        description: Task ID, system generated
                      task_status:
                        type: string
                        description: >-
                          Task status, enumerated values: submitted, processing,
                          succeed, failed.
                      created_at:
                        type: integer
                        description: Task creation time, Unix timestamp, in ms.
                      updated_at:
                        type: integer
                        description: Task update time, Unix timestamp, in ms.
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/kling/v1/images/generations \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "model_name": "kling-v2",
                "prompt": "cute cat",
                "subject_image_list": [
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  }
                ]
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/kling/v1/images/generations"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "model_name": "kling-v2",
              "prompt": "cute cat",
              "subject_image_list": [
                {
                  "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                },
                {
                  "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                },
                {
                  "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                },
                {
                  "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                }
              ]
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/kling/v1/images/generations", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "model_name": "kling-v2",
                "prompt": "cute cat",
                "subject_image_list": [
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  },
                  {
                    "subject_image": "https://filesystem.site/cdn/20250814/goDW44JIf6eSuxAS7TNringhWjO9kW.png"
                  }
                ]
              }),
            });


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use a DeerAPI API Key as a Bearer token.

````