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

# Swing Sketch を Comfy Router で使用する

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

`cartwheel/swing-sketch` の API リファレンスです。Comfy Router が Cartwheel から提供しています。

**入力:** テキスト · **出力:** 3D

## クイックスタート

[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:** `cartwheel/swing-sketch`

**エンドポイント:** `POST https://api.comfy.org/v2/models/cartwheel/swing-sketch`

> [tab] 結果を待つ
>
> ```python Python theme={null}
> from comfy_sdk import Comfy
>
> # 環境変数 COMFY_API_KEY を読み取ります。
> # SDK は冪等性キーを自動的に作成し、自動リトライ時に再利用します。
> with Comfy() as client:
>     result = client.models.run(
>         "cartwheel/swing-sketch",
>         {
>             "exportSettings": {
>                 "characterID": "char-upload-MHR",
>                 "exportType": "glb",
>                 "forward": "-Z",
>                 "frameRate": 30,
>                 "frameStepSize": 1,
>                 "up": "Y",
>             },
>             "prompts": ["a person waves with the right hand"],
>             "swingSketchProperties": {
>                 "duration": 4,
>             },
>         },
>     )
>
> print(result)
> ```
>
> ```typescript TypeScript theme={null}
> import { comfy } from "@comfyorg/sdk";
>
> // 環境変数 COMFY_API_KEY を読み取ります。
> // SDK は冪等性キーを自動的に作成し、自動リトライ時に再利用します。
> const { data } = await comfy.models.run("cartwheel/swing-sketch", {
>   exportSettings: {
>     characterID: "char-upload-MHR",
>     exportType: "glb",
>     forward: "-Z",
>     frameRate: 30,
>     frameStepSize: 1,
>     up: "Y",
>   },
>   prompts: ["a person waves with the right hand"],
>   swingSketchProperties: {
>     duration: 4,
>   },
> });
>
> console.log(data);
> ```
>
> ```bash cURL theme={null}
> curl https://api.comfy.org/v2/models/cartwheel/swing-sketch \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"exportSettings\": {\"characterID\":\"char-upload-MHR\",\"exportType\":\"glb\",\"forward\":\"-Z\",\"frameRate\":30,\"frameStepSize\":1,\"up\":\"Y\"}, \"prompts\": [\"a person waves with the right hand\"], \"swingSketchProperties\": {\"duration\":4}}"
> ```

> [tab] キューに送信して後で収集
>
> 同じボディを `POST https://api.comfy.org/v2/models/cartwheel/swing-sketch/requests` に送信します。Router は実行が受け付けられるとすぐに `request_id` とともに `201` を返し、結果は準備ができ次第、このプロセスまたは別のプロセスから収集されます。[キュー配信](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(
>             "cartwheel/swing-sketch",
>             {
>                 "exportSettings": {
>                     "characterID": "char-upload-MHR",
>                     "exportType": "glb",
>                     "forward": "-Z",
>                     "frameRate": 30,
>                     "frameStepSize": 1,
>                     "up": "Y",
>                 },
>                 "prompts": ["a person waves with the right hand"],
>                 "swingSketchProperties": {
>                     "duration": 4,
>                 },
>             },
>         )
>         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("cartwheel/swing-sketch", {
>   exportSettings: {
>     characterID: "char-upload-MHR",
>     exportType: "glb",
>     forward: "-Z",
>     frameRate: 30,
>     frameStepSize: 1,
>     up: "Y",
>   },
>   prompts: ["a person waves with the right hand"],
>   swingSketchProperties: {
>     duration: 4,
>   },
> });
> 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/cartwheel/swing-sketch/requests \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"exportSettings\": {\"characterID\":\"char-upload-MHR\",\"exportType\":\"glb\",\"forward\":\"-Z\",\"frameRate\":30,\"frameStepSize\":1,\"up\":\"Y\"}, \"prompts\": [\"a person waves with the right hand\"], \"swingSketchProperties\": {\"duration\":4}}"
>
> # 2. ステータスが COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After 秒を待ちます。
> REQUEST_ID="<request_id from the 201 body>"
> curl -i https://api.comfy.org/v2/models/cartwheel/swing-sketch/requests/$REQUEST_ID/status \
>   -H "X-API-Key: $COMFY_API_KEY"
>
> # 3. 収集。モデルのネイティブ出力とともに 200、実行中はステータス本文とともに 202 を返します。
> curl https://api.comfy.org/v2/models/cartwheel/swing-sketch/requests/$REQUEST_ID \
>   -H "X-API-Key: $COMFY_API_KEY"
> ```

## スキーマ

### 入力

**exportSettings** `object` *required*

生成されたモーションのエクスポート形式。

**exportSettings.characterID** `string` *required*

モーションをエクスポートする対象のキャラクター。例: `char-upload-MHR`。

**exportSettings.exportType** `string` *required*

エクスポート形式。例: `glb` または `fbx-blender`。

**exportSettings.forward** `string` *required*

前方軸。例: `-Z`。

**exportSettings.frameRate** `number` *required*

エクスポートのフレームレート。例: 24、30、60、120。

**exportSettings.frameStepSize** `number` *required*

フレームのステップサイズ。通常は1。

**exportSettings.includeMesh** `boolean`

エクスポートにキャラクターのメッシュを含めます。

**exportSettings.keyframeCleaning** `string`

`none`、`reduce`、`simplify` のいずれか。

**exportSettings.moveInPlace** `boolean`

キャラクターをその場に留めます。

**exportSettings.restPose** `boolean`

レストポーズをフレーム0として先頭に追加します。デフォルトはtrue。

**exportSettings.up** `string` *required*

上方向の軸。例: `Y`。

**loop** `boolean`

モーションをループします。デフォルトはfalse。

**prompts** `string[]` *required*

空白以外の文字を少なくとも1つ含むプロンプトをちょうど1つ指定します。

**requestedModel** `string`

Comfy Router を使用する場合は省略するかnullを送信します。モデルIDで `swing_sketch` が選択されます。

**swingSketchProperties** `object` *required*

Swing Sketchの設定。

**swingSketchProperties.cfgScale** `number`

プロンプトのガイダンス。1～9。デフォルトは7.5。

範囲: `1` ～ `9`

**swingSketchProperties.duration** `integer` *required*

モーションの長さを整数秒で指定。3～8。

範囲: `3` ～ `8`

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

### 出力

**items** `object[]`

アクターのエクスポートを伴う、1つの生成済みモーション。

**items\[].cameraFbxURL** `string`

キャプチャされたカメラのFBX。1時間有効。

**items\[].durationSeconds** `number`

予定されているSwing Choreoシーンの長さ（秒）。例: 7.416667。要求した再生時間と異なる場合があります。

**items\[].errorMessage** `string`

**items\[].exportFilenames** `string[]`

**items\[].exportURLs** `string[]`

アクターごとに1つのエクスポート。アクターの順序に従います。1時間有効。

**items\[].jobID** `string`

**items\[].outputs** `object[]`

Swing Choreoのアクターを順序どおりに並べたもの。

**items\[].outputs\[].actorIndex** `integer`

**items\[].outputs\[].bvhURL** `string`

**items\[].outputs\[].exportFilename** `string`

**items\[].outputs\[].exportURL** `string`

**items\[].outputs\[].mhrFbxURL** `string`

**items\[].sourceVideoMediaID** `string`

**items\[].status** `string`

`QUEUED`、`GENERATING`、`COMPLETED`、`FAILED`、`FLAGGED` のいずれか。

**items\[].studioPreviewURL** `string`

MP4プレビュー。12時間有効。

**items\[].title** `string`

**nextToken** `string`

さらにページが存在する場合に含まれます。

## 例

### 入力

```json theme={null}
{
  "exportSettings": {
    "characterID": "char-upload-MHR",
    "exportType": "glb",
    "forward": "-Z",
    "frameRate": 30,
    "frameStepSize": 1,
    "up": "Y"
  },
  "prompts": [
    "a person waves with the right hand"
  ],
  "swingSketchProperties": {
    "duration": 4
  }
}
```

### 出力

```json theme={null}
{
  "items": [
    {
      "exportFilenames": [
        "actor0.glb"
      ],
      "exportURLs": [
        "https://example.invalid/cartwheel/actor0.glb"
      ],
      "jobID": "job-1",
      "status": "COMPLETED",
      "studioPreviewURL": "https://example.invalid/cartwheel/preview.mp4",
      "title": "a person waves with the right hand"
    }
  ]
}
```

## 出荷前の確認

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.