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

# Initialiser une session d’édition Kling

> Initialisez des éléments vidéo via le endpoint init-selection de Kling dans CometAPI pour démarrer une édition multimodale avec des régions et des horodatages sélectionnables.

Utilisez ce endpoint pour ouvrir une session d’édition vidéo et obtenir le `session_id` requis par toutes les étapes ultérieures de l’édition multimodale.

## Choisissez un chemin d’entrée

* Vidéo générée par Kling : envoyez `video_id`
* Vidéo externe ou déjà hébergée : envoyez `video_url`
* N’envoyez pas les deux chemins d’entrée en même temps
* N’envoyez pas le `task_id` parent ici ; enregistrez le `session_id` renvoyé pour les étapes suivantes

## Rôle dans le workflow

<Steps>
  <Step title="Initialiser la session">
    Soumettez le clip source et enregistrez le `session_id` renvoyé.
  </Step>

  <Step title="Marquer les points de sélection">
    Poursuivez avec [Add Video Selection](./add-video-selection) pour définir la région que vous souhaitez modifier.
  </Step>

  <Step title="Soumettre la tâche d’édition finale">
    Une fois la sélection prête, poursuivez avec [Create Task](./create-task).
  </Step>
</Steps>

<Tip>
  Pour la référence complète des paramètres, consultez la [documentation de l’API Kling](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.

````