> ## 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.5-preview 動画生成

>  - 万相 2.5 プレビュー版動画生成モデル
- テキストから動画 (Text-to-Video) と画像から動画 (Image-to-Video) をサポート
- 480p/720p/1080p 解像度、5 または 10 秒の長さをサポート
- プロンプト自動拡張、自動音声、カスタム音声をサポート 

<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.5-preview",
      "prompt": "夕日の海辺の道路、映画のようなショット",
      "size": "16:9",
      "resolution": "720p",
      "duration": 5
    }'
  ```

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

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

  payload = {
      "model": "wan2.5-preview",
      "prompt": "夕日の海辺の道路、映画のようなショット",
      "size": "16:9",
      "resolution": "720p",
      "duration": 5
  }

  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.5-preview",
    prompt: "夕日の海辺の道路、映画のようなショット",
    size: "16:9",
    resolution: "720p",
    duration: 5
  };

  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.5-preview",
          "prompt":     "夕日の海辺の道路、映画のようなショット",
          "size":       "16:9",
          "resolution": "720p",
          "duration":   5,
      }

      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.5-preview",
            "prompt": "夕日の海辺の道路、映画のようなショット",
            "size": "16:9",
            "resolution": "720p",
            "duration": 5
          }
          """;

          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.5-preview",
      "prompt" => "夕日の海辺の道路、映画のようなショット",
      "size" => "16:9",
      "resolution" => "720p",
      "duration" => 5
  ];

  $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.5-preview",
    prompt: "夕日の海辺の道路、映画のようなショット",
    size: "16:9",
    resolution: "720p",
    duration: 5
  }

  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.5-preview",
      "prompt": "夕日の海辺の道路、映画のようなショット",
      "size": "16:9",
      "resolution": "720p",
      "duration": 5
  ]

  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.5-preview"",
              ""prompt"": ""夕日の海辺の道路、映画のようなショット"",
              ""size"": ""16:9"",
              ""resolution"": ""720p"",
              ""duration"": 5
          }";

          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>
  すべてのエンドポイントで Bearer Token 認証が必要です

  API Key の取得：

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

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

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

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

<ParamField body="model" type="string" required>
  動画生成モデル名、`wan2.5-preview` 固定
</ParamField>

<ParamField body="prompt" type="string">
  動画の内容説明

  テキストから動画（`image_urls` なし）の場合は**必須**、画像から動画の場合は任意ですが推奨

  シーン、動作、スタイルなどを詳細に記述してください

  例：`"夕日の海辺の道路、映画のようなショット"`
</ParamField>

<ParamField body="image_urls" type="array<string>">
  参照画像 URL 配列（1 枚のみサポート）

  画像から動画モードで必須、公開アクセス可能な画像 URL または Base64 エンコード（`data:image/png;base64,...`）をサポート

  例：`["https://example.com/image.jpg"]`

  <Note>
    `image_urls` の有無によりテキストから動画または画像から動画モードが自動選択されます。テキストから動画モードでは `image_urls` を**渡さないでください**。
  </Note>
</ParamField>

<ParamField body="negative_prompt" type="string">
  ネガティブプロンプト、表示したくない内容を記述

  最大 500 文字

  例：`"ぼやけ, 低品質, 変形"`
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  動画解像度

  オプション：

  * `480p` - SD、サポート size：`16:9`、`9:16`、`1:1`
  * `720p` - HD（デフォルト）、サポート size：`16:9`、`9:16`、`1:1`、`4:3`、`3:4`
  * `1080p` - FHD、サポート size：`16:9`、`9:16`、`1:1`、`4:3`、`3:4`

  デフォルト：`720p`

  <Note>
    解像度は料金に直接影響します：1080p > 720p > 480p。
  </Note>

  <Warning>
    480p は `16:9`、`9:16`、`1:1` の 3 つの比率のみサポートしています。`4:3` または `3:4` を指定するとエラーになります。
  </Warning>
</ParamField>

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

  `5` または `10` 秒のみサポート

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

<ParamField body="size" type="string" default="16:9">
  アスペクト比、**テキストから動画**（`image_urls` なし）のみ有効

  `resolution` により選択肢が異なります：

  **480p：**

  * `16:9` - 横向き（デフォルト）
  * `9:16` - 縦向き
  * `1:1` - 正方形

  **720p / 1080p：**

  * `16:9` - 横向き（デフォルト）
  * `9:16` - 縦向き
  * `1:1` - 正方形
  * `4:3` - 横向き
  * `3:4` - 縦向き

  デフォルト：`16:9`

  <Warning>
    画像から動画のアスペクト比は入力画像により決定されます。`size` を**渡さないでください**、エラーになります。
  </Warning>
</ParamField>

<ParamField body="seed" type="integer">
  ランダムシード（≥0）、同じシードを指定すると類似の結果を再現できます

  例：`12345`
</ParamField>

<ParamField body="prompt_extend" type="boolean" default="true">
  プロンプトのスマート書き換えを有効にするかどうか

  短いプロンプトの効果を大幅に向上させますが、処理時間が増加します

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

<ParamField body="audio" type="boolean" default="true">
  音声を自動追加するかどうか

  有効にすると、動画に合った音声が自動生成されます

  デフォルト：`true`

  <Warning>
    このモデルは `audio=true` のみサポートしています。`false` に設定して無音動画を生成することはできません。
  </Warning>
</ParamField>

<ParamField body="audio_url" type="string">
  カスタム音声 URL（wav/mp3、3-30 秒、≤ 15MB）

  音声が動画より長い場合は自動的にトリミングされます。短い場合は残りの部分が無音になります

  <Warning>
    音声ファイルの要件：

    * 形式：wav、mp3
    * 長さ：3-30 秒
    * サイズ：≤ 15MB
  </Warning>
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  「AI生成」ウォーターマークを追加するかどうか（右下）

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

## 解像度とアスペクト比の組み合わせ

`size` と `resolution` の組み合わせは上流のピクセルサイズにマッピングされます（**テキストから動画のみ有効**）：

| アスペクト比 | 説明         | 480p サイズ | 720p サイズ | 1080p サイズ |
| ------ | ---------- | -------- | -------- | --------- |
| `16:9` | 横向き（デフォルト） | 832×480  | 1280×720 | 1920×1080 |
| `9:16` | 縦向き        | 480×832  | 720×1280 | 1080×1920 |
| `1:1`  | 正方形        | 624×624  | 960×960  | 1440×1440 |
| `4:3`  | 横向き        | -        | 1088×832 | 1632×1248 |
| `3:4`  | 縦向き        | -        | 832×1088 | 1248×1632 |

<Note>
  480p は `16:9`、`9:16`、`1:1` の 3 つの比率のみサポートしています。`4:3` または `3:4` を指定するとエラーになります。720p と 1080p は 5 つすべての比率をサポートしています。
</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：テキストから動画（シンプル）

```json theme={null}
{
  "model": "wan2.5-preview",
  "prompt": "夕日の海辺の道路、映画のようなショット"
}
```

### シーン 2：テキストから動画（全パラメータ）

```json theme={null}
{
  "model": "wan2.5-preview",
  "prompt": "都市の夜景、ネオンと雨上がりの街",
  "negative_prompt": "ぼやけ, 低品質, 変形",
  "size": "16:9",
  "resolution": "720p",
  "duration": 5,
  "seed": 12345,
  "prompt_extend": true,
  "audio": true,
  "watermark": false
}
```

### シーン 3：画像から動画

```json theme={null}
{
  "model": "wan2.5-preview",
  "prompt": "猫が草原を走る",
  "image_urls": ["https://example.com/cat.jpg"],
  "resolution": "480p",
  "duration": 5
}
```

### シーン 4：画像から動画（Base64 画像）

```json theme={null}
{
  "model": "wan2.5-preview",
  "prompt": "猫を立ち上がって歩かせる",
  "image_urls": ["data:image/png;base64,iVBORw0KGgo..."],
  "duration": 5
}
```

### シーン 5：カスタム音声

```json theme={null}
{
  "model": "wan2.5-preview",
  "prompt": "人物が音楽に合わせて踊る",
  "image_urls": ["https://example.com/dancer.jpg"],
  "audio_url": "https://example.com/music.mp3",
  "resolution": "720p",
  "duration": 10
}
```

## モード説明

### テキストから動画 (Text-to-Video)

* `prompt` パラメータが必須
* `image_urls` は不要
* `size` でアスペクト比を指定可能

### 画像から動画 (Image-to-Video)

* `image_urls` パラメータが必須（1 枚のみ）
* `prompt` は任意、期待する動作の説明に使用
* アスペクト比は入力画像により決定、`size` を**渡さないでください**

<Note>
  `image_urls` の有無によりモードが自動選択されます
</Note>

<Note>
  **タスク結果の照会**

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