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

> Comfy Router 経由で meshy/animations を呼び出す: エンドポイント、リクエストの形状、Router が返すレスポンス。

`meshy/animations` の API リファレンス。Meshy から Comfy Router が提供します。

## クイックスタート

キーを [お使いの 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:** `meshy/animations`

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

<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(
              "meshy/animations",
              {
                  "action_id": 92,
                  "post_process": {
                      "fps": 60,
                      "operation_type": "change_fps",
                  },
                  "rig_task_id": "0193abcd-0000-0000-0000-000000000000",
              },
          )

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は冪等キーを自動的に作成し、自動リトライのために再利用します。
      const { data } = await comfy.models.run("meshy/animations", {
        action_id: 92,
        post_process: {
          fps: 60,
          operation_type: "change_fps",
        },
        rig_task_id: "0193abcd-0000-0000-0000-000000000000",
      });

      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(
          "meshy/animations",
          input: [
              "action_id": 92,
              "post_process": [
                  "fps": 60,
                  "operation_type": "change_fps",
              ],
              "rig_task_id": "0193abcd-0000-0000-0000-000000000000",
          ]
      )

      print(result.output)
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/meshy/animations \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"action_id\": 92, \"post_process\": {\"fps\":60,\"operation_type\":\"change_fps\"}, \"rig_task_id\": \"0193abcd-0000-0000-0000-000000000000\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="キューに送信して後で収集">
    同じボディを `POST https://api.comfy.org/v2/models/meshy/animations/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(
              "meshy/animations",
              {
                  "action_id": 92,
                  "post_process": {
                      "fps": 60,
                      "operation_type": "change_fps",
                  },
                  "rig_task_id": "0193abcd-0000-0000-0000-000000000000",
              },
          )
          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("meshy/animations", {
        action_id: 92,
        post_process: {
          fps: 60,
          operation_type: "change_fps",
        },
        rig_task_id: "0193abcd-0000-0000-0000-000000000000",
      });
      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(
          "meshy/animations",
          input: [
              "action_id": 92,
              "post_process": [
                  "fps": 60,
                  "operation_type": "change_fps",
              ],
              "rig_task_id": "0193abcd-0000-0000-0000-000000000000",
          ]
      )
      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/meshy/animations/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"action_id\": 92, \"post_process\": {\"fps\":60,\"operation_type\":\"change_fps\"}, \"rig_task_id\": \"0193abcd-0000-0000-0000-000000000000\"}"

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

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

## スキーマ

### 入力

<ParamField body="action_id" type="integer" required>
  適用するアニメーションアクションの識別子。
</ParamField>

<ParamField body="post_process" type="object">
  アニメーションファイルのポストプロセス用パラメータ。
</ParamField>

<ParamField body="post_process.fps" type="integer" default="30">
  ターゲットフレームレート。デフォルトは 30 です。operation\_type が change\_fps の場合にのみ適用されます。

  指定可能な値: `24`、`25`、`30`、`60`
</ParamField>

<ParamField body="post_process.operation_type" type="string" required>
  実行する操作の種類。

  指定可能な値: `change_fps`、`fbx2usdz`、`extract_armature`
</ParamField>

<ParamField body="rig_task_id" type="string" required>
  正常に完了したリグタスクの ID（POST /openapi/v1/rigging から取得）。このタスクのキャラクターがアニメートされます。
</ParamField>

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

### 出力

<ResponseField name="created_at" type="integer">
  タスクが作成されたときのタイムスタンプ（ミリ秒単位）。

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

<ResponseField name="expires_at" type="integer">
  タスク結果の有効期限のタイムスタンプ（ミリ秒単位）。

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

<ResponseField name="finished_at" type="integer">
  タスクが完了したときのタイムスタンプ（ミリ秒単位）。完了していない場合は 0。

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

<ResponseField name="id" type="string" required>
  タスクの一意の識別子。
</ResponseField>

<ResponseField name="preceding_tasks" type="integer">
  先行するタスクの数。status が PENDING の場合にのみ意味を持ちます。
</ResponseField>

<ResponseField name="progress" type="integer">
  タスクの進捗（0-100）。

  範囲: `0` から `100`
</ResponseField>

<ResponseField name="result" type="object">
  タスクが SUCCEEDED の場合、出力アニメーションの URL を含みます。
</ResponseField>

<ResponseField name="result.animation_fbx_url" type="string">
  FBX 形式のアニメーションのダウンロード可能な URL。
</ResponseField>

<ResponseField name="result.animation_glb_url" type="string">
  GLB 形式のアニメーションのダウンロード可能な URL。
</ResponseField>

<ResponseField name="result.processed_animation_fps_fbx_url" type="string">
  FPS を変更したアニメーションの FBX 形式のダウンロード可能な URL。
</ResponseField>

<ResponseField name="result.processed_armature_fbx_url" type="string">
  処理済みのアーマチュアの FBX 形式のダウンロード可能な URL。
</ResponseField>

<ResponseField name="result.processed_usdz_url" type="string">
  処理済みのアニメーションの USDZ 形式のダウンロード可能な URL。
</ResponseField>

<ResponseField name="started_at" type="integer">
  タスクが開始されたときのタイムスタンプ（ミリ秒単位）。開始されていない場合は 0。

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

<ResponseField name="status" type="string" required>
  指定可能な値: `SUCCEEDED`
</ResponseField>

<ResponseField name="task_error" type="object">
  タスクが失敗した場合にエラーメッセージを含むエラーオブジェクト。
</ResponseField>

<ResponseField name="task_error.message" type="string">
  詳細なエラーメッセージ。
</ResponseField>

<ResponseField name="type" type="string">
  アニメーションタスクのタイプ。

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

## 例

### 入力

```json theme={null}
{
  "action_id": 92,
  "post_process": {
    "fps": 60,
    "operation_type": "change_fps"
  },
  "rig_task_id": "0193abcd-0000-0000-0000-000000000000"
}
```

### 出力

```json theme={null}
{
  "created_at": 1767225600000,
  "expires_at": 1767830400000,
  "finished_at": 1767225648000,
  "id": "018f2c7a-4b1e-7c3d-9a05-6e2f8b41d0c9",
  "progress": 100,
  "result": {
    "animation_fbx_url": "https://example.invalid/meshy/animations/animation.fbx",
    "animation_glb_url": "https://example.invalid/meshy/animations/animation.glb"
  },
  "started_at": 1767225601000,
  "status": "SUCCEEDED",
  "type": "animate"
}
```

## 出荷前の確認

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>
