Auto Split API

将一个 3D 模型拆分为多个可分别打印的部件——可以自动拆分,也可以按你指定的部件拆分,或按颜色区域拆分——并可选择添加连接件;切割后留下的薄弱区域始终会被加固,以确保每个部件都能被实心打印出来。


POST/openapi/v1/print/split

创建 Auto Split 任务

此 endpoint 创建一个新的 Auto Split 任务。该任务将先前任务生成的模型切割为可分别打印的多个部件,并返回分割后的模型,其中每个部件在文件中都是独立的对象。

参数

  • Name
    input_task_id
    Type
    string
    必选
    Description

    要分割其模型的成功任务的 ID。支持的任务类型:Image to 3D、Multi-Image to 3D、Text to 3D(预览)、Remesh、Convert 以及 Resize。该任务的状态必须为 SUCCEEDED,且其模型必须由 Meshy 6 或 Meshy 7 生成(ai_model 为 meshy-6、meshy-7、meshy-7.1 或 latest)。不支持 low-poly 和 Smart Topology(meshy-t2)模型。可以接受带 texture 的模型,但其 texture 不会带入结果中。

  • Name
    mode
    Type
    string
    默认值 auto
    Description

    模型如何被划分为多个部件。

    可用取值:

    • auto:由 Meshy 自行选择切割方式。此时会忽略 prompt。
    • by_parts:沿着你在 prompt 中指定的结构部件(如头部、手臂、躯干)进行切割。
    • by_color:沿着你在 prompt 中指定的颜色区域进行切割。要求输入来自上传图片生成的结果(Image to 3D 或 Multi-Image to 3D);其他输入将被拒绝并返回 400。颜色区域的边界来自源图片,而不是输入模型的 texture。对于 Multi-Image to 3D,Auto Split 使用第一张源图片。
仅当 mode = by_parts or by_color
  • Name
    prompt
    Type
    string
    必选
    Description

    以任意语言描述要拆分成的部件。Meshy 会从中读取 1 到 10 个部件名称,因此请为部件命名,而不是描述整个模型——例如 split into the figure and the base,或 head, torso, left arm, right arm, legs。只命名一个部件也是可以的:所有未被命名的部分会合并成剩余的一个部件,因此 the head 会将模型拆分为“头部”和“其余部分”,与 web app 中的行为一致。最多 600 个字符。有两种失败情形:如果描述要求完全不拆分,或指定了超过 10 个部件,将返回 400 且不收费;如果 Meshy 完全无法解析该描述,会回退到 auto 模式,任务仍会运行并收费,且响应中会带有 prompt_ignored: true。

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

    导出分割后模型所使用的格式。支持场景对象的格式(glb、obj、fbx、usdz、blend、3mf)会将每个部件作为独立对象保存;stl 没有独立对象的概念,因此会将所有部件融合为一个实体,并按 layout 排列(如需在 slicer 中分别选中各部件,请选择 3mf)。glb 始终会生成,并在 model_urls 中返回;如需其他格式,请在此列出。

    可用取值:glb、obj、fbx、stl、usdz、blend、3mf。

  • Name
    layout
    Type
    string
    默认值 assembled
    Description

    各个输出格式以及 thumbnail 中部件的排列方式。

    可用取值:

    • assembled:部件保持在源模型中的原始位置。
    • on_plate:部件被平铺展开放置在打印平台上,可直接用于切片——与 web app 中的 On Plate 视图排列方式相同。

    在这两种排列方式中,切割后留下的坍缩薄片或近似点状的碎片都会在导出前被移除,因此你得到的每个部件都是可打印的。支持场景对象的格式会为每个部件保存一个对象;stl 会将它们融合为单个实体。

  • Name
    connectors
    Type
    boolean
    默认值 false
    Description

    在每个切割处添加榫卯连接件,使打印出的部件可以拼合在一起。

仅当 connectors = true
  • Name
    connector_type
    Type
    string
    默认值 cube
    Description

    每个切割面上连接件的形状。

    可用取值:cube、cylinder。

  • Name
    connector_size
    Type
    number
    默认值 0.5
    Description

    连接件相对于切割面的尺寸大小。

    有效范围:0.1 到 0.8。

  • Name
    connector_height
    Type
    number
    默认值 0.1
    Description

    连接件相对于切割面向外延伸的距离。

    有效范围:0.1 到 0.8。

