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

# Initialize a Kling editing session

> Initialize video elements via Kling init-selection endpoint in CometAPI to start multimodal editing with selectable regions and timestamps.

Use this endpoint to open a video-editing session and obtain the `session_id` required by all later multimodal editing steps.

## Choose one input path

* Kling-generated video: send `video_id`
* External or already-hosted video: send `video_url`
* Do not send both input paths at the same time
* Do not send the parent `task_id` here; save the returned `session_id` for the next steps

## Workflow role

<Steps>
  <Step title="Initialize the session">
    Submit the source clip and save the returned `session_id`.
  </Step>

  <Step title="Mark selection points">
    Continue with [Add Video Selection](./add-video-selection) to define the region you want to edit.
  </Step>

  <Step title="Submit the final edit task">
    After selection is ready, continue with [Create Task](./create-task).
  </Step>
</Steps>

<Tip>
  For the complete parameter reference, see the [Kling API documentation](https://kling.ai/document-api/apiReference/model/multiElements).
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/multimodal-video-editing/post-initialize-video-for-editing.openapi.json POST /kling/v1/videos/multi-elements/init-selection
openapi: 3.1.0
info:
  title: Initialize Video for Editing API
  version: 1.0.0
  description: >-
    Open a Kling multimodal editing session from either a Kling-generated video
    or an external video URL.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/multi-elements/init-selection:
    post:
      summary: Initialize a Kling multimodal editing session
      description: >-
        Send exactly one source: either `video_id` from a completed Kling video
        task, or `video_url` for an already-hosted video. The response opens the
        session used by later selection-editing calls.
      operationId: initialize_video_for_editing
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              oneOf:
                - required:
                    - video_id
                - required:
                    - video_url
              properties:
                video_id:
                  type: string
                  description: >-
                    Kling video id from a completed task. Send exactly one of
                    video_id or video_url.
                video_url:
                  type: string
                  description: >-
                    Public MP4 or MOV URL. Send exactly one of video_id or
                    video_url.
              default:
                video_id: <video_id>
            examples:
              From video_id:
                summary: Initialize from a Kling video id
                value:
                  video_id: <video_id>
              From video_url:
                summary: Initialize from a video URL
                value:
                  video_url: https://your-video-host/source.mp4
      responses:
        '200':
          description: Session initialized.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - data
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      session_id:
                        type: string
                    additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: Default
          source: >
            curl
            https://api.cometapi.com/kling/v1/videos/multi-elements/init-selection
            \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "video_id": "<video_id>"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/multi-elements/init-selection",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "video_id": "<video_id>"
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data", {}).get("session_id"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/multi-elements/init-selection",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "video_id": "<video_id>"
              }),
            });


            const result = await response.json();

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

````