> ## 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 画像生成・編集

>  - Wan2.7 画像シリーズ：テキストから画像、画像編集、インタラクティブ編集、連続生成、複数画像参照をサポート
- 非同期処理モード — タスクを送信し、返却された task_id を使って結果をポーリング
- 1K / 2K / 4K 解像度をサポート；wan2.7-image-pro のテキスト生成は最大 4K
- 課金は成功した生成枚数に基づき、解像度・アスペクト比は料金に影響しない 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/images/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "wan2.7-image-pro",
      "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
    }'
  ```

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

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

  payload = {
      "model": "wan2.7-image-pro",
      "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
  }

  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/images/generations";

  const payload = {
    model: "wan2.7-image-pro",
    prompt: "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
  };

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

  fetch(url, { method: "POST", headers, body: JSON.stringify(payload) })
    .then(r => r.json()).then(console.log).catch(console.error);
  ```

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

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

  func main() {
      url := "https://api.apimart.ai/v1/images/generations"
      payload := map[string]interface{}{
          "model":  "wan2.7-image-pro",
          "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている",
      }
      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")
      resp, err := (&http.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 payload = """
          {
            "model": "wan2.7-image-pro",
            "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
          }
          """;
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://api.apimart.ai/v1/images/generations"))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();
          System.out.println(HttpClient.newHttpClient()
              .send(request, HttpResponse.BodyHandlers.ofString()).body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $payload = ["model" => "wan2.7-image-pro", "prompt" => "精巧な窓のある花屋、美しい木製ドア、花が飾られている"];
  $ch = curl_init("https://api.apimart.ai/v1/images/generations");
  curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true,
      CURLOPT_POSTFIELDS => json_encode($payload),
      CURLOPT_HTTPHEADER => ["Authorization: Bearer <token>", "Content-Type: application/json"]]);
  echo curl_exec($ch); curl_close($ch);
  ?>
  ```

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

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

  payload = {
    model: "wan2.7-image-pro",
    prompt: "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
  }

  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/images/generations")!

  let payload: [String: Any] = [
      "model": "wan2.7-image-pro",
      "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている"
  ]

  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 str = String(data: data, encoding: .utf8) { print(str) }
  }
  task.resume()
  ```

  ```csharp C# theme={null}
  using System.Net.Http; using System.Text;
  var payload = @"{""model"":""wan2.7-image-pro"",""prompt"":""精巧な窓のある花屋、美しい木製ドア、花が飾られている""}";
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");
  var res = await client.PostAsync("https://api.apimart.ai/v1/images/generations",
      new StringContent(payload, Encoding.UTF8, "application/json"));
  Console.WriteLine(await res.Content.ReadAsStringAsync());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": "success",
    "data": [{ "task_id": "task_01HX...", "status": "processing" }]
  }
  ```

  ```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 管理ページ](https://apimart.ai/keys) から API Key を取得し、リクエストヘッダーに追加してください：

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

## 利用可能なモデル

| モデル名               | 説明                      | テキスト生成最大解像度 | 編集 / 連続生成最大解像度 | 単価        |
| ------------------ | ----------------------- | :---------: | :------------: | --------- |
| `wan2.7-image-pro` | プロフェッショナル版、精細度が高く 4K 対応 |      4K     |       2K       | ¥0.50 / 枚 |
| `wan2.7-image`     | スタンダード版、高速生成            |      2K     |       2K       | ¥0.20 / 枚 |

<Note>
  課金は**成功した生成枚数 × 単価**で計算されます。入力は課金対象外。解像度とアスペクト比は料金に影響しません。失敗したリクエストは課金されません。
</Note>

## Body

<ParamField body="model" type="string" required>
  画像生成モデル名

  * `wan2.7-image-pro` — プロフェッショナル版、テキスト生成で最大 4K
  * `wan2.7-image` — スタンダード版、高速、最大 2K
</ParamField>

<ParamField body="prompt" type="string">
  生成する画像のテキスト説明。最大 5000 文字。

  * **テキスト生成モード**（`image_urls` なし）：必須
  * **画像編集モード**（`image_urls` あり）：任意（推奨）

  例：`"精巧な窓のある花屋、美しい木製ドア、花が飾られている"`
</ParamField>

<ParamField body="image_urls" type="array<string>">
  入力画像の URL 配列。画像編集・複数画像参照などのシナリオで使用します。

  指定すると**画像編集モード**に自動的に切り替わります。

  **対応形式：** HTTP / HTTPS 画像リンク；`data:image/...;base64,...` Base64 形式

  **制約：** 最大 9 枚；JPEG / PNG / WEBP / BMP；240–8000 px；アスペクト比 1:8 \~ 8:1；1 枚あたり ≤ 20MB

  <Note>
    出力のアスペクト比は**最後の**入力画像に自動的に合わせられます。編集モードは最大 2K です（4K 非対応）。
  </Note>
</ParamField>

<ParamField body="n" type="integer" default="1">
  生成する画像の枚数

  * **標準モード**：1–4（デフォルト 1）
  * **連続生成モード**（`enable_sequential: true`）：1–12（デフォルト 1）

  <Note>成功した生成枚数ごとに課金されます。`n` に基づいて事前課金されます。</Note>
</ParamField>

<ParamField body="size" type="string">
  出力解像度またはアスペクト比。3つの形式をサポートしています：

  **① 解像度キーワード（推奨）：** `1K` / `2K`（デフォルト）/ `4K`（`wan2.7-image-pro` テキスト生成のみ）

  **② アスペクト比：** `1:1` / `16:9` / `9:16` / `4:3` / `3:4` / `3:2` / `2:3`（デフォルトでは 2K ティアに換算）

  **③ ピクセル値：** `1024x1024` または `1024*1024`
</ParamField>

<ParamField body="resolution" type="string">
  解像度キーワード：`1K` / `2K` / `4K`。`size`（アスペクト比）と組み合わせて使用できます。

  | モデル                | シナリオ        |     サポートキーワード    | ピクセル範囲              |
  | ------------------ | ----------- | :--------------: | ------------------- |
  | `wan2.7-image-pro` | テキスト生成（非連続） | 1K / **2K** / 4K | 768×768 〜 4096×4096 |
  | `wan2.7-image-pro` | 編集 / 連続生成   |    1K / **2K**   | 768×768 〜 2048×2048 |
  | `wan2.7-image`     | すべてのシナリオ    |    1K / **2K**   | 768×768 〜 2048×2048 |
</ParamField>

<ParamField body="negative_prompt" type="string">
  ネガティブプロンプト。例：`"ぼやけた、歪んだ、低品質"`
</ParamField>

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

<ParamField body="seed" type="integer">
  ランダムシード（0–2147483647）。同じパラメータと同じシードを使用すると、視覚的に一貫した結果を生成できます。
</ParamField>

<ParamField body="thinking_mode" type="boolean" default="true">
  強化推論モード。画像品質が向上しますが生成時間が長くなります。

  <Note>**連続生成モード無効**かつ**画像入力なし**の場合のみ有効です。</Note>
</ParamField>

<ParamField body="enable_sequential" type="boolean" default="false">
  **連続画像生成**モードを有効にします。絵コンテ、漫画、シリーズに最適。

  * 有効時の `n` 上限は 12
  * 連続生成モードでは `thinking_mode` と `color_palette` は無効
  * `wan2.7-image-pro` の連続生成は最大 2K（4K 非対応）
</ParamField>

<ParamField body="bbox_list" type="array">
  インタラクティブ編集用のバウンディングボックス。編集またはコンテンツ挿入する正確な領域を指定します。

  **構造：** `[[[x1, y1, x2, y2], ...], ...]`

  * 外側の配列長は `image_urls` の長さと一致する必要があります
  * ボックス不要な画像には `[]` を渡します
  * 1枚の画像につき最大2ボックス。座標は元画像の絶対ピクセル値で、左上を (0,0) とします

  例：`[[], [[989, 515, 1138, 681]]]`
</ParamField>

<ParamField body="color_palette" type="array<object>">
  カスタムカラーテーマ。**標準モードのみ**（連続生成モードでは使用不可）。

  * 3–10 項目（8項目推奨）。各項目には `hex` と `ratio` が必要です
  * すべての `ratio` 値の合計は正確に `100.00%` である必要があります

  ```json theme={null}
  [{ "hex": "#C2D1E6", "ratio": "23.51%" }, { "hex": "#636574", "ratio": "76.49%" }]
  ```
</ParamField>

## レスポンス

<ResponseField name="code" type="string">
  レスポンスステータス。成功時は `"success"` を返します。
</ResponseField>

<ResponseField name="data" type="array">
  <Expandable title="配列要素">
    <ResponseField name="task_id" type="string">
      生成結果の照会に使用する一意のタスク識別子。
    </ResponseField>

    <ResponseField name="status" type="string">
      初期タスクステータス。送信直後は常に `processing` です。
    </ResponseField>
  </Expandable>
</ResponseField>

## 利用例

### テキストから画像（最小）

```json theme={null}
{ "model": "wan2.7-image-pro", "prompt": "精巧な窓のある花屋、美しい木製ドア、花が飾られている" }
```

### テキストから画像（解像度指定）

```json theme={null}
{ "model": "wan2.7-image-pro", "prompt": "夏のビーチ、青空と白い雲、4K 超高精細", "size": "4K", "thinking_mode": true }
```

### カスタムカラーテーマ

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "ミニマルなモダンリビング",
  "size": "2K",
  "color_palette": [
    { "hex": "#C2D1E6", "ratio": "23.51%" }, { "hex": "#CDD8E9", "ratio": "20.13%" },
    { "hex": "#B5C8DB", "ratio": "15.88%" }, { "hex": "#C0B5B4", "ratio": "13.27%" },
    { "hex": "#DAE0EC", "ratio": "10.11%" }, { "hex": "#636574", "ratio": "8.93%" },
    { "hex": "#CACAD2", "ratio": "5.55%" },  { "hex": "#CBD4E4", "ratio": "2.62%" }
  ]
}
```

### 連続画像生成

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "映画的なシリーズ：同じ野良の茶トラ猫。1枚目：春の桜の木の下。2枚目：夏の古い街路の木陰。3枚目：秋の落ち葉が散る道。4枚目：冬の雪の上の足跡。",
  "enable_sequential": true,
  "n": 4,
  "size": "2K"
}
```

### 単一画像編集

```json theme={null}
{ "model": "wan2.7-image", "prompt": "背景を夕焼けのシーンに変え、全体的に暖色系に", "image_urls": ["https://example.com/portrait.jpg"], "size": "2K" }
```

### 複数画像参照 / 要素融合

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "画像2のグラフィティを画像1の車に描く",
  "image_urls": ["https://example.com/car.webp", "https://example.com/paint.webp"],
  "size": "2K"
}
```

### インタラクティブ編集（バウンディングボックス）

`bbox_list` は `image_urls` と 1 対 1 で対応します。選択範囲がない画像には `[]` を渡してください。

```json theme={null}
{
  "model": "wan2.7-image-pro",
  "prompt": "画像1の目覚まし時計を画像2の指定エリアに置き、シーンと光源に自然に馴染ませる",
  "image_urls": ["https://example.com/clock.webp", "https://example.com/desk.webp"],
  "bbox_list": [[], [[989, 515, 1138, 681]]],
  "size": "2K"
}
```

<Note>
  **結果の照会**

  画像生成は非同期です。返却された `task_id` を使用して [タスクステータス](/ja/api-reference/tasks/status) エンドポイントを `status == completed` になるまでポーリングしてください。
</Note>
