> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Geração de vídeo com controle de movimento Kling v2.6

>  - Modelo de controle de movimento Kling (imagem de referência + vídeo de referência)
- Chamado pelo endpoint unificado `/v1/videos/generations`
- Suporta orientação de personagem por imagem / por vídeo, com duração máxima de 10s / 30s respectivamente
- Tarefa assíncrona — retorna task_id ao ser submetida 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "kling-v2-6-motion-control",
      "prompt": "Keep the character consistent, perform a turn and wave following the reference video, cinematic lighting",
      "image_url": "https://example.com/ref-image.png",
      "video_url": "https://example.com/ref-video-8s.mp4",
      "keep_original_sound": "yes",
      "character_orientation": "image",
      "mode": "std",
      "watermark_info": {"enabled": false}
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "kling-v2-6-motion-control",
      "prompt": "Keep the character consistent, perform a turn and wave following the reference video, cinematic lighting",
      "image_url": "https://example.com/ref-image.png",
      "video_url": "https://example.com/ref-video-8s.mp4",
      "keep_original_sound": "yes",
      "character_orientation": "image",
      "mode": "std",
      "watermark_info": {"enabled": False}
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "kling-v2-6-motion-control",
    prompt: "Keep the character consistent, perform a turn and wave following the reference video, cinematic lighting",
    image_url: "https://example.com/ref-image.png",
    video_url: "https://example.com/ref-video-8s.mp4",
    keep_original_sound: "yes",
    character_orientation: "image",
    mode: "std",
    watermark_info: { enabled: false }
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "Invalid request parameters",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "Authentication failed. Please check your API key.",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "Insufficient account balance. Please top up and try again.",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "Too many requests. Please try again later.",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "Internal server error. Please try again later.",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## Autenticação

<ParamField header="Authorization" type="string" required>
  Todas as requisições exigem autenticação via Bearer Token

  Obtenha sua chave de API:

  Acesse a [página de gerenciamento de chaves de API](https://apimart.ai/keys) para obter sua chave de API

  Adicione o seguinte cabeçalho em cada requisição:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Parâmetros da requisição

<ParamField body="model" type="string" required>
  Nome do modelo: `kling-v3-motion-control` ou `kling-v2-6-motion-control`
</ParamField>

<ParamField body="prompt" type="string">
  Prompt de texto descrevendo o movimento desejado, os movimentos de câmera e o estilo

  Opcional, mas recomendado — descrições mais específicas produzem resultados mais estáveis

  Exemplo: `"The character dances following the reference video, smooth motion, realistic style"`
</ParamField>

<ParamField body="image_url" type="string" required>
  URL da imagem de referência

  Deve ser um link publicamente acessível
</ParamField>

<ParamField body="video_url" type="string" required>
  URL do vídeo de referência

  Deve ser um link direto e publicamente acessível; recomendado mp4/mov, abaixo de 100MB

  <Warning>
    O servidor analisa a duração real de `video_url`. O mínimo é 3 segundos; o máximo é determinado por `character_orientation`.
  </Warning>
</ParamField>

<ParamField body="keep_original_sound" type="string" default="yes">
  Define se a trilha de áudio original do vídeo de referência deve ser mantida

  Opções:

  * `yes`: Manter o áudio original (padrão)
  * `no`: Não manter o áudio original
</ParamField>

<ParamField body="character_orientation" type="string" required>
  Controle de orientação do personagem

  Opções:

  * `image`: Usa a orientação do personagem da imagem de referência (duração do vídeo de referência: `3~10s`)
  * `video`: Usa a orientação do personagem do vídeo de referência (duração do vídeo de referência: `3~30s`)
</ParamField>

<ParamField body="mode" type="string" required>
  Modo de geração

  Opções:

  * `std`: Modo padrão (equilíbrio entre velocidade e qualidade)
  * `pro`: Modo de alta qualidade (latência maior)
</ParamField>

<ParamField body="watermark_info" type="object">
  Objeto de controle de marca d'água (opcional)

  <Expandable title="campos de watermark_info">
    <ParamField body="enabled" type="boolean" default="false">
      Define se uma marca d'água deve ser adicionada

      * `true`: Adicionar marca d'água
      * `false`: Sem marca d'água (padrão)
    </ParamField>
  </Expandable>
</ParamField>

## Regras de duração

| Condição                        | Duração permitida do vídeo de referência |
| ------------------------------- | ---------------------------------------- |
| `character_orientation = image` | `3s ~ 10s`                               |
| `character_orientation = video` | `3s ~ 30s`                               |

<Note>
  A duração para cobrança é determinada pela duração real analisada pelo servidor a partir de `video_url`, e não por uma estimativa do lado do cliente.
</Note>

## Resposta

<ResponseField name="code" type="integer">
  Código de status da resposta, 200 em caso de sucesso
</ResponseField>

<ResponseField name="data" type="array">
  Array de dados da resposta

  <Expandable title="Elementos do array">
    <ResponseField name="status" type="string">
      Status da tarefa, `submitted` na submissão inicial
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Identificador único da tarefa, usado para consultar status e resultados
    </ResponseField>
  </Expandable>
</ResponseField>

## Exemplos

### Exemplo 1: orientação por imagem (até 10s)

```json theme={null}
{
  "model": "kling-v2-6-motion-control",
  "prompt": "Keep character orientation consistent with the reference image, perform a turn and wave",
  "image_url": "https://example.com/ref-image.png",
  "video_url": "https://example.com/ref-video-8s.mp4",
  "character_orientation": "image",
  "mode": "std",
  "keep_original_sound": "yes",
  "watermark_info": {"enabled": false}
}
```

### Exemplo 2: orientação por vídeo (até 30s)

```json theme={null}
{
  "model": "kling-v2-6-motion-control",
  "prompt": "Follow the character orientation and rhythm of the reference video, maintain fluid motion",
  "image_url": "https://example.com/ref-image.png",
  "video_url": "https://example.com/ref-video-12s.mp4",
  "character_orientation": "video",
  "mode": "pro",
  "keep_original_sound": "no",
  "watermark_info": {"enabled": false}
}
```
