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

# Bir Kling avatar videosu oluşturun

> CometAPI içindeki Kling Avatar API'yi kullanarak görsellerden avatar odaklı videolar oluşturun. Hızlı image-to-video avatarlar için POST /kling/v1/videos/avatar/image2video kullanın.

Bu endpoint'i, tek bir kaynak görsel ve tek bir ses kaynağından konuşan avatar klipleri oluşturmak için kullanın.

## Çağırmadan önce

* Bir avatar `image` öğesini herkese açık bir URL veya ham base64 string olarak sağlayın
* Kling piksel gereksinimlerini karşılayan bir avatar görseli kullanın; çok küçük küçük görseller generation task tarafından reddedilir
* `audio_id` veya `sound_file` alanlarından tam olarak birini gönderin
* İlk isteği basit tutun: bir yüz görseli, bir ses klibi ve isteğe bağlı kısa bir prompt
* Başvurulan sesin bağlanması gereken önceki bir task'a ait olması durumunda `task_id` ekleyin
* Özellikle daha yüksek kaliteli yolu gerektirmiyorsa `mode: std` ile başlayın

## Ses kaynağı kuralları

* `audio_id`, Kling TTS yolu üzerinden zaten konuşma oluşturduysanız en kolay yoldur
* `sound_file`, zaten kendi MP3, WAV, M4A veya AAC varlığınız varsa çalışır
* Avatar sesi için belgelenen süre 2 ile 60 saniye arasındadır

## Task akışı

<Steps>
  <Step title="Avatar task'ını oluşturun">
    Görseli ve tek bir ses kaynağını gönderin, ardından döndürülen task id değerini kaydedin.
  </Step>

  <Step title="Task'ı sorgulayın">
    Task bir terminal duruma ulaşana kadar [Bir Kling task'ı alın](./individual-queries) ile devam edin.
  </Step>

  <Step title="Tamamlanan sonucu depolayın">
    Sağlayıcının teslim URL'sinin ötesinde saklama ihtiyacınız varsa nihai varlığı kendi depolamanıza kopyalayın.
  </Step>
</Steps>

<Note>
  Tam parametre referansı için [resmi Kling Avatar dokümantasyonuna](https://kling.ai/document-api/apiReference/model/avatar) bakın.
</Note>


## OpenAPI

````yaml api/openapi/video/kling/post-avatar.openapi.json POST /kling/v1/videos/avatar/image2video
openapi: 3.1.0
info:
  title: Avatar API
  version: 1.0.0
  description: >-
    Create a Kling avatar video task from one source image plus one audio
    source.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/avatar/image2video:
    post:
      summary: Create a Kling avatar task
      description: >-
        Submit one avatar image and exactly one audio source. Poll the returned
        task id through the generic Kling query route.
      operationId: avatar
      parameters:
        - name: Content-Type
          in: header
          required: false
          description: Optional content type header.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - image
                - prompt
              oneOf:
                - required:
                    - audio_id
                - required:
                    - sound_file
              properties:
                image:
                  type: string
                  description: >-
                    Avatar image URL or base64 image string. Use an image that
                    meets Kling pixel requirements; very small thumbnails are
                    rejected.
                prompt:
                  type: string
                  description: Prompt describing the desired avatar performance.
                audio_id:
                  type: string
                  description: Audio id from a prior Kling audio task.
                sound_file:
                  type: string
                  description: Public audio URL when you provide your own audio.
                task_id:
                  type: string
                  description: >-
                    Optional prior task id associated with the referenced audio
                    asset.
                mode:
                  type: string
                  description: >-
                    Generation mode. Use `std` or `pro`; omitted requests use
                    `std`.
                  enum:
                    - std
                    - pro
              default:
                image: https://your-image-host/avatar.jpg
                prompt: The speaker talks naturally to camera
                sound_file: https://your-audio-host/speech.wav
                mode: std
            examples:
              Default:
                summary: Avatar image-to-video request
                value:
                  image: https://your-image-host/avatar.jpg
                  prompt: The speaker talks naturally to camera
                  sound_file: https://your-audio-host/speech.wav
                  mode: std
      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
                    required:
                      - task_id
                      - task_status
                      - created_at
                      - updated_at
                    properties:
                      task_id:
                        type: string
                      task_status:
                        type: string
                      task_info:
                        type: object
                        additionalProperties: true
                      created_at:
                        type: integer
                      updated_at:
                        type: integer
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/kling/v1/videos/avatar/image2video \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "image": "https://your-image-host/avatar.jpg",
                  "prompt": "The speaker talks naturally to camera",
                  "sound_file": "https://your-audio-host/speech.wav",
                  "mode": "std"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/avatar/image2video",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "image": "https://your-image-host/avatar.jpg",
                  "prompt": "The speaker talks naturally to camera",
                  "sound_file": "https://your-audio-host/speech.wav",
                  "mode": "std"
                },
            )

            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/avatar/image2video",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "image": "https://your-image-host/avatar.jpg",
                "prompt": "The speaker talks naturally to camera",
                "sound_file": "https://your-audio-host/speech.wav",
                "mode": "std"
              }),
            });


            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.

````