> ## 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 Remove Background Guided を使用する

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

Bria が提供し、Comfy Router から利用できる `bria/image-edit-remove-background-guided` の API リファレンスです。

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

## クイックスタート

[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-remove-background-guided`

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

**結果を待つ**

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

# 環境変数から COMFY_API_KEY を読み取ります。
# SDK は idempotency key を自動的に作成し、自動リトライで再利用します。
with Comfy() as client:
    result = client.models.run(
        "bria/image-edit-remove-background-guided",
        {
            "image": "https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg",
            "prompt": "the person with the mat and the plant",
        },
    )

print(result)
```

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

// 環境変数から COMFY_API_KEY を読み取ります。
// SDK は idempotency key を自動的に作成し、自動リトライで再利用します。
const { data } = await comfy.models.run("bria/image-edit-remove-background-guided", {
  image: "https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg",
  prompt: "the person with the mat and the plant",
});

console.log(data);
```

```bash cURL theme={null}
curl https://api.comfy.org/v2/models/bria/image-edit-remove-background-guided \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"image\": \"https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg\", \"prompt\": \"the person with the mat and the plant\"}"
```

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

同じボディを `POST https://api.comfy.org/v2/models/bria/image-edit-remove-background-guided/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-remove-background-guided",
            {
                "image": "https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg",
                "prompt": "the person with the mat and the plant",
            },
        )
        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-remove-background-guided", {
  image: "https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg",
  prompt: "the person with the mat and the plant",
});
console.log("requestId:", handle.requestId); // モデル ID と合わせれば、別のプロセスに必要なものはこれだけです

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

// models.run() が返すのと同じ結果です。失敗またはキャンセル済みのリクエストはここで reject されます。
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-remove-background-guided/requests \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"image\": \"https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg\", \"prompt\": \"the person with the mat and the plant\"}"

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

# 3. 収集します。モデル固有の出力を含む 200、まだ実行中ならステータスボディを含む 202 が返ります。
curl https://api.comfy.org/v2/models/bria/image-edit-remove-background-guided/requests/$REQUEST_ID \
  -H "X-API-Key: $COMFY_API_KEY"
```

## スキーマ

### 入力

**image** `string` *required*

背景を除去する画像。サポートされる入力タイプは、Base64 エンコード文字列または公開アクセス可能な画像ファイルを指す URL です。受け入れられる形式は JPEG、JPG、PNG、WEBP です。

**preserve\_alpha** `boolean`

背景除去後に、入力画像の部分的に透明な領域を出力に保持するかどうかを制御します。

**prompt** `string`

デフォルトの切り抜きが保持する内容を変更する、オプションの平易な語句です。たとえば「マットと植物を持った人物」「ランプのないデスクにいる女性」「椅子だけ」などです。プロンプトが不足しているか空の場合、スタンダードな Remove Background の切り抜きを返します。

**sync** `boolean`

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

**visual\_input\_content\_moderation** `boolean`

有効にすると、入力ビジュアルにコンテンツモデレーションを適用します。画像がモデレーションに失敗した場合は 422 を返します。

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

有効にすると、結果ビジュアルにコンテンツモデレーションを適用します。出力がモデレーションに失敗した場合は 422 を返します。

Router が `GET /v2/models/bria/image-edit-remove-background-guided/openapi.json` で提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に Router が呼び出しを検証するのと同じドキュメントです。

### 出力

**error** `object`

エラーオブジェクト（ステータスが ERROR の場合にのみ存在）

**error.code** `integer`

エラーコード。

**error.details** `string`

追加のエラー詳細。

**error.message** `string`

エラーメッセージ。

**request\_id** `string`

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

**result** `object`

結果オブジェクト（ステータスが COMPLETED の場合にのみ存在）

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

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

**result.prompt** `string`

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

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

プロンプトの調整済みバージョン。Bria が調整しなかった COMPLETED の生成では null。キーは省略されるのではなく null を保持して存在する（PRESENT）ため、nullable です。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}
{
  "image": "https://labs-assets.bria.ai/api-examples/guided-remove-background/yoga_studio_input.jpg",
  "prompt": "the person with the mat and the plant"
}
```

### 出力

```json theme={null}
{
  "request_id": "0b3f9d7e-2c41-4a8b-9f10-6d5c8e2a4b71",
  "result": {
    "image_url": "https://example.invalid/bria/image-edit-remove-background-guided/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.