> ## 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 使用混元3D智能拓扑

> 通过 Comfy Router 调用 tencent/hunyuan-3d-smart-topology：端点、请求形状以及 Router 返回的响应。

`tencent/hunyuan-3d-smart-topology` 的 API 参考，由 Comfy Router 提供，模型来源为 Tencent。

## 快速开始

在[你的 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：** `tencent/hunyuan-3d-smart-topology`

**端点：** `POST https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology`

<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(
              "tencent/hunyuan-3d-smart-topology",
              {
                  "File3D": {
                      "Type": "GLB",
                      "Url": "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
                  },
              },
          )

      print(result)
      ```

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

      // 从环境变量中读取 COMFY_API_KEY。
      // SDK 会自动创建幂等键，并在自动重试时复用它。
      const { data } = await comfy.models.run("tencent/hunyuan-3d-smart-topology", {
        File3D: {
          Type: "GLB",
          Url: "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
        },
      });

      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(
          "tencent/hunyuan-3d-smart-topology",
          input: [
              "File3D": [
                  "Type": "GLB",
                  "Url": "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
              ],
          ]
      )

      print(result.output)
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"File3D\": {\"Type\":\"GLB\",\"Url\":\"https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb\"}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="排队并稍后收集">
    将相同的请求体发送到 `POST https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology/requests`。运行被受理后，Router 会立即返回 `201` 和 `request_id`；结果就绪后，可以从本进程或其他进程收集。状态、取消与收集的细节见 [队列投递](/zh/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(
              "tencent/hunyuan-3d-smart-topology",
              {
                  "File3D": {
                      "Type": "GLB",
                      "Url": "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
                  },
              },
          )
          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("tencent/hunyuan-3d-smart-topology", {
        File3D: {
          Type: "GLB",
          Url: "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
        },
      });
      console.log("requestId:", handle.requestId); // 配合模型 ID，这就是另一个进程所需的全部信息

      // 轮询直到请求完成，按服务器指定的 Retry-After 等待。
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // 与 models.run() 返回的结果相同。失败或已取消的请求会在此处被拒绝。
      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(
          "tencent/hunyuan-3d-smart-topology",
          input: [
              "File3D": [
                  "Type": "GLB",
                  "Url": "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb",
              ],
          ]
      )
      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 返回 201，以及 request_id、status_url、response_url 和 cancel_url。
      curl https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"File3D\": {\"Type\":\"GLB\",\"Url\":\"https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb\"}}"

      # 2. 轮询直到状态为 COMPLETED，每次响应都按其中指定的 Retry-After 秒数等待。
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 收集。返回 200 时包含模型的原生输出；仍在运行时返回 202 及状态响应体。
      curl https://api.comfy.org/v2/models/tencent/hunyuan-3d-smart-topology/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 输入

<ParamField body="FaceLevel" type="string">
  多边形减面级别。

  可选值：`high`、`medium`、`low`
</ParamField>

<ParamField body="File3D" type="object" required>
  用于智能拓扑的 3D 文件输入
</ParamField>

<ParamField body="File3D.Type" type="string" required>
  3D 文件格式类型

  可选值：`OBJ`、`GLB`
</ParamField>

<ParamField body="File3D.Url" type="string (uri)" required>
  需要重新拓扑的 3D 文件网址

  格式：`uri`
</ParamField>

<ParamField body="PolygonType" type="string">
  输出网格的多边形类型。默认为三角形。

  可选值：`triangle`、`quadrilateral`
</ParamField>

该内容由 Router 在 `GET /v2/models/tencent/hunyuan-3d-smart-topology/openapi.json` 提供的 schema 生成，也是请求到达提供商之前用于校验调用的同一份文档。

### 输出

<ResponseField name="Response" type="object" required />

<ResponseField name="Response.ErrorCode" type="string">
  腾讯的错误码，文档说明在无错误时为空字符串。一旦存在 `Status`，Router 便不再读取该字段。
</ResponseField>

<ResponseField name="Response.ErrorMessage" type="string">
  腾讯的报错信息，文档说明在无错误时为空字符串。一旦存在 `Status`，Router 便不再读取该字段。
</ResponseField>

<ResponseField name="Response.RequestId" type="string">
  腾讯自己的请求标识符，用于向腾讯排查问题。它既不是任务ID，也不是资产。
</ResponseField>

<ResponseField name="Response.ResultFile3Ds" type="object[]" required>
  已完成任务生成的 3D 文件。在 Router 返回的文档中该字段存在且非空；至少一个条目带有可获取的 `Url`。这些链接由腾讯提供，文档说明有效期为 24 小时。
</ResponseField>

<ResponseField name="Response.ResultFile3Ds[].PreviewImageUrl" type="string (uri)">
  预览图像网址

  格式：`uri`
</ResponseField>

<ResponseField name="Response.ResultFile3Ds[].Type" type="string">
  3D 文件格式

  可选值：`GLB`、`OBJ`
</ResponseField>

<ResponseField name="Response.ResultFile3Ds[].Url" type="string (uri)">
  文件网址（有效期 24 小时）

  格式：`uri`
</ResponseField>

<ResponseField name="Response.Status" type="string" required>
  可选值：`DONE`
</ResponseField>

## 示例

### 输入

```json theme={null}
{
  "File3D": {
    "Type": "GLB",
    "Url": "https://vcg-test-1258344699.cos.ap-guangzhou.myqcloud.com/test/3d/test.glb"
  }
}
```

### 输出

```json theme={null}
{
  "Response": {
    "ErrorCode": "",
    "ErrorMessage": "",
    "RequestId": "9a1c0d4e-77b2-4e0c-8f2e-2f9a1c0d4e77",
    "ResultFile3Ds": [
      {
        "PreviewImageUrl": "https://example.invalid/tencent/hunyuan-3d-smart-topology/preview.png",
        "Type": "GLB",
        "Url": "https://example.invalid/tencent/hunyuan-3d-smart-topology/retopologised.glb"
      }
    ],
    "Status": "DONE"
  }
}
```

## 发布前须知

SDK 会生成 `Idempotency-Key` 并在自动重试中复用它。手动重试时，请复用原始 key。Router 最长可保持连接 10 分钟。

请求失败时，Router 会发送 `X-Comfy-Error-Type` 响应头说明原因。`422` 表示 Router 在调用提供商之前就拒绝了输入，`413` 表示请求体超出了 Router 可接受的大小。已生成的资源请及时下载，因为[结果 URL 会过期](/zh/development/comfy-router/reference#结果资产)。

上文任何字段描述中提到的尺寸限制，都是提供商对该字段自身的限定，引自提供商的规范。Router 会对整个请求体另行设置上限，base64 编码的媒体内容也计入其中：参见[请求体大小](/zh/development/comfy-router/limitations)。

本页记录的是通过 Comfy Router 调用的某一个合作伙伴模型。同一个 `comfy-sdk` / `@comfyorg/sdk` 包还提供第二个客户端，用于在 Comfy Cloud 上运行完整的 ComfyUI 工作流图：`Comfy(api_key=...)` / `new Comfy({ apiKey })`，并带有 `client.workflows`、`client.assets` 和 `client.jobs`。请参阅 [Comfy SDKs](/zh/development/api-development/sdks)。

<CardGroup cols={3}>
  <Card title="请求头" icon="list" href="/zh/development/comfy-router/headers">
    身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
  </Card>

  <Card title="使用 Router API" icon="code" href="/zh/development/comfy-router/api">
    模型发现、验证错误、重试与计费。
  </Card>

  <Card title="限制" icon="triangle-exclamation" href="/zh/development/comfy-router/limitations">
    Router 目前不支持的功能，以及替代方案。
  </Card>
</CardGroup>
