> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-mintlify-theme-mint.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Gemini Omni Flash Preview を使用する

> Comfy Router 経由で gemini-interactions/gemini-omni-flash-preview を呼び出す方法: エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`gemini-interactions/gemini-omni-flash-preview` の API リファレンス。Comfy Router が Gemini Interactions から提供します。

## クイックスタート

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

**モデル ID:** `gemini-interactions/gemini-omni-flash-preview`

**エンドポイント:** `POST https://api.comfy.org/v2/models/gemini-interactions/gemini-omni-flash-preview`

<Tabs>
  <Tab title="結果を待つ">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 環境変数から COMFY_API_KEY を読み取ります。
      # SDK は冪等性キーを自動的に作成し、自動リトライのために再利用します。
      with Comfy() as client:
          result = client.models.run(
              "gemini-interactions/gemini-omni-flash-preview",
              {
                  "input": "Reply with the single word: ok",
                  "stream": False,
              },
          )

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は冪等性キーを自動的に作成し、自動リトライのために再利用します。
      const { data } = await comfy.models.run("gemini-interactions/gemini-omni-flash-preview", {
        input: "Reply with the single word: ok",
        stream: false,
      });

      console.log(data);
      ```

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は呼び出しごとに冪等性キーを発行し、自動リトライのために再利用します。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let result = try await client.models.run(
          "gemini-interactions/gemini-omni-flash-preview",
          input: [
              "input": "Reply with the single word: ok",
              "stream": false,
          ]
      )

      print(result.output)
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/gemini-interactions/gemini-omni-flash-preview \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": \"Reply with the single word: ok\", \"stream\": false}"
      ```
    </CodeGroup>
  </Tab>

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

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

      # 環境変数から COMFY_API_KEY を読み取ります。
      # submit() 呼び出しごとに独自の Idempotency-Key を発行し、自動リトライで再利用します。
      with Comfy() as client:
          handle = client.models.submit(
              "gemini-interactions/gemini-omni-flash-preview",
              {
                  "input": "Reply with the single word: ok",
                  "stream": False,
              },
          )
          print("request_id:", handle.request_id)  # モデル ID と合わせれば、別のプロセスに必要な情報はこれだけです

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

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

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // submit() 呼び出しごとに独自の Idempotency-Key を発行し、自動リトライで再利用します。
      const handle = await comfy.models.submit("gemini-interactions/gemini-omni-flash-preview", {
        input: "Reply with the single word: ok",
        stream: false,
      });
      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);
      ```

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 環境変数から COMFY_API_KEY を読み取ります。
      // submit() 呼び出しごとに独自の Idempotency-Key を発行し、自動リトライで再利用します。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let handle = try await client.models.submit(
          "gemini-interactions/gemini-omni-flash-preview",
          input: [
              "input": "Reply with the single word: ok",
              "stream": false,
          ]
      )
      print("requestId:", handle.requestId)  // モデル ID と合わせれば、別のプロセスに必要な情報はこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After だけ待機します。
      for try await update in handle.events() {
          print(update.state.rawValue, update.queuePosition.map(String.init) ?? "unknown")
      }

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

      print(result.output)
      ```

      ```bash cURL theme={null}
      # 1. 送信。Router は request_id、status_url、response_url、cancel_url とともに 201 を返します。
      curl https://api.comfy.org/v2/models/gemini-interactions/gemini-omni-flash-preview/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": \"Reply with the single word: ok\", \"stream\": false}"

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

      # 3. 取得。実行中は 202 とステータスボディ、完了時は 200 とモデルのネイティブ出力を返します。
      curl https://api.comfy.org/v2/models/gemini-interactions/gemini-omni-flash-preview/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="input" type="object" required>
  プロンプト文字列、または型付きコンテンツパーツ（text、image、audio、video、document）の配列のいずれか。
</ParamField>

<ParamField body="model" type="string">
  Gemini モデル識別子: `gemini-omni-1.1-flash`（一般提供）、または非推奨の `gemini-omni-flash-preview`。Comfy Router のルート `POST /v2/models/gemini-interactions/{model}` ではパスから指定されるため、省略できます。このオペレーションが対応するのはこれら 2 つの表記（Comfy Router が `gemini-interactions/<model>` として扱う集合、supportedGeminiInteractionModels）です。ここでは enum で制約するのではなく列挙しています。プロキシ自身がモデルを検証し、対応していない表記に対しては独自の 400 を返すためです。
</ParamField>

<ParamField body="previous_interaction_id" type="string">
  以前に保存された interaction の ID。ステートフルなマルチターンのビデオ編集を可能にします。
</ParamField>

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

### 出力

<ResponseField name="id" type="string" />

<ResponseField name="model" type="string" />

<ResponseField name="object" type="string" />

<ResponseField name="status" type="string" required>
  Router のレスポンスでは常に `completed` です。プロバイダーのその他のステータス（`in_progress`、`requires_action`、`failed`、`cancelled`、`incomplete`、`budget_exceeded`）が Router を通じて呼び出し元に 200 として届くことはありません。これらはプロバイダーのボディを含む Comfy Router エラーとして返されます。

  指定可能な値: `completed`
</ResponseField>

<ResponseField name="steps" type="object[]" required>
  interaction のタイムラインを順序どおりに示します。ここでは出力のリーフを参照可能にするため、`GeminiInteraction` の型なしの `steps` から絞り込んでいます。プロバイダーはステップ種別を追加し続けるため、各項目は `additionalProperties: true` であり、Router の呼び出し元が読むフィールドのみを宣言しています。
</ResponseField>

<ResponseField name="steps[].content" type="object[]">
  このステップの型付きコンテンツブロック。
</ResponseField>

<ResponseField name="steps[].content[].data" type="string">
  インラインで配信されるメディアブロックにおける、Base64 エンコードされたインラインメディア。Google はインラインメディアを 4 MB までに制限しており、それを超える場合は `delivery: uri` を必須とします。
</ResponseField>

<ResponseField name="steps[].content[].mime_type" type="string">
  メディアブロックにおける `data` または `uri` のメディアタイプ。
</ResponseField>

<ResponseField name="steps[].content[].text" type="string">
  生成されたテキスト。`text` ブロックに存在し、ナイトリーの Router SDK ケースが検証するリーフでもあります。具体的には `model_output` ステップ上です（`steps[type=model_output].content[].text`）。
</ResponseField>

<ResponseField name="steps[].content[].type" type="string">
  ブロック種別: `text`、`image`、`audio`、`video`、`document`。
</ResponseField>

<ResponseField name="steps[].content[].uri" type="string">
  帯域外で配信されるメディアへの参照。呼び出し元が、それが示す URI から取得します。
</ResponseField>

<ResponseField name="steps[].type" type="string">
  ステップ種別。`model_output` は生成された回答、`user_input` は取得ルートがそのまま返す呼び出し元自身のターン、`thought` は内部推論です。ツールのステップ（`function_call`、`function_result`、`code_execution_call`、`google_search_call` など）は拡張可能で、Google が随時追加しています。
</ResponseField>

<ResponseField name="usage" type="object">
  Gemini interaction のトークン使用量。
</ResponseField>

<ResponseField name="usage.input_tokens_by_modality" type="object[]">
  1 つのモダリティあたりのトークン数。
</ResponseField>

<ResponseField name="usage.input_tokens_by_modality[].modality" type="string">
  `text`、`image`、`audio`、`video`、`document` のいずれか。
</ResponseField>

<ResponseField name="usage.input_tokens_by_modality[].tokens" type="integer" />

<ResponseField name="usage.output_tokens_by_modality" type="object[]">
  1 つのモダリティあたりのトークン数。
</ResponseField>

<ResponseField name="usage.output_tokens_by_modality[].modality" type="string">
  `text`、`image`、`audio`、`video`、`document` のいずれか。
</ResponseField>

<ResponseField name="usage.output_tokens_by_modality[].tokens" type="integer" />

<ResponseField name="usage.total_cached_tokens" type="integer" />

<ResponseField name="usage.total_input_tokens" type="integer" />

<ResponseField name="usage.total_output_tokens" type="integer" />

<ResponseField name="usage.total_thought_tokens" type="integer" />

<ResponseField name="usage.total_tokens" type="integer" />

## 例

### 入力

```json theme={null}
{
  "input": "Reply with the single word: ok",
  "stream": false
}
```

### 出力

```json theme={null}
{
  "id": "interactions/3f6c1a90-2b47-4d18-9a55-7c0e8b21d4f3",
  "object": "interaction",
  "status": "completed",
  "steps": [
    {
      "content": [
        {
          "text": "ok",
          "type": "text"
        }
      ],
      "type": "model_output"
    }
  ],
  "usage": {
    "input_tokens_by_modality": [
      {
        "modality": "text",
        "tokens": 9
      }
    ],
    "output_tokens_by_modality": [
      {
        "modality": "text",
        "tokens": 2
      }
    ],
    "total_cached_tokens": 0,
    "total_input_tokens": 9,
    "total_output_tokens": 2,
    "total_thought_tokens": 0,
    "total_tokens": 11
  }
}
```

## 出荷前の確認

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

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

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

このページは、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) を参照してください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/headers">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/api">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
