> ## 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 للتحكم بالحركة

> أنشئ مهمة Kling للتحكم بالحركة من صورة شخصية وفيديو حركة مرجعي.

استخدم `POST /motion-control/{model}` لتحريك صورة شخصية بالحركة المستمدة من فيديو مرجعي. ينشئ الطلب مهمة غير متزامنة.

## اختيار نموذج

| معرّف النموذج | الدقة | `settings.audio` |
| - | - | - |
| `kling-3.0` | `720p`, `1080p` | `original`, `off` |
| `kling-2.6` | `720p`, `1080p` | `original`, `off` |

استخدم صورة الشخصية والفيديو المرجعي كعناوين URL متاحة للعامة. اضبط `settings.audio` على `original` للاحتفاظ بالصوت من الفيديو المرجعي، أو على `off` للحصول على إخراج صامت.

يجب أن تكون الصورة بتنسيق JPG أو PNG، وألا يتجاوز حجمها 50 MB، وألا يقل طول كل ضلع فيها عن 300 بكسل. استخدم فيديو مرجعيًا بتنسيق MP4 أو MOV لا تقل مدته عن 3 ثوانٍ ولا يتجاوز حجمه 100 MB. باستخدام `character_orientation: image`، يمكن أن تصل مدة الفيديو إلى 10 ثوانٍ؛ وباستخدام `video`، يمكن أن تصل إلى 30 ثانية.

## معلمات الطلب

| الحقل | مطلوب | الوصف |
| - | - | - |
| المسار `model` | نعم | معرّف النموذج في عنوان URL: `kling-3.0` أو `kling-2.6`. لا تضفه إلى نص الطلب. |
| `contents` | نعم | مصفوفة تحتوي على عنصر `image` واحد وعنصر `video` واحد. أضف عنصر `prompt` لوصف المشهد. |
| `contents[].type` | نعم | `image` للشخصية، و`video` لمرجع الحركة، أو `prompt` للإرشاد النصي. |
| `contents[].url` | لعناصر الصور والفيديو | عنوان URL عام لصورة الشخصية أو فيديو الحركة المرجعي. |
| `contents[].text` | لعنصر `prompt` | إرشاد نصي مطلوب للمشهد الذي تم إنشاؤه. |
| `settings.resolution` | لا | دقة الإخراج: `720p` أو `1080p`. إذا تم حذفه، يستخدم الطلب `720p`. |
| `settings.character_orientation` | نعم | `image` يستخدم اتجاه الشخصية من الصورة؛ ويستخدم `video` الفيديو المرجعي. |
| `settings.audio` | لا | اضبط `original` للاحتفاظ بالصوت المرجعي أو `off` لتعطيله. اضبط القيمة صراحةً. |
| `options.callback_url` | لا | عنوان URL ببروتوكول HTTPS يتلقى عمليات رد الاتصال بحالة المهمة. |
| `options.external_task_id` | لا | معرّف المهمة الخاص بك للربط؛ احتفظ بالقيمة `data.id` المُعادة لإجراء الاستعلامات. |
| `options.watermark_info.enabled` | لا | اضبطه على `true` لطلب علامة مائية. |

لتحريك صورة شخصية، أرسل نص الطلب هذا إلى `POST /motion-control/kling-2.6`. استبدل عناوين URL للوسائط بملفاتك المتاحة عند استخدام شخصيتك وحركتك الخاصتين:

```json theme={null}
{
  "contents": [
    {
      "type": "prompt",
      "text": "The character performs the dance shown in the reference video."
    },
    {
      "type": "image",
      "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
    },
    {
      "type": "video",
      "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
    }
  ],
  "settings": {
    "resolution": "720p",
    "character_orientation": "video",
    "audio": "off"
  }
}
```

يعيد الرد قيمة `id` للمهمة غير المتزامنة:

```json theme={null}
{
  "code": 0,
  "message": "SUCCEED",
  "data": {
    "id": "example-task-id",
    "status": "submitted"
  }
}
```

