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

# Kling 멀티모달 편집 작업 생성

> CometAPI를 통해 Kling 멀티모달 비디오 편집 작업을 생성합니다: `POST /kling/v1/videos/multi-elements`를 사용해 여러 요소를 결합하고 비동기로 비디오를 생성합니다.

세션과 선택 항목 준비가 완료된 후, 이 엔드포인트를 사용해 최종 멀티모달 비디오 편집 작업을 제출합니다.

## 전체 워크플로

<Steps>
  <Step title="편집 세션 초기화">
    [편집용 비디오 초기화](./initialize-video-for-editing)를 먼저 수행하여 편집하려는 클립의 `session_id`를 획득하세요.
  </Step>

  <Step title="선택 영역 구성">
    [비디오 선택 추가](./add-video-selection)와 필요 시 [선택한 비디오 영역 미리보기](./preview-selected-video-area)를 사용해 편집 영역을 세부 조정하세요.
  </Step>

  <Step title="최종 작업 제출">
    이 엔드포인트를 통해 `session_id`, `edit_mode`, 최종 `prompt`, 그리고 필요한 선택적 생성 설정을 전송한 다음, 반환된 task id를 상태 확인용으로 저장하세요.
  </Step>
</Steps>

## 호출 전에 확인할 사항

* 선택 세션이 이미 초기화되어 있는지 확인하세요
* 생성 호출 비용이 발생하기 전에 영역 선택이 올바른지 확인하세요
* 선택 관련 후속 호출은 반드시 동일한 계정과 초기화 시 반환된 정확한 `session_id`로 실행하세요
* `edit_mode`를 `addition`, `swap`, 또는 `removal`로 설정하세요
* `addition`과 `swap`에는 `image_list`를 제공하고, `removal`에는 `image_list`를 생략하세요
* `duration`은 `"5"` 또는 `"10"`과 같은 문자열로 전송하세요. 예제에서는 `"5"`를 명시적으로 전달합니다
* 이 경로는 설정 단계가 아니라 최종 생성 단계로 취급하세요
* 편집 워크플로에 필요한 경우에만 `image_list`, `negative_prompt`, `mode`, `duration`, `callback_url`, 또는 `external_task_id`를 추가하세요

<Tip>
  전체 파라미터 참조는 [Kling API 문서](https://kling.ai/document-api/apiReference/model/multiElements)를 확인하세요.
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/multimodal-video-editing/post-create-task.openapi.json POST /kling/v1/videos/multi-elements
openapi: 3.1.0
info:
  title: Create Task API
  version: 1.0.0
  description: >-
    Submit the final Kling multimodal video-editing job after the selection
    session is ready.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/multi-elements:
    post:
      summary: Create a Kling multimodal edit task
      description: >-
        Send the `session_id`, `edit_mode`, and final edit prompt after the
        selection area has already been prepared.
      operationId: create_task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - session_id
                - edit_mode
                - prompt
              allOf:
                - if:
                    properties:
                      edit_mode:
                        const: addition
                    required:
                      - edit_mode
                  then:
                    required:
                      - image_list
                - if:
                    properties:
                      edit_mode:
                        const: swap
                    required:
                      - edit_mode
                  then:
                    required:
                      - image_list
              properties:
                session_id:
                  type: string
                  description: >-
                    Selection session id returned by init-selection. Follow-up
                    calls must use the same account and exact session id.
                edit_mode:
                  type: string
                  description: >-
                    Editing operation for the selected video region. Use
                    `addition` to add an element, `swap` to replace a selected
                    element, or `removal` to remove it.
                  enum:
                    - addition
                    - swap
                    - removal
                prompt:
                  type: string
                  description: >-
                    Instruction describing the desired edit. Reference the
                    source video as `<<<video_1>>>` and any reference image as
                    `<<<image_1>>>`.
                model_name:
                  type: string
                  description: >-
                    Kling model variant for the final edit task. Omit to use
                    `kling-v1-6`.
                  enum:
                    - kling-v1-6
                  default: kling-v1-6
                image_list:
                  type: array
                  description: >-
                    Image references used by `addition` and `swap` tasks. Omit
                    this field for `removal` tasks.
                  minItems: 1
                  items:
                    type: object
                    required:
                      - image
                    properties:
                      image:
                        type: string
                negative_prompt:
                  type: string
                  description: Elements to avoid in the edited result.
                mode:
                  type: string
                  description: Generation mode. Use `std` or `pro`.
                  enum:
                    - std
                    - pro
                duration:
                  type: string
                  description: Requested output duration in seconds.
                callback_url:
                  type: string
                  description: Webhook URL to receive task status updates.
                external_task_id:
                  type: string
                  description: >-
                    Custom task id for your own tracking. Must be unique per
                    account.
              default:
                session_id: <session_id>
                edit_mode: removal
                prompt: Delete the selected object from <<<video_1>>>
                mode: std
                duration: '5'
            examples:
              Default:
                summary: Multi-elements edit task
                value:
                  session_id: <session_id>
                  edit_mode: removal
                  prompt: Delete the selected object from <<<video_1>>>
                  mode: std
                  duration: '5'
              Addition:
                summary: Add an image element to the selected area
                value:
                  session_id: <session_id>
                  edit_mode: addition
                  image_list:
                    - image: https://your-image-host/object-to-add.jpg
                  prompt: >-
                    Add <<<image_1>>> naturally into <<<video_1>>> at the
                    selected area
                  mode: std
                  duration: '5'
              Swap:
                summary: Swap the selected element with an image reference
                value:
                  session_id: <session_id>
                  edit_mode: swap
                  image_list:
                    - image: https://your-image-host/new-object.jpg
                  prompt: >-
                    Use <<<image_1>>> to replace the selected object in
                    <<<video_1>>>
                  mode: std
                  duration: '5'
      responses:
        '200':
          description: Task accepted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - data
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      task_id:
                        type: string
                      task_status:
                        type: string
                      created_at:
                        type: integer
                      updated_at:
                        type: integer
                    additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/kling/v1/videos/multi-elements \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "session_id": "<session_id>",
                  "edit_mode": "removal",
                  "prompt": "Delete the selected object from <<<video_1>>>",
                  "mode": "std",
                  "duration": "5"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/multi-elements",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "session_id": "<session_id>",
                  "edit_mode": "removal",
                  "prompt": "Delete the selected object from <<<video_1>>>",
                  "mode": "std",
                  "duration": "5"
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data", {}).get("task_id"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/multi-elements", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "session_id": "<session_id>",
                "edit_mode": "removal",
                "prompt": "Delete the selected object from <<<video_1>>>",
                "mode": "std",
                "duration": "5"
              }),
            });


            const result = await response.json();

            console.log(result.code, result.data?.task_id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````