Remesh API

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


POST/openapi/v1/remesh

创建 Remesh 任务

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

参数

  • Name
    input_task_id
    Type
    string
    必选
    Description

    您希望进行 remesh 的、已完成的 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 进行 remesh 的 3D 模型。 支持的格式:.glb.gltf.obj.fbx.stl

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

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

    remesh 后模型的目标格式列表。若省略,则仅生成 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 属性包含新创建的 remesh 任务的 id

失败模式

  • Name
    400 - Bad Request
    Description

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

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

    authentication 失败。请检查您的 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。

任务状态

仍处于 PENDING 状态的任务会被删除,并且创建时消耗的 credits 会被退还。

已经处于 IN_PROGRESS 状态的任务无法删除:请求会被拒绝并返回 409 Conflict,任务会继续运行。工作进程已经开始处理的任务所消耗的 credits 不可退还,因此如果在运行过程中删除任务,你将同时损失 credits 和结果。请等待任务到达 SUCCEEDEDFAILEDCANCELED 状态,然后再删除它。

处于终止状态(SUCCEEDEDFAILEDCANCELED)的任务会被删除,且不会退还 credits。

返回值

成功时返回 200 OK;当任务处于 IN_PROGRESS 状态时返回 409 Conflict

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

// 200 OK on success, with an empty body.
//
// 409 Conflict when the task is IN_PROGRESS — the task is left running:
{
  "message": "Task is IN_PROGRESS and cannot be deleted. Credits for a task the worker has already started are not refundable; wait for it to reach SUCCEEDED, FAILED or CANCELED, then delete it."
}

GET/openapi/v1/remesh

获取 Remesh 任务列表

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

参数

  • Name
    page_num
    Type
    integer
    默认值 1
    Description

    用于分页的页码。

  • Name
    page_size
    Type
    integer
    默认值 10
    Description

    每页数量限制。最大允许 100 项。

  • 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,
}

Remesh 任务对象

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

属性

  • Name
    id
    Type
    string
    Description

    任务的唯一标识符。虽然我们在实现细节上使用 k-可排序 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

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

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
}