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

> Comfy Routerを通じてmeshy/remeshを呼び出す方法: エンドポイント、リクエスト形状、Routerが返すレスポンス。

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

## クイックスタート

[お使いの Comfy ワークスペース](https://platform.comfy.org/profile/api-keys)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）を使用しています。cURL のスニペットは、同じ呼び出しを raw HTTP で行うものです。

**モデル ID:** `meshy/remesh`

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

<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/remesh",
              {
                  "input_task_id": "0193abcd-0000-0000-0000-000000000000",
                  "origin_at": "bottom",
                  "resize_height": 1,
                  "target_formats": ["glb", "fbx"],
                  "target_polycount": 50000,
                  "topology": "quad",
              },
          )

      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/remesh", {
        input_task_id: "0193abcd-0000-0000-0000-000000000000",
        origin_at: "bottom",
        resize_height: 1,
        target_formats: ["glb", "fbx"],
        target_polycount: 50000,
        topology: "quad",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/meshy/remesh \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input_task_id\": \"0193abcd-0000-0000-0000-000000000000\", \"origin_at\": \"bottom\", \"resize_height\": 1, \"target_formats\": [\"glb\",\"fbx\"], \"target_polycount\": 50000, \"topology\": \"quad\"}"
      ```
    </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/remesh",
              {
                  "input_task_id": "0193abcd-0000-0000-0000-000000000000",
                  "origin_at": "bottom",
                  "resize_height": 1,
                  "target_formats": ["glb", "fbx"],
                  "target_polycount": 50000,
                  "topology": "quad",
              },
          )
          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/remesh", {
        input_task_id: "0193abcd-0000-0000-0000-000000000000",
        origin_at: "bottom",
        resize_height: 1,
        target_formats: ["glb", "fbx"],
        target_polycount: 50000,
        topology: "quad",
      });
      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/remesh/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input_task_id\": \"0193abcd-0000-0000-0000-000000000000\", \"origin_at\": \"bottom\", \"resize_height\": 1, \"target_formats\": [\"glb\",\"fbx\"], \"target_polycount\": 50000, \"topology\": \"quad\"}"

      # 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/remesh/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/remesh/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="convert_format_only" type="boolean" default="false">
  true の場合、入力モデルファイルの形式のみを変更し、トポロジー、resize\_height、target\_polycount などの他の入力は無視されます。
</ParamField>

<ParamField body="input_task_id" type="string">
  リメッシュしたい完了済みの Image to 3D または Text to 3D タスクの ID。model\_url が指定されていない場合に必須です。
</ParamField>

<ParamField body="model_url" type="string">
  3Dモデルへの公開アクセス可能な URL または data URI。対応形式は glb、gltf、obj、fbx、stl。input\_task\_id が指定されていない場合に必須です。
</ParamField>

<ParamField body="origin_at" type="string">
  原点の位置。

  指定可能な値: `bottom`、`center`、\`\`
</ParamField>

<ParamField body="resize_height" type="number" default="0">
  モデルをメートル単位で指定した高さにリサイズします。0 はリサイズなしを意味します。
</ParamField>

<ParamField body="target_formats" type="`glb`, `fbx`, `obj`, `usdz`, `blend`, `stl`[]" default="[&#x22;glb&#x22;]">
  リメッシュされたモデルのターゲット形式のリスト。
</ParamField>

<ParamField body="target_polycount" type="integer" default="30000">
  生成されるモデルのポリゴン数のターゲットを指定します。有効範囲は 100 から 300,000 です。

  範囲: `100` から `300000`
</ParamField>

<ParamField body="topology" type="string" default="&#x22;triangle&#x22;">
  生成されるモデルのトポロジーを指定します。

  指定可能な値: `quad`、`triangle`
</ParamField>

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

### 出力

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

  形式: `int64`
</ResponseField>

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

  形式: `int64`
</ResponseField>

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

<ResponseField name="model_urls" type="object">
  リメッシュされた 3Dモデルファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.blend" type="string">
  Blender ファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.fbx" type="string">
  FBX ファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.glb" type="string">
  GLB ファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.obj" type="string">
  OBJ ファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.stl" type="string">
  STL ファイルのダウンロード URL。
</ResponseField>

<ResponseField name="model_urls.usdz" type="string">
  USDZ ファイルのダウンロード URL。
</ResponseField>

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

<ResponseField name="progress" type="integer">
  タスクの進捗。未開始の場合は 0、成功時は 100。

  範囲: `0` から `100`
</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">
  Remesh タスクのタイプ。

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

## 例

### 入力

```json theme={null}
{
  "input_task_id": "0193abcd-0000-0000-0000-000000000000",
  "origin_at": "bottom",
  "resize_height": 1,
  "target_formats": [
    "glb",
    "fbx"
  ],
  "target_polycount": 50000,
  "topology": "quad"
}
```

### 出力

```json theme={null}
{
  "created_at": 1767225600000,
  "finished_at": 1767225663000,
  "id": "018f2c7a-4b1e-7c3d-9a05-6e2f8b41d0c9",
  "model_urls": {
    "fbx": "https://example.invalid/meshy/remesh/model.fbx",
    "glb": "https://example.invalid/meshy/remesh/model.glb",
    "obj": "https://example.invalid/meshy/remesh/model.obj"
  },
  "progress": 100,
  "started_at": 1767225601000,
  "status": "SUCCEEDED",
  "type": "remesh"
}
```

## 出荷前の確認

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>
