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

# Modele göre Kling metinden videoya görevi oluşturma

> Modele özgü bir rota kullanarak metin Prompt'undan Kling videosu oluşturun, ardından görev kimliğiyle videoyu alın.

Video görevi oluşturmak için `POST /text-to-video/{model}` adresine bir Prompt gönderin. Yanıt, sonucu almak için kullanacağınız bir `id` içerir.

## Model seçme

Model kimliğini URL'ye ekleyin. JSON gövdesine model alanı eklemeyin.

| Model kimliği | Çözünürlük | Süre | Ses |
| - | - | - | - |
| `kling-4.0` | `720p`, `1080p` | 3 ile 30 saniye arasında bir tam sayı | Belirtmeyin `audio` |
| `kling-3.0-turbo` | `720p`, `1080p` | 3 ile 15 saniye arasında bir tam sayı | Belirtmeyin `audio` |
| `kling-3.0` | `720p`, `1080p`, `4k` | 3 ile 15 saniye arasında bir tam sayı | `native` veya `off` |
| `kling-2.6` | `720p`, `1080p` | 5 veya 10 saniye | `native` veya `off`; `1080p` değerini şu değerle kullanın: `native` |
| `kling-2.5-turbo` | `720p`, `1080p` | 5 veya 10 saniye | Belirtmeyin `audio` |

## İstek parametreleri

| Alan | Tür | Zorunlu | Açıklama |
| - | - | - | - |
| Yol `model` | string | Evet | URL'deki model kimliği. Yukarıdaki tablodan bir kimlik seçin; bunu istek gövdesine eklemeyin. |
| `prompt` | string | Evet | Oluşturulacak videonun açıklaması. |
| `settings.resolution` | string | Hayır | Yukarıda seçilen modelin satırında belirtilen çıktı çözünürlüğü. Varsayılan değer: `720p`. |
| `settings.aspect_ratio` | string | Hayır | Çıktı kare oranı: `21:9` (yalnızca `kling-4.0`), `16:9`, `9:16` veya `1:1`. Varsayılan değer: `16:9`. |
| `settings.duration` | integer | Hayır | Yukarıda seçilen modelin satırında belirtilen, saniye cinsinden video uzunluğu. Varsayılan değer `10` olup `kling-4.0` için geçerlidir; diğer modeller için varsayılan değer `5` şeklindedir. Bir string değil, tam sayı gönderin. |
| `settings.multi_shot` | boolean | Hayır | Yalnızca `kling-3.0` için resmi varsayılan değer `true` şeklindedir. Birden fazla çekim için `true`, tek çekim için `false` değerini ayarlayın ve bu alanı kullanırken değeri açıkça belirtin. |
| `settings.audio` | string | Hayır | `kling-3.0` veya `kling-2.6` için ses oluşturulmasını istiyorsanız `native`, ses oluşturulmamasını istiyorsanız `off` değerini ayarlayın. Bu alanı kullanırken değeri açıkça belirtin. |
| `options.callback_url` | string | Hayır | Görev güncellemelerini alan herkese açık URL. |
| `options.external_task_id` | string | Hayır | Görevi uygulamanızla eşleştirmek için kullandığınız kimlik. |
| `options.watermark_info` | object | Hayır | Çıktı için filigran yapılandırması. |

`kling-4.0` için `settings.audio` anahtarı sunulmaz. Videoları bir ses parçası içerir; modelin yok sayacağı bir değer göndermek yerine alanı belirtmeyin.

Aşağıdaki istek, `kling-3.0-turbo` ile beş saniyelik bir video oluşturur:

```json theme={null}
{
  "prompt": "A paper boat drifts across a calm pond at sunrise.",
  "settings": {
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "duration": 5
  }
}
```

Bu gövdeyi CometAPI API anahtarınızla `https://api.cometapi.com/text-to-video/kling-3.0-turbo` adresine gönderin. OpenAPI kod panelinde aynı gövdeyi kullanan Shell, Python ve JavaScript istekleri bulunur.

## Videoyu alma

Oluşturma yanıtı şu yapıdadır:

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

