> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Image Edit Product Holding を使用する

> Comfy Router 経由で bria/image-edit-product-holding を呼び出します。エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`bria/image-edit-product-holding` の API リファレンスです。Bria から Comfy Router が提供します。

**入力:** 画像、テキスト · **出力:** 画像

## クイックスタート

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

**モデル ID:** `bria/image-edit-product-holding`

**エンドポイント:** `POST https://api.comfy.org/v2/models/bria/image-edit-product-holding`

**結果を待つ**

```python Python theme={null}
from comfy_sdk import Comfy

# 環境変数から COMFY_API_KEY を読み取ります。
# SDK は自動的に冪等キーを作成し、自動リトライ時にそれを再利用します。
with Comfy() as client:
    result = client.models.run(
        "bria/image-edit-product-holding",
        {
            "person_image": "https://labs-assets.bria.ai/api-examples/product-holding/person.jpg",
            "product_images": ["https://labs-assets.bria.ai/api-examples/product-holding/product.jpg"],
        },
    )

print(result)
```

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

// 環境変数から COMFY_API_KEY を読み取ります。
// SDK は自動的に冪等キーを作成し、自動リトライ時にそれを再利用します。
const { data } = await comfy.models.run("bria/image-edit-product-holding", {
  person_image: "https://labs-assets.bria.ai/api-examples/product-holding/person.jpg",
  product_images: ["https://labs-assets.bria.ai/api-examples/product-holding/product.jpg"],
});

console.log(data);
```

```bash cURL theme={null}
curl https://api.comfy.org/v2/models/bria/image-edit-product-holding \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"person_image\": \"https://labs-assets.bria.ai/api-examples/product-holding/person.jpg\", \"product_images\": [\"https://labs-assets.bria.ai/api-examples/product-holding/product.jpg\"]}"
```

**キューに送信して後で収集する**

同じボディを `POST https://api.comfy.org/v2/models/bria/image-edit-product-holding/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備ができ次第、このプロセスまたは別のプロセスから収集できます。[キュー配信](/ja/development/comfy-router/queue.md)では、ステータス、キャンセル、収集の流れを説明しています。

```python Python theme={null}
import asyncio
from comfy_sdk import AsyncComfy

# 環境変数から COMFY_API_KEY を読み取ります。
# 各 submit() 呼び出しは独自の Idempotency-Key を発行し、自動リトライ時にそれを再利用します。
async def main():
    async with AsyncComfy() as client:
        handle = await client.models.submit(
            "bria/image-edit-product-holding",
            {
                "person_image": "https://labs-assets.bria.ai/api-examples/product-holding/person.jpg",
                "product_images": ["https://labs-assets.bria.ai/api-examples/product-holding/product.jpg"],
            },
        )
        print("request_id:", handle.request_id)  # モデル ID と合わせて、別のプロセスが必要とするすべての情報

        # リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の時間だけ待機します。
        async for update in handle.iter_events():
            print(update.status, update.queue_position)

        # プロバイダー自身のペイロードで、models.run() が返すのと同じ値です。
        # 失敗またはキャンセルされたリクエストは、ここで型付きの Router エラーを発生させます。
        result = await handle.get()

    print(result)

asyncio.run(main())
```

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

// 環境変数から COMFY_API_KEY を読み取ります。
// 各 submit() 呼び出しは独自の Idempotency-Key を発行し、自動リトライ時にそれを再利用します。
const handle = await comfy.models.submit("bria/image-edit-product-holding", {
  person_image: "https://labs-assets.bria.ai/api-examples/product-holding/person.jpg",
  product_images: ["https://labs-assets.bria.ai/api-examples/product-holding/product.jpg"],
});
console.log("requestId:", handle.requestId); // モデル ID と合わせて、別のプロセスが必要とするすべての情報

// リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の時間だけ待機します。
for await (const update of handle.events()) {
  console.log(update.status, update.queuePosition);
}

// models.run() が返すのと同じ結果です。失敗またはキャンセルされたリクエストはここで拒否されます。
const result = await handle.get();

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

```bash cURL theme={null}
# 1. 送信。Router は request_id、status_url、response_url、cancel_url とともに 201 を返します。
curl https://api.comfy.org/v2/models/bria/image-edit-product-holding/requests \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"person_image\": \"https://labs-assets.bria.ai/api-examples/product-holding/person.jpg\", \"product_images\": [\"https://labs-assets.bria.ai/api-examples/product-holding/product.jpg\"]}"

# 2. ステータスが COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After の秒数だけ待機します。
REQUEST_ID="<request_id from the 201 body>"
curl -i https://api.comfy.org/v2/models/bria/image-edit-product-holding/requests/$REQUEST_ID/status \
  -H "X-API-Key: $COMFY_API_KEY"

# 3. 収集。実行中は 200 とモデルのネイティブ出力、まだ実行中の間は 202 とステータスボディを返します。
curl https://api.comfy.org/v2/models/bria/image-edit-product-holding/requests/$REQUEST_ID \
  -H "X-API-Key: $COMFY_API_KEY"
```

