> ## 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 で Claude Opus 5.5 を使う

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

`anthropic/claude-opus-5-5` の API リファレンスです。これは Anthropic から Comfy Router によって提供されます。

## クイックスタート

[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:** `anthropic/claude-opus-5-5`

**エンドポイント:** `POST https://api.comfy.org/v2/models/anthropic/claude-opus-5-5`

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

      # 環境変数から COMFY_API_KEY を読み取ります。
      # SDK は冪等性キーを自動的に作成し、自動リトライ時に再利用します。
      with Comfy() as client:
          result = client.models.run(
              "anthropic/claude-opus-5-5",
              {
                  "max_tokens": 16,
                  "messages": [
                      {
                          "content": "Reply with the single word: ok",
                          "role": "user",
                      },
                  ],
              },
          )

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は冪等性キーを自動的に作成し、自動リトライ時に再利用します。
      const { data } = await comfy.models.run("anthropic/claude-opus-5-5", {
        max_tokens: 16,
        messages: [
          {
            content: "Reply with the single word: ok",
            role: "user",
          },
        ],
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/anthropic/claude-opus-5-5 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="キューに送信して後で収集する">
    同じボディを `POST https://api.comfy.org/v2/models/anthropic/claude-opus-5-5/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備ができ次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集の流れを順に説明します。

    <CodeGroup>
      ```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(
                  "anthropic/claude-opus-5-5",
                  {
                      "max_tokens": 16,
                      "messages": [
                          {
                              "content": "Reply with the single word: ok",
                              "role": "user",
                          },
                      ],
                  },
              )
              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("anthropic/claude-opus-5-5", {
        max_tokens: 16,
        messages: [
          {
            content: "Reply with the single word: ok",
            role: "user",
          },
        ],
      });
      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/anthropic/claude-opus-5-5/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"max_tokens\": 16, \"messages\": [{\"content\":\"Reply with the single word: ok\",\"role\":\"user\"}]}"

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

      # 3. 収集。200 はモデルのネイティブ出力を、202 はまだ実行中の場合にステータスボディを返します。
      curl https://api.comfy.org/v2/models/anthropic/claude-opus-5-5/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="max_tokens" type="integer" required>
  停止する前に生成するトークンの最大数。
</ParamField>

<ParamField body="messages" type="object[]" required>
  会話のターン。コンテンツブロックの分類の全体については、Anthropic Messages API のドキュメントを参照してください。
</ParamField>

<ParamField body="messages[].content" type="object" required>
  文字列の省略形、またはコンテンツブロックの配列（text、image、document、tool\_use、tool\_result、...）のいずれか。
</ParamField>

<ParamField body="messages[].role" type="string" required>
  指定可能な値: `user`、`assistant`
</ParamField>

<ParamField body="model" type="string">
  Anthropic のモデル識別子（例: `claude-sonnet-4-5`、`claude-opus-4-7`）。
</ParamField>

<ParamField body="stream" type="boolean">
  true の場合、レスポンスは単一の JSON ボディではなく、Anthropic のメッセージイベントの `text/event-stream` になります。
</ParamField>

<ParamField body="system" type="object">
  トップレベルのシステムプロンプト。文字列またはコンテンツブロックの配列のいずれかで、どちらもそのまま Anthropic に渡されます。
</ParamField>

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

### 出力

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

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

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

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

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

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

<ResponseField name="usage" type="object">
  Anthropic Messages API 呼び出しのトークン使用量。
</ResponseField>

<ResponseField name="usage.cache_creation" type="object">
  Anthropic Messages API 呼び出しにおける、キャッシュ書き込み入力トークンの TTL 別内訳。
</ResponseField>

<ResponseField name="usage.cache_creation.ephemeral_1h_input_tokens" type="integer" />

<ResponseField name="usage.cache_creation.ephemeral_5m_input_tokens" type="integer" />

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

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

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

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

<ResponseField name="content" type="object[]" required>
  返信のコンテンツブロックを順序どおりに並べたもの。完了したすべてのメッセージに含まれ、ターンが何も生成しなかった場合は空になります。
</ResponseField>

<ResponseField name="content[].text" type="string">
  ブロックのテキスト。`text` ブロックに含まれ、それ以外の種類には含まれません。
</ResponseField>

<ResponseField name="content[].type" type="string">
  ブロックの種類。`text` は `text` を持つ唯一の種類です。`thinking`、`redacted_thinking`、`tool_use`、`server_tool_use` およびツール結果ブロックは、現在 Anthropic が送信するその他の種類であり、このリストは開かれています。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "max_tokens": 16,
  "messages": [
    {
      "content": "Reply with the single word: ok",
      "role": "user"
    }
  ]
}
```

### 出力

```json theme={null}
{
  "content": [
    {
      "text": "ok",
      "type": "text"
    }
  ],
  "id": "msg_01ExampleInvalidPlaceholder",
  "model": "claude-opus-5-5",
  "role": "assistant",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "type": "message",
  "usage": {
    "input_tokens": 16,
    "output_tokens": 3
  }
}
```

## 出荷前の確認

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>