返回值

响应中的 result 属性包含新创建的 Auto Split 任务的 id。

失败情形

  • Name
    400 - Bad Request
    Description

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

    • 缺少 prompt:当 mode 为 by_parts 或 by_color 时,prompt 为必填项。
    • prompt 描述不拆分,或部件数量过多:by_parts / by_color 接受 1 到 10 个命名部件。若描述要求保持模型完整不拆分,或命名了超过 10 个部件,请求将被拒绝。此情况不收费。
    • 不支持的输入任务:input_task_id 必须指向一个由 Meshy 6 或 Meshy 7 生成的、状态为成功的受支持类型任务。
    • 缺少参考图片:by_color 要求输入来自上传图片生成的结果。
    • 连接件参数超出范围:connector_size 或 connector_height 超出了 0.1 到 0.8 的范围。
  • Name
    401 - Unauthorized
    Description

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

  • Name
    402 - Payment Required
    Description

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

  • Name
    404 - Not Found
    Description

    input_task_id 不存在,或不属于你的账户。

  • Name
    429 - Too Many Requests
    Description

    你已超出速率限制。by_parts 和 by_color 请求还共享一个 prompt 解析限制,即每个账户每分钟 12 次请求。

  • Name
    503 - Service Unavailable
    Description

    基于 prompt 的拆分功能(by_parts 和 by_color)暂时不可用。请稍后重试,或使用不受影响的 mode: "auto"。此情况不收费。

Request

POST
/openapi/v1/print/split
# Simple request: let Meshy choose the cuts
curl https://api.meshy.ai/openapi/v1/print/split \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578"
  }'

# Advanced request: name the parts, add connectors, export glb and obj
curl https://api.meshy.ai/openapi/v1/print/split \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "mode": "by_parts",
    "prompt": "split into the figure and the base",
    "target_formats": ["glb", "obj"],
    "layout": "on_plate",
    "connectors": true,
    "connector_type": "cylinder",
    "connector_size": 0.4
  }'

Response

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

GET/openapi/v1/print/split/:id

获取 Auto Split 任务

此 endpoint 通过 ID 获取一个 Auto Split 任务。

参数

  • Name
    id
    Type
    path
    Description

    要获取的 Auto Split 任务的 ID。

返回

Auto Split 任务对象。

Request

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

Response

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-split",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
  "part_count": 4,
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000082000,
  "task_error": null,
  "consumed_credits": 10
}

DELETE/openapi/v1/print/split/:id

删除一个 Auto Split 任务

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

路径参数

  • Name
    id
    Type
    path
    Description

    要删除的 Auto Split 任务的 ID。

任务状态

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

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

处于终止状态(SUCCEEDED、FAILED 或 CANCELED)的任务将被删除,且不予退还 credits。

返回值

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

Request

DELETE
/openapi/v1/print/split/a43b5c6d-7e8f-901a-234b-567c890d1e2f
curl --request DELETE \
  --url https://api.meshy.ai/openapi/v1/print/split/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/print/split

获取 Auto Split 任务列表

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

参数

可选属性

  • Name
    page_num
    Type
    integer
    Description

    用于分页的页码。起始值及默认值为 1。

  • Name
    page_size
    Type
    integer
    Description

    每页数量限制。默认为 10 项。最大允许值为 100 项;超过该值将被限制为 100。

  • Name
    sort_by
    Type
    string
    Description

    用于排序的字段。可用取值:

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

返回值

返回一个分页列表,其中包含 Auto Split 任务对象。

Request

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

Response

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "print-split",
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
    "part_count": 4,
    "progress": 100,
    "status": "SUCCEEDED",
    "preceding_tasks": 0,
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000082000,
    "task_error": null,
    "consumed_credits": 10
  }
]

GET/openapi/v1/print/split/:id/stream

流式获取 Auto Split 任务

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

参数

  • Name
    id
    Type
    path
    Description

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

返回

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

