Remesh API

Remesh API 允许您对其他 Meshy API(如 Image to 3D 或 Text to 3D)生成的现有 3D 模型进行重拓扑,并将其导出为多种格式。本节将详细介绍如何使用 Remesh API。


POST/openapi/v1/remesh

创建 Remesh 任务

此 endpoint 用于创建一个新的 Remesh 任务。

参数

  • Name
    input_task_id
    Type
    string
    必选
    Description

    您希望进行重拓扑的、已完成的 Image to 3D 或 Text to 3D 任务的 ID。 该任务必须是以下任务之一:Text to 3D Preview、Text to 3D Refine、Image to 3D 或 Retexture。此外,其状态必须为 SUCCEEDED

  • Name
    model_url
    Type
    string
    必选
    Description

    请通过可公开访问的 URL 或 data URI 提供一个供 Meshy 进行重拓扑的 3D 模型。 支持的格式:.glb.gltf.obj.fbx.stl

    对于 Data URI,请使用 MIME type:application/octet-stream

  • Name
    target_formats
    Type
    string[]
    默认值 ["glb"]
    Description

    重拓扑后模型的目标格式列表。若省略,则仅生成 GLB 格式。

    可选值:glbfbxobjusdzblendstl3mf

  • Name
    topology
    Type
    string
    默认值 triangle
    Description

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

    可选值:

    • quad:生成以四边形为主的 mesh。
    • triangle:生成经过精简的三角形 mesh。
  • Name
    target_polycount
    Type
    integer
    默认值 30,000
    Description

    指定生成模型中的目标多边形数量。实际的多边形数量可能会根据 geometry 的复杂程度与目标值有所偏差。

    有效值范围因用户等级而异:

    • 100 到 300,000(含边界值)
  • Name
    decimation_mode
    Type
    integer
    Description

    通过设置 polycount 级别来启用自适应精简。设置该参数后,target_polycount 将被忽略。

    可选值:

    • 1:自适应 — 超高 polycount。
    • 2:自适应 — 高 polycount。
    • 3:自适应 — 中等 polycount。
    • 4:自适应 — 低 polycount。
  • Name
    resize_height
    Type
    number
    已弃用
    默认值 0
    Description

    将模型尺寸调整为以米为单位的特定高度。我们建议改用专用的 Resize API

  • Name
    resize_longest_side
    Type
    number
    已弃用
    默认值 0
    Description

    调整模型尺寸,使其边界框中最长的一边等于指定的米数值。我们建议改用专用的 Resize API

  • Name
    auto_size
    Type
    boolean
    已弃用
    默认值 false
    Description

    设置为 true 时,服务会使用 AI 视觉自动估算物体的真实世界高度,并据此调整模型尺寸。我们建议改用专用的 Resize API

仅当 auto_size = true
  • Name
    origin_at
    Type
    string
    已弃用
    默认值 bottom
    Description

    origin(原点)的位置。我们建议改用专用的 Resize API

    可选值:bottomcenter

  • Name
    convert_format_only
    Type
    boolean
    已弃用
    Description

    如果为 true,服务将仅更改输入模型文件的格式,而忽略其他输入参数,如 topologyresize_heighttarget_polycount。我们建议改用专用的 Convert API

  • Name
    alpha_thumbnail
    Type
    boolean
    默认值 false
    Description

    设置为 true 时,该任务会额外渲染一个透明背景(RGBA)版本的预览图,并在 GET 响应中以 alpha_thumbnail_url 的形式返回。现有的 thumbnail_url 字段保持不变。

返回值

响应中的 result 属性包含新创建的重拓扑任务的 id

失败模式

  • Name
    400 - Bad Request
    Description

    请求不可接受。常见原因:

    • 缺少参数:必须提供 model_urlinput_task_id 其中之一。
    • 输入任务无效input_task_id 必须指向来自受支持模型的成功任务。
    • 模型格式无效model_url 指向的文件扩展名不受支持。
    • URL 无法访问:无法下载 model_url 所指向的文件。
    • topology 无效topology 参数无效。
    • 参数互斥auto_sizeresize_height 不能同时设置。
  • Name
    401 - Unauthorized
    Description

    身份验证失败。请检查您的 API key。

  • Name
    402 - Payment Required
    Description

    credits 不足,无法执行此任务。

  • Name
    429 - Too Many Requests
    Description

    您已超出速率限制。

