> ## 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 で Photon Flash 1 を使う

> luma/photon-flash-1 を Comfy Router 経由で呼び出す: エンドポイント、リクエストの形式、および Router が返すレスポンス。

`luma/photon-flash-1` の API リファレンス。Luma から 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:** `luma/photon-flash-1`

**エンドポイント:** `POST https://api.comfy.org/v2/models/luma/photon-flash-1`

<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(
              "luma/photon-flash-1",
              {
                  "aspect_ratio": "1:1",
                  "prompt": "a red circle on a plain white background",
              },
          )

      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("luma/photon-flash-1", {
        aspect_ratio: "1:1",
        prompt: "a red circle on a plain white background",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/luma/photon-flash-1 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"1:1\", \"prompt\": \"a red circle on a plain white background\"}"
      ```
    </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(
              "luma/photon-flash-1",
              {
                  "aspect_ratio": "1:1",
                  "prompt": "a red circle on a plain white background",
              },
          )
          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("luma/photon-flash-1", {
        aspect_ratio: "1:1",
        prompt: "a red circle on a plain white background",
      });
      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/luma/photon-flash-1/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"1:1\", \"prompt\": \"a red circle on a plain white background\"}"

      # 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/luma/photon-flash-1/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/luma/photon-flash-1/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="aspect_ratio" type="string" default="&#x22;16:9&#x22;">
  生成のアスペクト比

  指定可能な値: `1:1`、`16:9`、`9:16`、`4:3`、`3:4`、`21:9`、`9:21`
</ParamField>

<ParamField body="callback_url" type="string (uri)">
  生成のコールバック URL

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

<ParamField body="character_ref" type="object" />

<ParamField body="character_ref.identity0" type="object">
  画像アイデンティティオブジェクト
</ParamField>

<ParamField body="character_ref.identity0.images" type="string (uri)[]">
  画像アイデンティティの URL
</ParamField>

<ParamField body="generation_type" type="string" default="&#x22;image&#x22;">
  指定可能な値: `image`
</ParamField>

<ParamField body="image_ref" type="object[]">
  画像参照オブジェクト
</ParamField>

<ParamField body="image_ref[].url" type="string (uri)">
  画像参照の URL

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

<ParamField body="image_ref[].weight" type="number">
  画像参照の重み
</ParamField>

<ParamField body="model" type="string">
  生成に使用する画像モデル。Comfy Router のルート `POST /v2/models/luma/{model}` では、このフィールドはパスから供給されるため送信してはなりません。v1 の `POST /proxy/luma/generations/image` ルートでは LumaImageModel enum（`photon-1`、`photon-flash-1`）に制約され、Rewrite はモデルの省略または不明なモデルを拒否することでこれを強制します。
</ParamField>

<ParamField body="modify_image_ref" type="object">
  変更用画像参照オブジェクト
</ParamField>

<ParamField body="modify_image_ref.url" type="string (uri)">
  画像参照の URL

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

<ParamField body="modify_image_ref.weight" type="number">
  変更用画像参照の重み
</ParamField>

<ParamField body="prompt" type="string">
  生成のプロンプト
</ParamField>

<ParamField body="style_ref" type="object[]">
  画像参照オブジェクト
</ParamField>

<ParamField body="style_ref[].url" type="string (uri)">
  画像参照の URL

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

<ParamField body="style_ref[].weight" type="number">
  画像参照の重み
</ParamField>

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

### 出力

<ResponseField name="assets" type="object">
  画像生成のアセットです。`image` が結果であり、`video` と `progress_video` はこのステータスルートを共有する Dream Machine の VIDEO オペレーションに属するもので、Luma はそれらを明示的な null としてここに送信します。
</ResponseField>

<ResponseField name="assets.image" type="string (uri)">
  生成された画像の URL です。`luma/photon-*` の生成が埋めるリーフにあたります。生成が `completed` に達するまで null です。

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

<ResponseField name="assets.progress_video" type="string (uri)">
  画像生成では常に null です。これは VIDEO 生成の実行中に Luma が公開する進行中のプレビューです。

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

<ResponseField name="assets.video" type="string (uri)">
  画像生成では常に null です。代わりに `luma/ray-*` のビデオモデルがこれを埋めます。

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

<ResponseField name="created_at" type="string (date-time)">
  生成が作成された日時

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

<ResponseField name="failure_reason" type="string">
  生成の状態の理由
</ResponseField>

<ResponseField name="generation_type" type="string">
  生成のタイプです。このオペレーションでは常に `image` です

  取り得る値: `image`
</ResponseField>

<ResponseField name="id" type="string (uuid)">
  生成の ID

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

<ResponseField name="model" type="string">
  生成に使用されたモデル
</ResponseField>

<ResponseField name="request" type="object">
  ターミナルドキュメント内にエコーバックされる画像生成リクエストです。Luma はリクエストモデルのすべてのフィールドをシリアライズし、呼び出し元が設定しなかった各フィールドに明示的な `null` を書き込むため、フィールドの存在はキーではなく値から読み取ってください。
</ResponseField>

<ResponseField name="request.aspect_ratio" type="string" default="&#x22;16:9&#x22;">
  生成のアスペクト比

  取り得る値: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `21:9`, `9:21`
</ResponseField>

<ResponseField name="request.callback_url" type="string (uri)">
  生成のコールバック URL

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

<ResponseField name="request.character_ref" type="object" />

<ResponseField name="request.character_ref.identity0" type="object">
  ターミナルドキュメント内に返ってくる形の画像アイデンティティです。`LumaImageIdentity` と同じ形状で、`LumaImageRefEcho` が示す理由によりそのメンバーは null 許容です。
</ResponseField>

<ResponseField name="request.character_ref.identity0.images" type="string (uri)[]">
  画像アイデンティティの URL
</ResponseField>

<ResponseField name="request.generation_type" type="string">
  設定されている場合は常に `image` で、オペレーションをエコーします。呼び出し元が送信しなかった場合は null です。これはこのエコーオブジェクト全体が存在する理由によるものです。
</ResponseField>

<ResponseField name="request.image_ref" type="object[]">
  ターミナルドキュメント内に返ってくる形の画像参照です。`LumaImageRef` と同じ形状で、各メンバーは null 許容です。Luma は未設定のものを省略せず明示的な `null` としてエコーするためです。
</ResponseField>

<ResponseField name="request.image_ref[].url" type="string (uri)">
  画像参照の URL

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

<ResponseField name="request.image_ref[].weight" type="number">
  画像参照の重み
</ResponseField>

<ResponseField name="request.model" type="string" default="&#x22;photon-1&#x22;">
  生成に使用された画像モデル

  取り得る値: `photon-1`, `photon-flash-1`
</ResponseField>

<ResponseField name="request.modify_image_ref" type="object">
  ターミナルドキュメント内に返ってくる形の画像変更参照です。`LumaModifyImageRef` と同じ形状で、`LumaImageRefEcho` が示す理由によりそのメンバーは null 許容です。
</ResponseField>

<ResponseField name="request.modify_image_ref.url" type="string (uri)">
  画像参照の URL

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

<ResponseField name="request.modify_image_ref.weight" type="number">
  画像変更参照の重み
</ResponseField>

<ResponseField name="request.prompt" type="string">
  生成のプロンプト
</ResponseField>

<ResponseField name="request.style_ref" type="object[]">
  ターミナルドキュメント内に返ってくる形の画像参照です。`LumaImageRef` と同じ形状で、各メンバーは null 許容です。Luma は未設定のものを省略せず明示的な `null` としてエコーするためです。
</ResponseField>

<ResponseField name="request.style_ref[].url" type="string (uri)">
  画像参照の URL

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

<ResponseField name="request.style_ref[].weight" type="number">
  画像参照の重み
</ResponseField>

<ResponseField name="state" type="string">
  生成の状態

  取り得る値: `queued`, `dreaming`, `completed`, `failed`
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "aspect_ratio": "1:1",
  "prompt": "a red circle on a plain white background"
}
```

### 出力

```json theme={null}
{
  "assets": {
    "image": "https://example.invalid/luma/photon-flash-1/generated.png",
    "progress_video": null,
    "video": null
  },
  "created_at": "2027-01-01T00:00:00Z",
  "failure_reason": null,
  "generation_type": "image",
  "id": "a1c73f26-08d5-4e69-b7a2-3c4d5e6f7a80",
  "model": "photon-flash-1",
  "request": {
    "aspect_ratio": "1:1",
    "callback_url": null,
    "character_ref": null,
    "generation_type": "image",
    "image_ref": null,
    "model": "photon-flash-1",
    "modify_image_ref": null,
    "prompt": "a red circle on a plain white background",
    "style_ref": null
  },
  "state": "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>
