> ## 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 で Aleph 2 を使用する

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

`runway/aleph2` の API リファレンス。Runway から Comfy Router が提供します。

## クイックスタート

[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:** `runway/aleph2`

**エンドポイント:** `POST https://api.comfy.org/v2/models/runway/aleph2`

<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(
              "runway/aleph2",
              {
                  "promptText": "recolor the scene in cool blue tones",
                  "videoUri": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.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("runway/aleph2", {
        promptText: "recolor the scene in cool blue tones",
        videoUri: "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/runway/aleph2 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"promptText\": \"recolor the scene in cool blue tones\", \"videoUri\": \"https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4\"}"
      ```
    </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(
              "runway/aleph2",
              {
                  "promptText": "recolor the scene in cool blue tones",
                  "videoUri": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.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("runway/aleph2", {
        promptText: "recolor the scene in cool blue tones",
        videoUri: "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.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/runway/aleph2/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"promptText\": \"recolor the scene in cool blue tones\", \"videoUri\": \"https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.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/runway/aleph2/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/runway/aleph2/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="contentModeration" type="object">
  コンテンツモデレーションシステムの動作に影響する設定。
</ParamField>

<ParamField body="contentModeration.publicFigureThreshold" type="string">
  `low` に設定すると、コンテンツモデレーションシステムは、識別可能な著名人を含む生成を防ぐ際の厳格さが緩和されます。

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

<ParamField body="keyframes" type="object[]">
  入力ビデオ内の特定の時点に配置する、時間指定付きのガイダンス画像。最大5つのキーフレーム。
</ParamField>

<ParamField body="model" type="string">
  生成に使用するモデル。Comfy Router のルート `POST /v2/models/runway/{model}` では、このフィールドはパスから供給されるため送信してはなりません。v1 の `POST /proxy/runway/video_to_video` ルートでは必須であり、RunwayVideoToVideoModelEnum（`aleph2`）に制約されます。
</ParamField>

<ParamField body="promptImage" type="object[]">
  ビデオ内の特定の時点での編集をガイドするための、最大5つの画像キーフレームのリスト。
</ParamField>

<ParamField body="promptImage[].position" type="`first`, `last` | object" required>
  出力ビデオ内で画像を適用する位置。
</ParamField>

<ParamField body="promptImage[].uri" type="string" required>
  エンコードされた画像を含む HTTPS URL、Runway URI、またはデータ URI。
</ParamField>

<ParamField body="promptText" type="string" required>
  出力に何を表示するかを記述する、1000文字以下の空でない文字列。
</ParamField>

<ParamField body="seed" type="integer">
  生成用のランダムシード。

  範囲: `0` ～ `4294967295`

  フォーマット: `int64`
</ParamField>

<ParamField body="videoUri" type="string" required>
  編集する入力ビデオ（HTTPS URL、Runway アップロード URI、またはデータ URI）。30秒以下である必要があります。
</ParamField>

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

### 出力

<ResponseField name="createdAt" type="string (date-time)" required>
  タスク作成タイムスタンプ

  フォーマット: `date-time`
</ResponseField>

<ResponseField name="id" type="string" required>
  タスク ID
</ResponseField>

<ResponseField name="output" type="string[]">
  完了した生成のアセット URL。`runway/gen4_turbo` および `runway/aleph2` では、各要素は VIDEO URL です。タスクが正常に終了すると存在します。このリストが結果そのものです。
</ResponseField>

<ResponseField name="progress" type="number">
  タスクの進捗を表す 0 から 1 の間の浮動小数点値。ステータスが RUNNING の場合にのみ利用可能です。

  範囲: `0` ～ `1`

  フォーマット: `float`
</ResponseField>

<ResponseField name="status" type="string" required>
  Runway タスクで指定可能なステータス。

  指定可能な値: `SUCCEEDED`、`RUNNING`、`FAILED`、`PENDING`、`CANCELLED`、`THROTTLED`
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "promptText": "recolor the scene in cool blue tones",
  "videoUri": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"
}
```

### 出力

```json theme={null}
{
  "createdAt": "2027-01-01T00:00:00Z",
  "id": "5f7c1b28-9a03-4e61-8d2f-1b2c3d4e5f60",
  "output": [
    "https://example.invalid/runway/gen4_turbo/generated.mp4"
  ],
  "status": "SUCCEEDED"
}
```

## 出荷前の確認

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>
