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

# Kling v2.6 Motion Control 動画生成

>  - Kling モーションコントロールモデル（参考画像 + 参考動画）
- 統一エンドポイント `/v1/videos/generations` 経由で呼び出し
- image / video の 2 種類のキャラクター方向をサポート、最大時間はそれぞれ 10s / 30s
- 非同期タスク — 送信後に task_id を返す 

<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": "参考動画に合わせてキャラクターが振り向いて手を振る動作を行う、映画的な照明",
      "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": "参考動画に合わせてキャラクターが振り向いてhand を振る動作を行う、映画的な照明",
      "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: "参考動画に合わせてキャラクターが振り向いて手を振る動作を行う、映画的な照明",
    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": "リクエストパラメータが無効です",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "認証に失敗しました。APIキーをご確認ください。",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "残高不足です。チャージしてから再試行してください。",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "リクエストが多すぎます。しばらくしてから再試行してください。",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "サーバー内部エラーが発生しました。しばらくしてから再試行してください。",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## 認証

<ParamField header="Authorization" type="string" required>
  すべてのリクエストに Bearer Token 認証が必要です

  API Key の取得：

  [API Key 管理ページ](https://apimart.ai/keys) にアクセスして API Key を取得してください

  各リクエストに以下のヘッダーを追加してください：

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

## リクエストパラメータ

<ParamField body="model" type="string" required>
  モデル名：`kling-v3-motion-control` または `kling-v2-6-motion-control`
</ParamField>

<ParamField body="prompt" type="string">
  動作・カメラ・スタイルを補足するテキストプロンプト

  省略可能ですが、具体的に記述するほど安定した結果が得られます

  例：`"キャラクターが参考動画に合わせて踊る、滑らかな動き、リアルなスタイル"`
</ParamField>

<ParamField body="image_url" type="string" required>
  参考画像 URL

  公開アクセス可能なリンクを指定してください
</ParamField>

<ParamField body="video_url" type="string" required>
  参考動画 URL

  公開アクセス可能な直リンクを指定してください。mp4/mov 推奨、100MB 以内

  <Warning>
    サーバーが `video_url` の実際の時間を検出します。最短は 3 秒、上限は `character_orientation` によって決まります。
  </Warning>
</ParamField>

<ParamField body="keep_original_sound" type="string" default="yes">
  参考動画の元の音声を保持するかどうか

  選択肢：

  * `yes`：元の音声を保持（デフォルト）
  * `no`：元の音声を保持しない
</ParamField>

<ParamField body="character_orientation" type="string" required>
  キャラクターの向きの制御方式

  選択肢：

  * `image`：参考画像のキャラクターの向きを使用（参考動画の時間：`3~10s`）
  * `video`：参考動画のキャラクターの向きを使用（参考動画の時間：`3~30s`）
</ParamField>

<ParamField body="mode" type="string" required>
  生成モード

  選択肢：

  * `std`：標準モード（速度と品質のバランス）
  * `pro`：高品質モード（処理時間が長くなります）
</ParamField>

<ParamField body="watermark_info" type="object">
  ウォーターマーク制御オブジェクト（オプション）

  <Expandable title="watermark_info フィールド">
    <ParamField body="enabled" type="boolean" default="false">
      ウォーターマークを追加するかどうか

      * `true`：ウォーターマークを追加
      * `false`：ウォーターマークを追加しない（デフォルト）
    </ParamField>
  </Expandable>
</ParamField>

## 時間ルール

| 条件                              | 参考動画の許容時間  |
| ------------------------------- | ---------- |
| `character_orientation = image` | `3s ~ 10s` |
| `character_orientation = video` | `3s ~ 30s` |

<Note>
  課金時間は、サーバーが `video_url` から検出した実際の時間によって決まります。クライアント側の推定値ではありません。
</Note>

## レスポンス

<ResponseField name="code" type="integer">
  レスポンスステータスコード。成功時は 200
</ResponseField>

<ResponseField name="data" type="array">
  レスポンスデータの配列

  <Expandable title="配列要素">
    <ResponseField name="status" type="string">
      タスクのステータス。初回送信時は `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      タスクの一意識別子。タスクの状態と結果の照会に使用します
    </ResponseField>
  </Expandable>
</ResponseField>

## 使用例

### 例 1：image 方向（10 秒以内）

```json theme={null}
{
  "model": "kling-v2-6-motion-control",
  "prompt": "参考画像のキャラクターの向きに合わせて振り向いて手を振る",
  "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}
}
```

### 例 2：video 方向（30 秒以内）

```json theme={null}
{
  "model": "kling-v2-6-motion-control",
  "prompt": "参考動画のキャラクターの向きとリズムに合わせて、滑らかな動きを維持する",
  "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}
}
```
