> ## 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.

# Jev 1.13.0 を Comfy Router で使用する

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

`typesafe/jev-1.13.0` の API リファレンスです。Comfy Router が Typesafe から提供します。

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

## クイックスタート

[ご自身の 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 のスニペットは、同じ呼び出しを生の HTTP で行うものです。

**モデル ID:** `typesafe/jev-1.13.0`

**エンドポイント:** `POST https://api.comfy.org/v2/models/typesafe/jev-1.13.0`

> [tab] 結果を待つ
>
> ```python Python theme={null}
> from comfy_sdk import Comfy
>
> # 環境変数から COMFY_API_KEY を読み取ります。
> # SDK は自動的に冪等性キーを作成し、自動再試行時に再利用します。
> with Comfy() as client:
>     result = client.models.run(
>         "typesafe/jev-1.13.0",
>         {
>             "questions": {
>                 "department": {
>                     "criteria": {
>                         "billing": "Payments, invoicing, refunds",
>                         "technical": "Bugs, outages, integrations",
>                     },
>                     "instructions": "Which team should handle this?",
>                     "type": "choice",
>                 },
>                 "is_urgent": {
>                     "instructions": "Does this convey urgency?",
>                     "type": "noul",
>                 },
>             },
>             "state": "Help! My payouts have been failing for 3 days.",
>         },
>     )
>
> print(result)
> ```
>
> ```typescript TypeScript theme={null}
> import { comfy } from "@comfyorg/sdk";
>
> // 環境変数から COMFY_API_KEY を読み取ります。
> // SDK は自動的に冪等性キーを作成し、自動再試行時に再利用します。
> const { data } = await comfy.models.run("typesafe/jev-1.13.0", {
>   questions: {
>     department: {
>       criteria: {
>         billing: "Payments, invoicing, refunds",
>         technical: "Bugs, outages, integrations",
>       },
>       instructions: "Which team should handle this?",
>       type: "choice",
>     },
>     is_urgent: {
>       instructions: "Does this convey urgency?",
>       type: "noul",
>     },
>   },
>   state: "Help! My payouts have been failing for 3 days.",
> });
>
> console.log(data);
> ```
>
> ```bash cURL theme={null}
> curl https://api.comfy.org/v2/models/typesafe/jev-1.13.0 \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"questions\": {\"department\":{\"criteria\":{\"billing\":\"Payments, invoicing, refunds\",\"technical\":\"Bugs, outages, integrations\"},\"instructions\":\"Which team should handle this?\",\"type\":\"choice\"},\"is_urgent\":{\"instructions\":\"Does this convey urgency?\",\"type\":\"noul\"}}, \"state\": \"Help! My payouts have been failing for 3 days.\"}"
> ```

> [tab] キューに送信して後で収集
>
> 同じボディを `POST https://api.comfy.org/v2/models/typesafe/jev-1.13.0/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備ができ次第、このプロセスまたは別のプロセスから収集します。[キュー配信](https://docs.comfy.org/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(
>             "typesafe/jev-1.13.0",
>             {
>                 "questions": {
>                     "department": {
>                         "criteria": {
>                             "billing": "Payments, invoicing, refunds",
>                             "technical": "Bugs, outages, integrations",
>                         },
>                         "instructions": "Which team should handle this?",
>                         "type": "choice",
>                     },
>                     "is_urgent": {
>                         "instructions": "Does this convey urgency?",
>                         "type": "noul",
>                     },
>                 },
>                 "state": "Help! My payouts have been failing for 3 days.",
>             },
>         )
>         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("typesafe/jev-1.13.0", {
>   questions: {
>     department: {
>       criteria: {
>         billing: "Payments, invoicing, refunds",
>         technical: "Bugs, outages, integrations",
>       },
>       instructions: "Which team should handle this?",
>       type: "choice",
>     },
>     is_urgent: {
>       instructions: "Does this convey urgency?",
>       type: "noul",
>     },
>   },
>   state: "Help! My payouts have been failing for 3 days.",
> });
> 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/typesafe/jev-1.13.0/requests \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"questions\": {\"department\":{\"criteria\":{\"billing\":\"Payments, invoicing, refunds\",\"technical\":\"Bugs, outages, integrations\"},\"instructions\":\"Which team should handle this?\",\"type\":\"choice\"},\"is_urgent\":{\"instructions\":\"Does this convey urgency?\",\"type\":\"noul\"}}, \"state\": \"Help! My payouts have been failing for 3 days.\"}"
>
> # 2. status が COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After の秒数だけ待機します。
> REQUEST_ID="<request_id from the 201 body>"
> curl -i https://api.comfy.org/v2/models/typesafe/jev-1.13.0/requests/$REQUEST_ID/status \
>   -H "X-API-Key: $COMFY_API_KEY"
>
> # 3. 収集。200 はモデルネイティブの出力、実行中は 202 とステータスボディを返します。
> curl https://api.comfy.org/v2/models/typesafe/jev-1.13.0/requests/$REQUEST_ID \
>   -H "X-API-Key: $COMFY_API_KEY"
> ```

## スキーマ

### 入力

**assets** `object`

リクエスト内の画像。参照文字列をキーとします。すべての参照は `state`、`instructions`、`criteria` のいずれかに現れる必要があります。各画像は一辺 280～1568 ピクセル、デコード後 16 MiB 以下の静止 PNG または JPEG です。TypeSafe は合計 32 MiB を超える呼び出しを拒否します。

**model** `string`

ピン留めされた Jev バージョン。任意: Router はパス内のモデル ID からこれを設定します。`jev-latest` と `jev-preview` のエイリアスは受け付けられません。

**questions** `object` *required*

回答する質問。任意の ID をキーとして指定します。各質問への回答は同じ ID の下に返されます。

**state** `object` *required*

評価するコンテンツ: 文字列、または最大 64 階層までの構造化データ (オブジェクトまたは配列)。その中のどこかにあるアセット参照は、その画像に置き換えられます。

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

### 出力

**answers** `object` *required*

質問ごとに 1 つの回答。送信した質問 ID をキーとします。

**model** `string` *required*

回答した Jev バージョン (例: `jev-1.14.0`)。

**usage** `object`

リクエストのトークン使用量。

**usage.input\_tokens** `integer`

入力トークン。リクエスト内のすべての画像を含みます。

**usage.output\_tokens** `integer`

出力トークン。

## 例

### 入力

```json theme={null}
{
  "questions": {
    "department": {
      "criteria": {
        "billing": "Payments, invoicing, refunds",
        "technical": "Bugs, outages, integrations"
      },
      "instructions": "Which team should handle this?",
      "type": "choice"
    },
    "is_urgent": {
      "instructions": "Does this convey urgency?",
      "type": "noul"
    }
  },
  "state": "Help! My payouts have been failing for 3 days."
}
```

### 出力

```json theme={null}
{
  "answers": {
    "is_urgent": {
      "noul": 0.95,
      "type": "noul"
    },
    "mug": {
      "box": {
        "bottom": 0.82,
        "left": 0.44,
        "right": 0.84,
        "top": 0.25
      },
      "confidence": 0.92,
      "type": "box"
    }
  },
  "model": "jev-1.14.0",
  "usage": {
    "input_tokens": 290,
    "output_tokens": 21
  }
}
```

## 出荷前の確認

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

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

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

> [card] [ヘッダー](https://docs.comfy.org/ja/development/comfy-router/headers.md)
>
> 認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。

> [card] [Router API の利用](https://docs.comfy.org/ja/development/comfy-router/api.md)
>
> モデルの検出、バリデーションエラー、リトライ、課金。

> [card] [制限事項](https://docs.comfy.org/ja/development/comfy-router/limitations.md)
>
> Router が現在対応していないことと、代替手段。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.