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

# Wan2.7-VideoEdit 動画編集

>  - アリババクラウド万相 2.7 動画編集モデル
- 既存動画に対するAI編集：スタイル転送、コンテンツ置換、要素追加
- 任意で参考画像を渡してターゲットのスタイルや外観を指定可能
- 元の動画の長さ保持または出力長のカスタマイズに対応 

<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": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "背景を雪山のシーンに差し替える",
      "resolution": "1080P"
    }'
  ```

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

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

  payload = {
      "model": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "背景を雪山のシーンに差し替える",
      "resolution": "1080P"
  }

  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: "wan2.7-videoedit",
    video_urls: ["https://cdn.example.com/original.mp4"],
    prompt: "背景を雪山のシーンに差し替える",
    resolution: "1080P"
  };

  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));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":      "wan2.7-videoedit",
          "video_urls": []string{"https://cdn.example.com/original.mp4"},
          "prompt":     "背景を雪山のシーンに差し替える",
          "resolution": "1080P",
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://api.apimart.ai/v1/videos/generations";

          String payload = """
          {
            "model": "wan2.7-videoedit",
            "video_urls": ["https://cdn.example.com/original.mp4"],
            "prompt": "背景を雪山のシーンに差し替える",
            "resolution": "1080P"
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

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

  $payload = [
      "model" => "wan2.7-videoedit",
      "video_urls" => ["https://cdn.example.com/original.mp4"],
      "prompt" => "背景を雪山のシーンに差し替える",
      "resolution" => "1080P"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

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

  payload = {
    model: "wan2.7-videoedit",
    video_urls: ["https://cdn.example.com/original.mp4"],
    prompt: "背景を雪山のシーンに差し替える",
    resolution: "1080P"
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "背景を雪山のシーンに差し替える",
      "resolution": "1080P"
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error {
          print("Error: \(error)")
          return
      }

      if let data = data, let responseString = String(data: data, encoding: .utf8) {
          print(responseString)
      }
  }

  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://api.apimart.ai/v1/videos/generations";

          var payload = @"{
              ""model"": ""wan2.7-videoedit"",
              ""video_urls"": [""https://cdn.example.com/original.mp4""],
              ""prompt"": ""背景を雪山のシーンに差し替える"",
              ""resolution"": ""1080P""
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(url, content);
          var result = await response.Content.ReadAsStringAsync();

          Console.WriteLine(result);
      }
  }
  ```