Request

POST
/openapi/v1/remesh
# Basic remesh with custom formats and resize
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"
  }'

# Quad remesh with auto-size
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,
    "auto_size": true
  }'

Response

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

GET/openapi/v1/remesh/:id

获取 Remesh 任务

此 endpoint 用于根据 ID 获取一个 remesh 任务。

参数

  • Name
    id
    Type
    path
    Description

    要获取的 remesh 任务的 ID。

返回

Remesh 任务对象。

Request

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}"

Response

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "remesh",
  "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=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

DELETE/openapi/v1/remesh/:id

删除 Remesh 任务

此 endpoint 将永久删除一个 remesh 任务,包括所有相关的模型和数据。此操作不可撤销。

路径参数

  • Name
    id
    Type
    path
    Description

    要删除的 remesh 任务的 ID。

返回值

成功时返回 200 OK

Request

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

Response

// Returns 200 Ok on success.

GET/openapi/v1/remesh

获取 Remesh 任务列表

此 endpoint 允许您获取 Remesh 任务的列表。

参数

  • Name
    page_num
    Type
    integer
    默认值 1
    Description

    用于分页的页码。

  • Name
    page_size
    Type
    integer
    默认值 10
    Description

    每页大小限制。最大允许为 50 项。

  • Name
    sort_by
    Type
    string
    Description

    用于排序的字段。

    可用值:

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

返回

返回一个经过分页的 Remesh 任务对象 列表。

Request

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

Response

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "remesh",
    "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=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
    },
    "progress": 100,
    "status": "SUCCEEDED",
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000001000,
    "task_error": null
  }
]

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

流式获取 Remesh 任务

此 endpoint 使用 Server-Sent Events(SSE)流式传输 Remesh 任务的实时更新。

参数

  • Name
    id
    Type
    path
    Description

    要流式传输的 Remesh 任务的唯一标识符。

返回值

以 Server-Sent Events 的形式返回 Remesh 任务对象 的流。

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

Request

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}"

Response Stream

// 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",
  "type": "remesh",
  "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=***",
    "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

The Remesh Task Object

Remesh Task 对象表示 Meshy 用于将现有 3D 模型重拓扑并导出为多种格式的工作单元。 该对象具有以下属性:

Properties

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

    Remesh 任务的类型。该值为 remesh

  • 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
      3mf
      Type
      string
      Description

      指向 3MF 文件的可下载 URL。仅当通过 target_formats 请求了 3mf 时才会出现。

  • Name
    thumbnail_url
    Type
    string
    Description

    指向由重拓扑后的模型渲染生成的预览图片的可下载 URL。

  • Name
    alpha_thumbnail_url
    Type
    string
    Description

    指向 thumbnail_url 的透明背景(RGBA)版本的可下载 URL。仅当任务创建时设置了 alpha_thumbnail: true 且透明预览图渲染成功时才会出现;否则该字段将被省略。

  • Name
    progress
    Type
    integer
    Description

    任务的进度。如果任务尚未开始,该属性为 0。任务成功后,该值将变为 100

  • Name
    status
    Type
    string
    Description

    任务的状态。可能的值为 PENDINGIN_PROGRESSSUCCEEDEDFAILED 之一。

  • 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

    失败任务的错误详情。完整的 task_error 对象参考请参见 Errors

  • Name
    consumed_credits
    Type
    integer
    Description

    该任务消耗的积分数量。当任务状态为 PENDINGIN_PROGRESSSUCCEEDED 时会出现该字段。对于 FAILED 任务将返回 0(失败时积分会被退还)。

Example Remesh Task Object

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "remesh",
  "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=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": {

    "message": ""

  },

  "consumed_credits": 5
}