استخدم قيمة `data.id` مع [الحصول على مهمة Kling](https://apidoc.cometapi.com/ar/api/video/kling/model-routes/tasks.md) حتى تكتمل المهمة. اقرأ عنوان URL للفيديو المكتمل من مصفوفة `outputs` الخاصة بالمهمة. خزّن الفيديو في مساحة التخزين الخاصة بك إذا كنت تحتاج إلى وصول دائم.

تحتوي لوحة OpenAPI على طلبات مطابقة لـ Shell وPython وJavaScript. لمزيد من تفاصيل الإدخال، راجع [مرجع API للتحكم بالحركة في Kling](https://kling.ai/document-api/api/video/3-0-omni/motion-control).


## OpenAPI

````yaml api/openapi/video/kling/model-routes/post-motion-control.openapi.json POST /motion-control/{model}
openapi: 3.1.0
info:
  title: Kling motion-control model routes
  version: 1.0.0
  description: Create a Kling motion-control video task with a model ID in the URL.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /motion-control/{model}:
    post:
      summary: Create a Kling motion-control task
      description: >-
        Animate a character image with movement from a reference video. Save the
        returned task ID for status queries.
      operationId: createKlingModelRouteMotionControl
      parameters:
        - name: model
          in: path
          required: true
          description: Kling motion-control model ID.
          schema:
            type: string
            enum:
              - kling-3.0
              - kling-2.6
          example: kling-2.6
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MotionControlRequest'
            example:
              contents:
                - type: prompt
                  text: >-
                    The character performs the dance shown in the reference
                    video.
                - type: image
                  url: >-
                    https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png
                - type: video
                  url: >-
                    https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4
              settings:
                resolution: 720p
                character_orientation: video
                audio: 'off'
      responses:
        '200':
          description: Task created. Store `data.id` for a `GET /tasks` query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
              example:
                code: 0
                message: SUCCEED
                data:
                  id: example-task-id
                  status: submitted
      x-codeSamples:
        - lang: Shell
          label: Create task
          source: |
            curl https://api.cometapi.com/motion-control/kling-2.6 \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              --data-binary @- <<'JSON'
            {
              "contents": [
                {
                  "type": "prompt",
                  "text": "The character performs the dance shown in the reference video."
                },
                {
                  "type": "image",
                  "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
                },
                {
                  "type": "video",
                  "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
                }
              ],
              "settings": {
                "resolution": "720p",
                "character_orientation": "video",
                "audio": "off"
              }
            }
            JSON
        - lang: Python
          label: Create task
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/motion-control/kling-2.6",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "contents": [
                        {
                            "type": "prompt",
                            "text": "The character performs the dance shown in the reference video.",
                        },
                        {
                            "type": "image",
                            "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png",
                        },
                        {
                            "type": "video",
                            "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4",
                        },
                    ],
                    "settings": {
                        "resolution": "720p",
                        "character_orientation": "video",
                        "audio": "off",
                    },
                },
            )
            response.raise_for_status()
            result = response.json()
            print(result["data"]["id"])
        - lang: JavaScript
          label: Create task
          source: |
            const response = await fetch(
              "https://api.cometapi.com/motion-control/kling-2.6",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  "contents": [
                    {
                      "type": "prompt",
                      "text": "The character performs the dance shown in the reference video."
                    },
                    {
                      "type": "image",
                      "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
                    },
                    {
                      "type": "video",
                      "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
                    }
                  ],
                  "settings": {
                    "resolution": "720p",
                    "character_orientation": "video",
                    "audio": "off"
                  }
                }),
              },
            );
            if (!response.ok) throw new Error(`HTTP ${response.status}`);
            const result = await response.json();
            console.log(result.data.id);
components:
  schemas:
    MotionControlRequest:
      type: object
      required:
        - contents
        - settings
      properties:
        contents:
          type: array
          minItems: 2
          description: >-
            Send a character image and motion reference video. Add a prompt item
            for scene guidance.
          items:
            $ref: '#/components/schemas/ContentItem'
          allOf:
            - contains:
                type: object
                required:
                  - type
                properties:
                  type:
                    const: image
                    description: Character image input role.
              minContains: 1
              maxContains: 1
            - contains:
                type: object
                required:
                  - type
                properties:
                  type:
                    const: video
                    description: Motion reference video input role.
              minContains: 1
              maxContains: 1
        settings:
          $ref: '#/components/schemas/MotionControlSettings'
        options:
          $ref: '#/components/schemas/TaskOptions'
      additionalProperties: false
      description: >-
        Motion-control request fields exposed by the CometAPI route. The model
        ID is a path parameter, not a body field.
    SubmitResponse:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          type:
            - integer
            - string
          description: Result code. `0` indicates task creation.
        message:
          type: string
          description: Result message.
        msg:
          type: string
          description: Additional result message, when included.
        data:
          type: object
          description: Task identification and submission status.
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: System task ID for a `GET /tasks` query.
            status:
              type: string
              enum:
                - submitted
                - processing
                - succeeded
                - failed
              description: Task status.
    ContentItem:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - prompt
            - image
            - video
          description: >-
            Input role: text guidance, character appearance image, or motion
            reference video.
        text:
          type: string
          maxLength: 2500
          description: Text prompt, required when `type` is `prompt`.
        url:
          type: string
          description: >-
            Required for image and video items. The image accepts a public URL
            or Base64 JPG/PNG; the motion video accepts a public MP4/MOV URL.
      allOf:
        - if:
            properties:
              type:
                const: prompt
                description: Text-prompt input role.
          then:
            required:
              - text
          else:
            required:
              - url
      additionalProperties: false
      description: Content input fields exposed by the CometAPI route.
    MotionControlSettings:
      type: object
      required:
        - character_orientation
      description: >-
        Output resolution, reference orientation, and explicitly selected audio
        behavior.
      properties:
        character_orientation:
          type: string
          enum:
            - image
            - video
          description: >-
            `image` follows the character orientation in the image and allows a
            reference video up to 10 seconds. `video` follows the reference
            video and allows up to 30 seconds.
        resolution:
          type: string
          enum:
            - 720p
            - 1080p
          default: 720p
          description: Output resolution.
        audio:
          type: string
          enum:
            - original
            - 'off'
          description: >-
            Set `original` to retain the reference video's audio or `off` to
            make a silent output. Set the value explicitly.
      additionalProperties: false
    TaskOptions:
      type: object
      description: Optional task fields exposed by the CometAPI route.
      properties:
        callback_url:
          type: string
          format: uri
          description: HTTPS URL that receives task status callbacks.
        external_task_id:
          type: string
          description: >-
            Your own task identifier, unique within your account. The response
            still returns the system task ID.
        watermark_info:
          type: object
          description: Watermark setting for the generated output.
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              description: Set to `true` to request a watermarked result.
          additionalProperties: false
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Authenticate with your CometAPI API key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.