重建网格 API

重建网格 API 允许您对由其他 Meshy API(如图像转3D或文本转3D)生成的现有3D模型进行重建网格并导出为多种格式。本节将为您详细介绍如何使用重建网格 API。


POST/openapi/v1/remesh

创建重建网格任务

此端点用于创建一个新的重建网格任务。

参数

必需属性

  • Name
    input_task_id
    Type
    string
    Description

    需要重建网格的已完成图像转3D或文本转3D任务的ID。 该任务必须是以下任务之一:Text to 3D Preview、Text to 3D Refine 或 Image to 3D,并且必须使用 meshy-4meshy-5 AI模型运行且状态为 SUCCEEDED

可选属性

  • Name
    target_formats
    Type
    array of strings
    Description

    重建网格模型的目标格式列表。

    可选值:glbfbxobjusdzblendstl

    未指定时默认为 ["glb"]

  • Name
    topology
    Type
    string
    Description

    指定生成模型的拓扑结构。

    可选值:

    • quad:生成以四边形为主的网格。
    • triangle:生成简化的三角网格。

    未指定时默认为 triangle

  • Name
    target_polycount
    Type
    integer
    Description

    指定生成模型的目标面数。实际面数可能会根据几何复杂度有所偏差。

    有效取值范围根据用户等级不同:

    • 100 到 300,000(含)

    未指定时默认为 30,000

  • Name
    resize_height
    Type
    number
    Description

    将模型缩放到指定高度(单位:米)。

    未指定时默认为 0(不缩放)。

  • Name
    origin_at
    Type
    string
    Description

    原点位置。

    可选值:bottomcenter

    未指定时默认为空字符串(无影响)。

返回值

响应的 result 字段包含新建重建网格任务的 id

请求

POST
/openapi/v1/remesh
curl https://api.meshy.ai/openapi/v1/remesh \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "target_formats": ["glb", "fbx"],
    "topology": "quad",
    "target_polycount": 50000,
    "resize_height": 1.0,
    "origin_at": "bottom"
  }'

响应

{
  "result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}

GET/openapi/v1/remesh/:id

获取重建网格任务

此端点用于通过ID获取重建网格任务。

参数

  • Name
    id
    Type
    path
    Description

    要获取的重建网格任务ID。

返回值

返回重建网格任务对象。

请求

GET
/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f
curl https://api.meshy.ai/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***"
},
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

GET/openapi/v1/remesh

列出重建网格任务

此端点允许您获取重建网格任务的列表。

参数

可选属性

  • Name
    page_num
    Type
    integer
    Description

    分页的页码。起始值和默认值为1

  • Name
    page_size
    Type
    integer
    Description

    每页返回的任务数量。默认为10,最大允许为50

  • Name
    sort_by
    Type
    string
    Description

    排序字段。可选值:

    • +created_at:按创建时间升序排序。
    • -created_at:按创建时间降序排序。

返回值

返回分页的重建网格任务对象列表。

请求

GET
/openapi/v1/remesh
curl https://api.meshy.ai/openapi/v1/remesh?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***"
    },
    "progress": 100,
    "status": "SUCCEEDED",
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000001000,
    "task_error": null
  }
]

GET/openapi/v1/remesh/:id/stream

流式重建网格任务

此端点通过Server-Sent Events (SSE)流式返回重建网格任务的实时进度更新。

参数

  • Name
    id
    Type
    path
    Description

    要流式获取的重建网格任务ID。

返回值

返回重建网格任务对象的流式Server-Sent Events。

对于PENDINGIN_PROGRESS状态的任务,响应流仅包含必要的progressstatus字段。

请求

GET
/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream
curl -N https://api.meshy.ai/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应流

// Error event example
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// Message event examples illustrate task progress.
// For PENDING or IN_PROGRESS tasks, the response stream will not include all fields.
event: message
data: {
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

重建网格任务对象

重建网格任务对象表示Meshy用于对现有3D模型进行重建网格并导出为多种格式的工作单元。 该对象包含以下属性:

属性

  • Name
    id
    Type
    string
    Description

    任务的唯一标识符。虽然我们使用k-sortable UUID作为任务ID的实现细节,但您不应该对ID的格式做任何假设。

  • Name
    model_urls
    Type
    object
    Description

    Meshy生成的带纹理3D模型文件的可下载URL。如果未生成某种格式,该格式的属性将被省略而不是返回空字符串。

    • Name
      glb
      Type
      string
      Description

      GLB文件的可下载URL。

    • Name
      fbx
      Type
      string
      Description

      FBX文件的可下载URL。

    • Name
      obj
      Type
      string
      Description

      OBJ文件的可下载URL。

    • Name
      usdz
      Type
      string
      Description

      USDZ文件的可下载URL。

    • Name
      blend
      Type
      string
      Description

      Blender文件的可下载URL。

    • Name
      stl
      Type
      string
      Description

      STL文件的可下载URL。

  • Name
    progress
    Type
    integer
    Description

    任务的进度。如果任务尚未开始,此属性将为0。一旦任务成功,这将变为100

  • Name
    status
    Type
    string
    Description

    任务的状态。可能的值是PENDINGPROCESSINGSUCCEEDEDFAILED之一。

  • Name
    preceding_tasks
    Type
    integer
    Description

    前置任务的数量。

  • Name
    created_at
    Type
    timestamp
    Description

    任务创建时的时间戳,以毫秒为单位。

  • Name
    started_at
    Type
    timestamp
    Description

    任务开始时的时间戳,以毫秒为单位。如果任务尚未开始,此属性将为0

  • Name
    finished_at
    Type
    timestamp
    Description

    任务完成时的时间戳,以毫秒为单位。如果任务尚未完成,此属性将为0

  • Name
    task_error
    Type
    object
    Description

    如果任务失败,包含错误消息的错误对象。如果任务成功,message属性应为空。

    • Name
      message
      Type
      string
      Description

      详细的错误消息。

重建网格任务对象示例

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": {
      "message": ""
  }
}