</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>
  すべてのAPIエンドポイントでBearer Token認証が必要です

  APIキーの取得：

  [APIキー管理ページ](https://apimart.ai/keys)からAPIキーを取得してください

  リクエストヘッダーに追加：

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

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

<ParamField body="model" type="string" required>
  動画生成モデル名。`wan2.7-videoedit` で固定
</ParamField>

<ParamField body="video_urls" type="array<string>" required>
  編集対象の元動画URL配列

  <Warning>
    **最初の 1 本のみ使用されます**
  </Warning>

  <Note>
    **動画の制限：**

    * フォーマット：mp4、mov
    * 長さ：2〜10秒
    * 解像度：幅・高さともに \[240, 4096] ピクセルの範囲
    * アスペクト比：1:8 〜 8:1
    * ファイルサイズ：100MB 以下
  </Note>
</ParamField>

<ParamField body="prompt" type="string">
  編集指示。動画にどのような変更を加えたいかを記述、最大 5000 文字

  <Note>
    未指定の場合、モデルはデフォルトのスタイル転送を実行します
  </Note>

  例：`"人物の衣装を赤いドレスに変える"`、`"背景を雪山のシーンに差し替える"`
</ParamField>

<ParamField body="negative_prompt" type="string">
  出力に含めたくない内容を表すネガティブプロンプト。最大 500 文字まで。
</ParamField>

<ParamField body="image_urls" type="array<string>">
  参考画像URLの配列。最大 4 枚

  ターゲットのスタイルや外観の指定に使用（スタイル転送の参考スタイルなど）
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  出力動画の解像度

  選択肢：

  * `720P` - 標準
  * `1080P` - 高解像度（デフォルト）
</ParamField>

<ParamField body="duration" type="integer" default="0">
  出力動画の長さ（秒）

  * `0`（デフォルト）：元動画の全長を保持
  * `2-10` の整数：先頭から指定時間を切り出し

  <Note>
    `duration=0` の場合、出力動画の実時間で課金されます

    指定する時間は `video_urls` の元動画の長さを超えることはできません
  </Note>
</ParamField>

<ParamField body="size" type="string">
  出力画面のアスペクト比

  対応フォーマット：

  * `16:9` - 横向きワイド
  * `9:16` - 縦向き
  * `1:1` - 正方形
  * `4:3` - 横向き
  * `3:4` - 縦向き

  <Note>
    未指定の場合、入力動画のアスペクト比に従います
  </Note>
</ParamField>

<ParamField body="prompt_extend" type="boolean" default="true">
  プロンプトのインテリジェントな書き換えを有効にするか

  短いプロンプトで効果が顕著ですが、処理時間が増加します

  デフォルト：`true`
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  生成された動画に "AI生成" ウォーターマークを追加するか

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

<ParamField body="seed" type="integer">
  生成内容のランダム性を制御するシード整数

  範囲：`≥0` の整数

  <Note>
    * 同一リクエストで異なるseed値を受け取ると（seedを指定しない場合など）、異なる結果が生成されます
    * 同一リクエストで同じseed値を受け取ると、類似した結果が生成されますが、完全一致は保証されません
  </Note>
</ParamField>

<ParamField body="metadata" type="object">
  追加パラメータオブジェクト

  <Expandable title="metadata フィールド">
    <ParamField body="audio_setting" type="string" default="auto">
      音声処理方式：

      * `auto`（デフォルト）：編集後の動画内容に基づき、AIがマッチングする音声を自動再生成
      * `origin`：元動画の音声を強制的に保持。重要なBGMや対話を含む動画に適する
    </ParamField>
  </Expandable>
</ParamField>

## レスポンス

<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：基本動画編集（最小）

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "prompt": "背景を雪山のシーンに差し替える"
}
```

### 例 2：スタイル転送（参考画像付き）

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "prompt": "参考画像のアニメ調に動画のスタイルを合わせる",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "image_urls": [
    "https://cdn.example.com/anime_style.jpg"
  ],
  "resolution": "1080P",
  "watermark": false
}
```

### 例 3：元動画の音声を保持

重要なBGMや人物の対話がある動画に適します：

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "video_urls": ["https://cdn.example.com/speech.mp4"],
  "prompt": "背景を山道に差し替える",
  "metadata": { "audio_setting": "origin" }
}
```

### 例 4：フルパラメータ

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "prompt": "人物の衣装を赤いドレスに変える",
  "negative_prompt": "ぼやけ、歪み",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "image_urls": ["https://cdn.example.com/reference.jpg"],
  "resolution": "1080P",
  "duration": 0,
  "size": "16:9",
  "prompt_extend": true,
  "watermark": false,
  "seed": 888,
  "metadata": {
    "audio_setting": "origin"
  }
}
```

## 音声処理の説明

| audio\_setting | 説明                            | 適用シーン                      |
| -------------- | ----------------------------- | -------------------------- |
| `auto`（デフォルト）  | 編集後の動画内容に基づき、AIがマッチングする音声を再生成 | 視覚スタイルが大きく変化し、音声も同期更新したい場合 |
| `origin`       | 元動画の音声トラックを強制保持               | 重要なBGMや人物対話を含む動画           |

<Note>
  **タスク結果の取得**

  動画生成は非同期タスクで、送信時に `task_id` が返されます。[タスクステータス取得](/ja/api-reference/tasks/status) エンドポイントで生成進捗と結果を取得してください。
</Note>