## スキーマ

### 入力

**aspect\_ratio** `string`

出力画像のアスペクト比。"1:1"、"2:3"、"3:2"、"3:4"、"4:3"、"4:5"、"5:4"、"9:16"、"16:9" のいずれかです。デフォルトは person\_image のアスペクト比です。

**instruction** `string`

このショットに対する追加の任意指定です。例えば「彼女の右手に持った紙コーヒーカップを缶に置き換え、ロゴをカメラに向ける」などです。完全なプロンプトではなく、方向付けたいディテールのみを送信してください。

**output\_type** `string`

出力画像のフォーマット。"png" または "jpeg"。

**person\_image** `string` *required*

編集対象の人物の写真。公開 URL または Base64 エンコード。対応フォーマットは JPEG、JPG、PNG、WEBP です。

**product\_images** `string[]` *required*

商品の画像を 1 〜 3 枚。パッケージ、別アングル、関連アイテムなどです。各エントリは person\_image と同様に、公開 URL または Base64 エンコードです。

**seed** `integer`

決定論的生成用のシード。省略した場合はランダムなシードが使用されます。

**sync** `boolean`

false または省略する必要があります。Bria の同期モード (true) は、Comfy Router でも、このオペレーション独自の `/proxy/` ルートでも、転送されるのではなく拒否されます。Comfy Router はディスパッチ前に戻りモードを固定し、呼び出し内で結果をポーリングします。また `/proxy/` ルートは、ポーリング用の request\_id と status\_url を返します。

**visual\_output\_content\_moderation** `boolean`

true の場合、ビジュアル出力のモデレーション失敗時に 422 を返します。

このスキーマは、Router が `GET /v2/models/bria/image-edit-product-holding/openapi.json` で提供するスキーマから生成されたもので、リクエストがプロバイダーに到達する前に呼び出しを検証する際に使用される同一のドキュメントです。

### 出力

**error** `object`

エラーオブジェクト (status が ERROR の場合のみ存在)

**error.code** `integer`

エラーコード。

**error.details** `string`

追加のエラー詳細。

**error.message** `string`

エラーメッセージ。

**request\_id** `string`

リクエストの一意の識別子。

**result** `object`

結果オブジェクト (status が COMPLETED の場合のみ存在)

**result.image\_url** `string`

生成/編集された画像の URL。

**result.prompt** `string`

オリジナルのプロンプト。

**result.refined\_prompt** `string`

洗練されたバージョンのプロンプト。Bria が洗練しなかった COMPLETED の生成では null です。キーが省略されるのではなく、null を保持したまま存在 (PRESENT) するため null 許容です。bria/image-edit-gen-fill で実際に確認されています。

**result.seed** `integer`

生成に使用されたシード。

**result.structured\_instruction** `string`

構造化された命令。`/v2/structured_instruction/generate` が返す、文字列としてシリアライズされた JSON ドキュメントです。このオペレーションはどちらの URL も埋めません。

**result.structured\_prompt** `string`

詳細な JSON 構造化プロンプト。

**result.video\_url** `string`

生成されたビデオの URL。

**status** `string`

リクエストの現在のステータス。

取り得る値: `IN_PROGRESS`、`COMPLETED`、`ERROR`、`UNKNOWN`

## 例

### 入力

```json theme={null}
{
  "person_image": "https://labs-assets.bria.ai/api-examples/product-holding/person.jpg",
  "product_images": [
    "https://labs-assets.bria.ai/api-examples/product-holding/product.jpg"
  ]
}
```

### 出力

```json theme={null}
{
  "request_id": "0b3f9d7e-2c41-4a8b-9f10-6d5c8e2a4b71",
  "result": {
    "image_url": "https://example.invalid/bria/image-edit-product-holding/generated.png"
  },
  "status": "COMPLETED"
}
```

## 出荷前の確認

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

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

上記のフィールド説明に記載されているサイズ制限は、プロバイダーの仕様から引用した、そのフィールドに対するプロバイダー自身の上限です。Router はリクエスト本文全体に対して別の上限を適用し、base64 エンコードされたメディアもこれにカウントされます。[リクエスト本文のサイズ](/ja/development/comfy-router/limitations.md) を参照してください。

このページは、Comfy Router 経由で呼び出す 1 つのパートナーモデルについて説明しています。同じ `comfy-sdk` / `@comfyorg/sdk` パッケージには、Comfy Cloud 上で ComfyUI のワークフローグラフ全体を実行するための 2 つ目のクライアントも含まれています: `Comfy(api_key=...)` / `new Comfy({ apiKey })`、および `client.workflows`、`client.assets`、`client.jobs`。[Comfy SDKs](/ja/development/api-development/sdks.md) を参照してください。

> **[ヘッダー](/ja/development/comfy-router/headers.md)**
>
> 認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。

> **[Router API の利用](/ja/development/comfy-router/api.md)**
>
> モデルの検出、バリデーションエラー、リトライ、課金。

> **[制限事項](/ja/development/comfy-router/limitations.md)**
>
> Router が現在対応していないことと、代替手段。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.