> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Seedream 4.5 251128 を使用する

> Comfy Router 経由で byteplus/seedream-4-5-251128 を呼び出します: エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`byteplus/seedream-4-5-251128` の API リファレンスです。Comfy Router が BytePlus から提供しています。

## クイックスタート

[Comfy ワークスペース](https://platform.comfy.org/profile/api-keys)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）を使用しており、cURL のスニペットは同じ呼び出しを生の HTTP で行うものです。

**モデル ID:** `byteplus/seedream-4-5-251128`

**エンドポイント:** `POST https://api.comfy.org/v2/models/byteplus/seedream-4-5-251128`

<Tabs>
  <Tab title="Wait for the result">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # The SDK automatically creates an idempotency key and reuses it for automatic retries.
      with Comfy() as client:
          result = client.models.run(
              "byteplus/seedream-4-5-251128",
              {
                  "prompt": "A red fox trotting through a snowy pine forest, cinematic lighting",
                  "response_format": "url",
                  "watermark": False,
              },
          )

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // The SDK automatically creates an idempotency key and reuses it for automatic retries.
      const { data } = await comfy.models.run("byteplus/seedream-4-5-251128", {
        prompt: "A red fox trotting through a snowy pine forest, cinematic lighting",
        response_format: "url",
        watermark: false,
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/byteplus/seedream-4-5-251128 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"A red fox trotting through a snowy pine forest, cinematic lighting\", \"response_format\": \"url\", \"watermark\": false}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      with Comfy() as client:
          handle = client.models.submit(
              "byteplus/seedream-4-5-251128",
              {
                  "prompt": "A red fox trotting through a snowy pine forest, cinematic lighting",
                  "response_format": "url",
                  "watermark": False,
              },
          )
          print("request_id:", handle.request_id)  # with the model ID, all another process needs

          # Poll until the request completes, waiting the Retry-After the server names.
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # The provider's own payload, the same value models.run() returns.
          # A request that failed or was cancelled raises the typed Router error here.
          result = handle.get()

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      const handle = await comfy.models.submit("byteplus/seedream-4-5-251128", {
        prompt: "A red fox trotting through a snowy pine forest, cinematic lighting",
        response_format: "url",
        watermark: false,
      });
      console.log("requestId:", handle.requestId); // with the model ID, all another process needs

      // Poll until the request completes, waiting the Retry-After the server names.
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // The same result models.run() returns. A request that failed or was cancelled rejects here.
      const result = await handle.get();

      console.log(result.data);
      ```

      ```bash cURL theme={null}
      # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
      curl https://api.comfy.org/v2/models/byteplus/seedream-4-5-251128/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"A red fox trotting through a snowy pine forest, cinematic lighting\", \"response_format\": \"url\", \"watermark\": false}"

      # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/byteplus/seedream-4-5-251128/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
      curl https://api.comfy.org/v2/models/byteplus/seedream-4-5-251128/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="guidance_scale" type="number">
  出力画像が入力プロンプトにどれだけ忠実に一致するかを制御します。範囲 \[1, 10]。値が大きいほどプロンプトへの追従性が高くなります。seedream-3-0-t2i-250415 ではデフォルト 2.5、seededit-3-0-i2i-250628 では 5.5 です。seedream-5.0-pro、5.0-lite、4.5、4.0 ではサポートされていません。

  範囲: `1` から `10`

  形式: `float`
</ParamField>

<ParamField body="image" type="string | string[]">
  seedream-5.0-pro、5.0-lite、4.5、4.0、および seededit-3.0-i2i がこのパラメータをサポートします。

  編集する画像の Base64 エンコーディング、またはアクセス可能な URL を入力します。seedream-5.0-pro、5.0-lite、4.5、4.0 は単一画像または複数画像の入力に対応しています（複数画像のブレンド例を参照）。一方、seededit-3.0-i2i は単一画像の入力のみに対応しています。

  • 画像URL: 画像URLにアクセス可能であることを確認してください。
  • Base64 エンコーディング: 形式は data:image/\<image format>;base64,\<Base64 encoding> である必要があります。注意: \<image format> は小文字である必要があります。例: data:image/png;base64,\<base64\_image>。

  Comfy Router は、base64 の展開とすべての参照画像を含め、JSON リクエスト全体を 10 MiB に制限します。この転送制限を超える入力には URL を使用してください。

  入力画像は次の要件を満たす必要があります:
  • 画像形式: jpeg、png（seedream-5.0-pro、5.0-lite、4.5、4.0 は webp、bmp、tiff、gif にも対応。seedream-5.0-pro は heic と heif にも対応）
  • アスペクト比（幅/高さ）: seedream-5.0-pro、5.0-lite、4.5、4.0 では \[1/16, 16] の範囲。seededit-3.0-i2i では \[1/3, 3] の範囲
  • 幅と高さ（px）: 14 より大きい
  • サイズ: 10 MB 以下（seedream-5.0-pro は 30 MB）
  • 総ピクセル数: seedream-5.0-pro では 6000x6000（36,000,000 px）以下
  • 参照画像は最大 14 枚（seedream-5.0-pro は 10 枚）

  レイヤー分離シナリオ（layer\_decomposition が有効）では、image は必須で、単一の入力画像のみがサポートされます（複数の画像を渡すとエラーが返ります）。入力画像は png、jpeg、webp、bmp、tiff、gif のいずれかである必要があり（heic と heif はサポートされません）、最大 30 MB、総ピクセル数が \[512x512, 6000x6000] の範囲、アスペクト比が \[1/16, 16] の範囲である必要があります。
</ParamField>

<ParamField body="layer_decomposition" type="boolean" default="false">
  レイヤー分離を有効にするかどうかを制御します。seedream-5.0-pro のみがこのパラメータをサポートします。
  true: レイヤー分離モード。モデルは単一の入力画像を 1 つのベース画像と複数のレイヤー（最大 16）に分解し、生成された各レイヤーの位置とコンテンツ情報を返します。これには重なり順（z\_index）、バウンディングボックス（bounding\_box）、名前（name）、説明（description）が含まれます。
  false: スタンダードな画像生成モード。レイヤー分離は行われません。
  レイヤー分離モードに関する注意: 単一の入力画像のみがサポートされます（複数の画像を渡すとエラーが返ります）。いずれか 1 つのレイヤーの生成に失敗すると、リクエスト全体が失敗します（部分的な成功はサポートされません）。返される画像は最大 17 枚です（ベース画像 1 枚 + レイヤー 16 枚）。sequential\_image\_generation、sequential\_image\_generation\_options、tools、stream を渡すとエラーが返ります。
</ParamField>

<ParamField body="model" type="string">
  モデル識別子。サポートされるモデル: seedream-3-0-t2i-250415、seededit-3-0-i2i-250628、seedream-4-0-250828、seedream-4-5-251128、seedream-5-0-260128、seedream-5-0-pro-260628。POST /proxy/byteplus/api/v3/images/generations への直接の v1 呼び出しでは必ず指定する必要があります。プロキシはそれ以外の値を拒否し、省略された場合も 400 で拒否します。このスキーマの `required` リストには含まれていません。Comfy Router が /v2/models/byteplus/\{model} の `{model}` パスセグメントからこれを設定するため、Router の呼び出し側は省略します。
</ParamField>

<ParamField body="optimize_prompt_options" type="object">
  プロンプト最適化機能の設定。seedream-5.0-pro/5.0-lite/4.5（スタンダードモードのみをサポート）と seedream-4.0 のみがこのパラメータをサポートします。
</ParamField>

<ParamField body="optimize_prompt_options.mode" type="string" default="&#x22;standard&#x22;">
  プロンプト最適化機能のモードを設定します。standard = より高品質ですが生成時間が長くなります。fast = より高速ですが品質は平均的です。

  指定可能な値: `standard`、`fast`
</ParamField>

<ParamField body="output_format" type="string" default="&#x22;jpeg&#x22;">
  出力画像の形式を指定します。seedream-5.0-pro と 5.0-lite のみがこのパラメータをサポートします。レイヤー分離シナリオでは、output\_format はベース画像の形式のみを制御します。各レイヤーは常に png として出力されます。

  指定可能な値: `png`、`jpeg`
</ParamField>

<ParamField body="prompt" type="string">
  画像の生成または変換のためのテキスト記述。
  レイヤー分離シナリオ（layer\_decomposition を有効にした seedream-5.0-pro）では任意です。プロンプトを指定した場合、モデルはプロンプトの意図に従って指定された要素を認識して分離します。プロンプトを指定しない場合、モデルは画像内の主要な要素をすべて自動検出し、独立したレイヤーに分離します。
</ParamField>

<ParamField body="response_format" type="string" default="&#x22;url&#x22;">
  レスポンスで返される生成済み画像の形式を指定します

  指定可能な値: `url`、`b64_json`
</ParamField>

<ParamField body="seed" type="integer" default="-1">
  画像生成のランダム性を制御するシード。範囲: \[-1, 2147483647]。指定しない場合、シードは自動的に生成されます。同じ出力を再現するには、同じシード値を使用してください。

  範囲: `-1` から `2147483647`
</ParamField>

<ParamField body="sequential_image_generation" type="string">
  バッチ生成機能を無効にするかどうかを制御します。このパラメータは seedream-5.0-lite、4.5、4.0 でのみサポートされています（seedream-5.0-pro ではサポートされません）。有効な値:
  auto: 自動モードでは、ユーザーのプロンプトに基づいて、複数の画像を返すかどうか、および含まれる画像数をモデルが自動的に判断します。
  disabled: バッチ生成機能を無効にします。モデルは 1 枚の画像のみを生成します。

  指定可能な値: `auto`、`disabled`
</ParamField>

<ParamField body="sequential_image_generation_options" type="object">
  このパラメータをサポートするのは seedream-5.0-lite、4.5、4.0 のみです（seedream-5.0-pro ではサポートされません）。
  バッチ画像生成機能の設定です。このパラメータは sequential\_image\_generation が auto に設定されている場合にのみ有効です。
</ParamField>

<ParamField body="sequential_image_generation_options.max_images" type="integer" default="15">
  このリクエストで生成する画像の最大数を指定します。入力参照画像数 + 生成画像数 ≤ 15 です。

  範囲: `1` から `15`
</ParamField>

<ParamField body="size" type="string">
  "seedream-3-0-t2i-250415": 生成画像の寸法（幅 x 高さ、ピクセル単位）を指定します。\[512x512, 2048x2048] の範囲である必要があります。
  "seededit-3-0-i2i-250628": 生成画像の幅と高さのピクセル数です。現在は adaptive のみをサポートします。
  "seedream-4-0-250828": 生成画像の仕様を設定します。2 つの方法がありますが、併用はできません。
  方法 1 | 解像度を指定します。指定可能な値: 1K、2K、4K
  方法 2 | 幅と高さをピクセル単位で指定します。デフォルト: 2048x2048、総ピクセル数: \[1024x1024, 4096x4096]、アスペクト比: \[1/16, 16]
  "seedream-4-5-251128": 2 つの方法があります。
  方法 1 | 解像度を指定します。指定可能な値: 2K、4K
  方法 2 | 幅と高さをピクセル単位で指定します。デフォルト: 2048x2048、総ピクセル数: \[2560x1440, 4096x4096]、アスペクト比: \[1/16, 16]
  "seedream-5-0-260128": 2 つの方法があります。
  方法 1 | 解像度を指定します。指定可能な値: 2K、3K
  方法 2 | 幅と高さをピクセル単位で指定します。デフォルト: 2048x2048、総ピクセル数: \[2560x1440, \~3072x3072]、アスペクト比: \[1/16, 16]
  "seedream-5-0-pro-260628": 2 つの方法があります（併用はできません）。
  方法 1 | 解像度を指定し、プロンプトで画像のアスペクト比、形状、用途を記述します。最終的なサイズはモデルが決定します。指定可能な値: 1K、2K
  方法 2 | 幅と高さをピクセル単位で指定します。デフォルト: 1024x1024、総ピクセル数: \[1024x1024 (1048576), 2048x2048 (4194304)]、アスペクト比: \[1/16, 16]
  "seedream-5-0-pro-260628" で layer\_decomposition を有効にした場合: 解像度レベルの方法のみをサポートします。指定可能な値: 1K、1.5K、2K、auto。デフォルト: auto。
  ベース画像は、元の入力画像のアスペクト比を保ちながら指定された解像度で出力されます。各レイヤーは、元の画像でのアスペクト比を維持しつつ、指定された解像度に近いサイズで出力されます。
  auto: 入力画像のサイズとアスペクト比に基づいて出力されます。\[1280x720, \~2048x2048] の範囲の入力は元の入力サイズで出力され、1K より小さい入力は 1K で出力され、2K より大きい入力は 2K で出力されます。
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  Comfy Router は完全な JSON 結果を取得するため、明示的に指定された stream フラグを false に固定します。v1 プロキシでは、このフィールドはストリーミング出力モードを有効にするかどうかを制御します。このパラメータをサポートするのは seedream-5.0-lite、4.5、4.0 のみです（seedream-5.0-pro ではサポートされません）。false = すべての出力画像が一度に返されます。true = 各出力画像は生成直後に返されます。
</ParamField>

<ParamField body="watermark" type="boolean" default="true">
  生成画像にウォーターマークを追加するかどうかを指定します。false = ウォーターマークなし、true = 'AI generated' ラベル付きのウォーターマークを追加
</ParamField>

Router が `GET /v2/models/byteplus/seedream-4-5-251128/openapi.json` で提供する schema から生成されています。これはリクエストがプロバイダーに到達する前に呼び出しを検証する際に使用されるドキュメントと同じものです。

### 出力

<ResponseField name="created" type="integer">
  リクエストが作成された時刻を示す Unix タイムスタンプ（秒単位）
</ResponseField>

<ResponseField name="data" type="object[]">
  生成された画像に関する情報を含みます。
  レイヤー分離のシナリオでは、配列の最初の要素がベース画像（z\_index=0）で、以降の要素がレイヤーとなり、z\_index の昇順で並びます。
</ResponseField>

<ResponseField name="data[].b64_json" type="string">
  Base64 エンコードされた画像データ（response\_format が "b64\_json" の場合）
</ResponseField>

<ResponseField name="data[].bounding_box" type="object">
  現在のレイヤーがベース画像内で占める領域のバウンディングボックス情報。このフィールドを返すのはレイヤーのみで、ベース画像はキャンバス全体を覆うため bounding\_box を返しません。layer\_decomposition が true の場合にのみ返されます。
</ResponseField>

<ResponseField name="data[].bounding_box.absolute" type="integer[]">
  レイヤーのバウンディングボックスの絶対ピクセル座標。出力されるベース画像の座標系で、左上隅が (0, 0) となります。座標形式: \[left, top, right, bottom]。
</ResponseField>

<ResponseField name="data[].bounding_box.normalized" type="integer[]">
  レイヤーのバウンディングボックスのパーミル量子化（正規化）座標。ベース画像のサイズに基づいて \[0, 1000] の離散的な整数範囲に比例マッピングされ、最大 1000 で切り捨てられます。座標形式: \[left, top, right, bottom]。
</ResponseField>

<ResponseField name="data[].description" type="string">
  現在の分離された要素の詳細な説明。name よりも豊富なレイヤーの特徴（色、状態、マテリアルなど）を提供します。このフィールドを返すのはレイヤーのみで、ベース画像は返しません。layer\_decomposition が true の場合にのみ返されます。
</ResponseField>

<ResponseField name="data[].name" type="string">
  現在の分離された要素の名前/ラベル。分離された被写体の特徴からモデルによって自動生成されます。このフィールドを返すのはレイヤーのみで、ベース画像は返しません。layer\_decomposition が true の場合にのみ返されます。
</ResponseField>

<ResponseField name="data[].output_format" type="string">
  出力画像のファイル形式。このフィールドをサポートするのは seedream-5.0-pro のみです。
</ResponseField>

<ResponseField name="data[].size" type="string">
  画像の幅と高さ（ピクセル単位）。形式は \<width>x\<height>。このパラメータをサポートするのは seedream-5.0-pro、5.0-lite、4.5、4.0 のみです。
</ResponseField>

<ResponseField name="data[].url" type="string (uri)">
  画像ダウンロード用の URL（response\_format が "url" の場合）

  形式: `uri`
</ResponseField>

<ResponseField name="data[].z_index" type="integer">
  レイヤーの重なり順。下から上へ増加します。0 が最下層のレイヤー（ベース画像）で、値が大きいほど上に位置します。レイヤーを正しい重なり順で完全な画像に再構成するために使用します。layer\_decomposition が true の場合にのみ返されます。
</ResponseField>

<ResponseField name="error" type="object">
  エラー情報（存在する場合）
</ResponseField>

<ResponseField name="error.code" type="string">
  エラーコード
</ResponseField>

<ResponseField name="error.message" type="string">
  エラーメッセージ
</ResponseField>

<ResponseField name="model" type="string">
  リクエストに使用されたモデル ID
</ResponseField>

<ResponseField name="usage" type="object" />

<ResponseField name="usage.generated_images" type="integer">
  モデルが生成した画像の数
</ResponseField>

<ResponseField name="usage.input_images" type="integer">
  モデルに入力された画像の数。このフィールドをサポートするのは seedream-5.0-pro のみです。
</ResponseField>

<ResponseField name="usage.output_tokens" type="integer">
  モデルが生成した画像に使用されたトークン数。
</ResponseField>

<ResponseField name="usage.total_tokens" type="integer">
  このリクエストで消費されたトークンの総数。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "prompt": "A red fox trotting through a snowy pine forest, cinematic lighting",
  "response_format": "url",
  "watermark": false
}
```

### 出力

```json theme={null}
{
  "created": 1767225600,
  "data": [
    {
      "size": "1024x1024",
      "url": "https://example.invalid/byteplus/seedream-3-0-t2i-250415/generated.png"
    }
  ],
  "model": "seedream-4-5-251128",
  "usage": {
    "generated_images": 1
  }
}
```

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を示す `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/quickstart">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/quickstart">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