`data.id` değerini kaydedin. Bu kimlikle [Kling görevi alma](https://apidoc.cometapi.com/tr/api/video/kling/model-routes/tasks.md) işlemini görev son duruma ulaşana kadar kullanın. Video URL'sini görevin `outputs` dizisinden alın.


## OpenAPI

````yaml api/openapi/video/kling/model-routes/post-text-to-video.openapi.json POST /text-to-video/{model}
openapi: 3.1.0
info:
  title: Kling text-to-video model route
  version: 1.0.0
  description: Create a Kling video task from a text prompt.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /text-to-video/{model}:
    post:
      summary: Create a text-to-video task
      description: >-
        Submit a prompt and receive a task ID for retrieving the generated
        video.
      operationId: createKlingModelTextToVideoTask
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Kling model ID. `kling-4.0` accepts 3-30 second durations and the
            `21:9` ratio. `kling-3.0` supports 4k resolution. The 2.x models
            accept 5- or 10-second duration.
          schema:
            type: string
            enum:
              - kling-4.0
              - kling-3.0-turbo
              - kling-3.0
              - kling-2.6
              - kling-2.5-turbo
            default: kling-3.0-turbo
          example: kling-3.0-turbo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToVideoRequest'
            example:
              prompt: A paper boat drifts across a calm pond at sunrise.
              settings:
                resolution: 720p
                aspect_ratio: '16:9'
                duration: 5
      responses:
        '200':
          description: >-
            The task was created. Use `data.id` to retrieve its status and video
            output.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateTaskResponse'
              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/text-to-video/kling-3.0-turbo \
              -X POST \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              --data-raw '{
              "prompt": "A paper boat drifts across a calm pond at sunrise.",
              "settings": {
                "resolution": "720p",
                "aspect_ratio": "16:9",
                "duration": 5
              }
            }'
        - lang: Python
          label: Create task
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/text-to-video/kling-3.0-turbo",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "prompt": "A paper boat drifts across a calm pond at sunrise.",
                    "settings": {
                        "resolution": "720p",
                        "aspect_ratio": "16:9",
                        "duration": 5
                    },
                },
            )
            response.raise_for_status()
            print(response.json()["data"]["id"])
        - lang: JavaScript
          label: Create task
          source: |
            const response = await fetch(
              "https://api.cometapi.com/text-to-video/kling-3.0-turbo",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  prompt: "A paper boat drifts across a calm pond at sunrise.",
                  settings: {
                    resolution: "720p",
                    aspect_ratio: "16:9",
                    duration: 5,
                  },
                }),
              },
            );
            if (!response.ok) throw new Error(`HTTP ${response.status}`);
            console.log((await response.json()).data.id);
components:
  schemas:
    TextToVideoRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          minLength: 1
          description: Text description of the video to generate.
        settings:
          $ref: '#/components/schemas/VideoSettings'
        options:
          $ref: '#/components/schemas/TaskOptions'
      additionalProperties: false
      description: >-
        Text-to-video request fields exposed by the CometAPI route. The model ID
        is a path parameter, not a body field.
    CreateTaskResponse:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          oneOf:
            - type: integer
            - type: string
          description: Request result code. `0` or `success` indicates acceptance.
        message:
          type: string
          description: Result message.
        msg:
          type: string
          description: Additional result message when included in the response.
        data:
          type: object
          description: Task identifier and submission status.
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: Task ID to use in `GET /tasks?task_ids={id}`.
            status:
              type: string
              description: Task status at submission.
    VideoSettings:
      type: object
      description: >-
        Video generation settings exposed by the CometAPI route. The model ID in
        the URL determines which values are accepted.
      properties:
        resolution:
          type: string
          enum:
            - 720p
            - 1080p
            - 4k
          default: 720p
          description: >-
            Output resolution. `4k` is available with `kling-3.0`; the other
            listed models accept `720p` or `1080p`.
        aspect_ratio:
          type: string
          enum:
            - '21:9'
            - '16:9'
            - '9:16'
            - '1:1'
          default: '16:9'
          description: Output frame aspect ratio. `21:9` is available with `kling-4.0`.
        duration:
          type: integer
          minimum: 3
          maximum: 30
          description: >-
            Video length in seconds. Use an integer from 3 to 30 for
            `kling-4.0`, 3 to 15 for the 3.0 models, or 5 or 10 for the 2.x
            models. If omitted, the request uses 10 seconds for `kling-4.0` and
            5 seconds for the other models. Send a JSON number, not a string.
        multi_shot:
          type: boolean
          description: >-
            For `kling-3.0` only, the official default is `true`. Set `true` for
            multiple shots or `false` for one shot, and set the value explicitly
            when you use this field.
        audio:
          type: string
          enum:
            - native
            - 'off'
          description: >-
            For `kling-3.0` or `kling-2.6`, use `native` for generated audio or
            `off` to disable it. Set the value explicitly when you use this
            field. With `kling-2.6`, `native` requires `1080p`. Omit this field
            for the Turbo models.
      additionalProperties: false
    TaskOptions:
      type: object
      description: Optional task fields exposed by the CometAPI route.
      properties:
        callback_url:
          type: string
          format: uri
          description: Public URL that receives task updates.
        external_task_id:
          type: string
          description: >-
            Your identifier for matching this task to a record in your
            application.
        watermark_info:
          type: object
          description: Watermark configuration for the generated video.
          additionalProperties: true
      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.