每个 message 事件都携带 获取 Auto Split 任务 返回的完整任务对象,包括 consumed_credits、时间戳以及 prompt_ignored;当任务处于 PENDING 或 IN_PROGRESS 状态时,帧之间会变化的字段是 progress、status、started_at 和 preceding_tasks,而 model_urls、thumbnail_url 和 part_count 会在任务达到 SUCCEEDED 状态后出现。error 事件只携带 status_code 和 message,因此在读取 status 之前应先根据事件名称进行分支处理。

Request

GET
/openapi/v1/print/split/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream
curl -N https://api.meshy.ai/openapi/v1/print/split/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 (other task fields omitted here for brevity;
// each frame is the full task object).
event: message
data: {
  "id": "a43b5c6d-7e8f-901a-234b-567c890d1e2f",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "a43b5c6d-7e8f-901a-234b-567c890d1e2f",
  "type": "print-split",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/model.glb?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/preview.png?Expires=***",
  "part_count": 4,
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000082000,
  "task_error": null,
  "consumed_credits": 10
}

The Auto Split Task Object

Auto Split 任务仅携带以下属性。其他任务对象中包含的生成提示词字段(name、object_prompt、texture_prompt 等)、单个 model_url 以及 texture_urls,在拆分任务中永远不会被填充,也不会被返回。随着任务运行而逐步填充的属性(thumbnail_url、model_urls、时间戳)始终存在,只是在有值之前为空,因此这组键在 PENDING 和 SUCCEEDED 之间不会发生变化。

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

    任务的类型。此值为 print-split。

  • Name
    model_urls
    Type
    object
    Description

    指向拆分模型的可下载 URL,每个请求的格式对应一个。支持 scene 对象的格式会将每个部件保留为独立对象;stl 会将它们熔合为一个整体。如果未请求某种格式,则该格式对应的属性将被省略。

    • Name
      glb
      Type
      string
      Description

      指向 GLB 格式拆分模型的可下载 URL。

    • Name
      obj
      Type
      string
      Description

      指向 OBJ 格式拆分模型的可下载 URL。

    • Name
      fbx
      Type
      string
      Description

      指向 FBX 格式拆分模型的可下载 URL。

    • Name
      stl
      Type
      string
      Description

      指向 STL 格式拆分模型的可下载 URL。所有部件都会熔合为一个整体;如需分别可选的部件,请请求 3mf。

    • Name
      usdz
      Type
      string
      Description

      指向 USDZ 格式拆分模型的可下载 URL。

    • Name
      blend
      Type
      string
      Description

      指向 Blender 格式拆分模型的可下载 URL。

    • Name
      3mf
      Type
      string
      Description

      指向 3MF 格式拆分模型的可下载 URL。

  • Name
    thumbnail_url
    Type
    string
    Description

    指向拆分模型渲染预览图的可下载 URL,其中每个部件以不同颜色显示,采用所请求的 layout。

  • Name
    prompt_ignored
    Type
    boolean
    Description

    当 by_parts 或 by_color 请求的 prompt 未指定任何部件名称时,此值为 true,表示 Meshy 转而自动拆分了模型——结果中的部件名称是 Meshy 生成的,而不是你提供的。从 PENDING 起就会出现该字段。对于 auto 任务,以及任何遵循了提示词的情况,此字段会被省略。

  • Name
    part_count
    Type
    integer
    Description

    拆分产生的可打印部件数量。支持 scene 对象的格式会为每个部件携带一个对象;stl 会将它们熔合为一个整体,但计数仍报告部件数量。分割过程中无法生成可打印部件的坍缩薄片,会在导出前从文件中移除,且不计入计数。

  • Name
    progress
    Type
    integer
    Description

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

  • Name
    status
    Type
    string
    Description

    任务的状态。可能的值为 PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED 之一。

  • 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 数量。始终存在:任务被接受后为 10,对于 FAILED 任务则为 0,因为失败时费用会被退还。在任务仍处于 PENDING 状态时删除它,也会退还费用。

The Auto Split Task Object

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-split",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
  "part_count": 4,
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000082000,
  "task_error": null,
  "consumed_credits": 10
}