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

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

`meshy/animations` の API リファレンス。Meshy から 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:** `meshy/animations`

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

<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(
              "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";

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

      console.log(data);
      ```

      ```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="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(
              "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)  # 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("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); // 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/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. 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/meshy/animations/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/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 が入力を拒否したことを意味します。生成されたアセットは [結果 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>
