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

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

`bria/video-edit-remove-background` の API リファレンスです。Comfy Router が Bria から提供しています。

## クイックスタート

[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:** `bria/video-edit-remove-background`

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

<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(
              "bria/video-edit-remove-background",
              {
                  "background_color": "Transparent",
                  "output_container_and_codec": "webm_vp9",
                  "video": "https://example.com/input.mp4",
              },
          )

      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("bria/video-edit-remove-background", {
        background_color: "Transparent",
        output_container_and_codec: "webm_vp9",
        video: "https://example.com/input.mp4",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/bria/video-edit-remove-background \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"background_color\": \"Transparent\", \"output_container_and_codec\": \"webm_vp9\", \"video\": \"https://example.com/input.mp4\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    同じボディを `POST https://api.comfy.org/v2/models/bria/video-edit-remove-background/requests` に送信します。Router は実行が受け付けられ次第 `201` と `request_id` を返し、結果は準備が整った時点で、このプロセスからでも別のプロセスからでも取得できます。ステータス、キャンセル、結果の取得の詳細は [Queued delivery](/ja/development/comfy-router/queue) を参照してください。

    <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(
              "bria/video-edit-remove-background",
              {
                  "background_color": "Transparent",
                  "output_container_and_codec": "webm_vp9",
                  "video": "https://example.com/input.mp4",
              },
          )
          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("bria/video-edit-remove-background", {
        background_color: "Transparent",
        output_container_and_codec: "webm_vp9",
        video: "https://example.com/input.mp4",
      });
      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/bria/video-edit-remove-background/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"background_color\": \"Transparent\", \"output_container_and_codec\": \"webm_vp9\", \"video\": \"https://example.com/input.mp4\"}"

      # 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/bria/video-edit-remove-background/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/bria/video-edit-remove-background/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="background_color" type="string">
  出力ビデオの背景色。Transparent の場合、出力コーデックはアルファをサポートしている必要があります。

  指定可能な値: `Transparent`、`Black`、`White`、`Gray`、`Red`、`Green`、`Blue`、`Yellow`、`Cyan`、`Magenta`、`Orange`
</ParamField>

<ParamField body="output_container_and_codec" type="string">
  出力コンテナとコーデックのプリセット。

  指定可能な値: `mp4_h264`、`mp4_h265`、`webm_vp9`、`mov_h265`、`mov_proresks`、`mkv_h264`、`mkv_h265`、`mkv_vp9`、`gif`
</ParamField>

<ParamField body="preserve_audio" type="boolean">
  入力ビデオのオーディオを保持するかどうか。
</ParamField>

<ParamField body="video" type="string" required>
  入力ビデオの公開アクセス可能な URL。入力解像度は最大 16000x16000 (16K) までサポートされています。最大再生時間は 60 秒です。
</ParamField>

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

### 出力

<ResponseField name="error" type="object">
  エラーオブジェクト (status が ERROR の場合にのみ存在)
</ResponseField>

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

<ResponseField name="error.details" type="string">
  追加のエラー詳細。
</ResponseField>

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

<ResponseField name="request_id" type="string">
  リクエストの一意の識別子。
</ResponseField>

<ResponseField name="result" type="object">
  結果オブジェクト (status が COMPLETED の場合にのみ存在)
</ResponseField>

<ResponseField name="result.image_url" type="string">
  生成または編集された画像の URL。
</ResponseField>

<ResponseField name="result.prompt" type="string">
  オリジナルのプロンプト。
</ResponseField>

<ResponseField name="result.refined_prompt" type="string">
  プロンプトの洗練されたバージョン。Bria が洗練しなかった COMPLETED の生成では null になります。キーは省略されるのではなく null を保持した状態で存在するため Nullable です。bria/image-edit-gen-fill で実際に確認されています。
</ResponseField>

<ResponseField name="result.seed" type="integer">
  生成に使用されたシード。
</ResponseField>

<ResponseField name="result.structured_prompt" type="string">
  詳細な JSON 構造化プロンプト。
</ResponseField>

<ResponseField name="result.video_url" type="string">
  生成されたビデオの URL。
</ResponseField>

<ResponseField name="status" type="string">
  リクエストの現在のステータス。

  指定可能な値: `IN_PROGRESS`、`COMPLETED`、`ERROR`、`UNKNOWN`
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "background_color": "Transparent",
  "output_container_and_codec": "webm_vp9",
  "video": "https://example.com/input.mp4"
}
```

### 出力

```json theme={null}
{
  "request_id": "0b3f9d7e-2c41-4a8b-9f10-6d5c8e2a4b71",
  "result": {
    "video_url": "https://example.invalid/bria/video-edit-remove-background/generated.mp4"
  },
  "status": "COMPLETED"
}
```

## 出荷前の確認

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>
