Auto Split API

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


POST/openapi/v1/print/split

创建 Auto Split 任务

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

参数

  • Name
    input_task_id
    Type
    string
    必选
    Description

    要分割其模型的成功任务的 ID。支持的任务类型:Image to 3DMulti-Image to 3DText to 3D(预览)、RemeshConvertResize。该任务的状态必须为 SUCCEEDED,且其模型必须由 Meshy 6 或 Meshy 7 生成(ai_modelmeshy-6meshy-7latest)。不支持 low-poly 和 Smart Topology(meshy-t2)模型。

  • Name
    mode
    Type
    string
    默认值 auto
    Description

    模型划分为多个部件的方式。

    可用值:

    • auto:由 Meshy 选择切割方式。prompt 将被忽略。
    • by_parts:沿着你在 prompt 中指定的结构部件(例如头部、手臂和躯干)进行切割。
    • by_color:沿着你在 prompt 中指定的颜色区域进行切割。要求输入来自上传图像生成的结果(Image to 3DMulti-Image to 3D);其他输入将被拒绝并返回 400
仅当 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。最多 600 个字符。有两种失败情形:一种是描述内容读起来像是要求分割,但命名的部件少于两个(例如 split into individual parts),此时会被拒绝并返回 400,且不会扣费;另一种是 Meshy 完全无法解析描述内容,此时会回退到 auto,任务仍会执行并计费,且响应中会带有 prompt_ignored: true

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

    导出分割后模型所用的格式。在每种格式中,每个部件都是独立的对象。系统始终会生成 glb 并在 model_urls 中返回;如需其他格式,请在此列出。

    可用值:glbobjfbxusdzblend3mf

    3mf 是为 slicer 编写的:每个部件对应一个对象,各自占用独立的耗材槽位,因此 Bambu Studio 打开该文件时,各部件会显示为可单独着色、可单独选中的部分(该压缩包中带有 Bambu Studio 项目配置;其他 slicer 则只读取 geometry)。与 Meshy 的其他打印格式一样,该格式以毫米为单位;由于此 endpoint 不接受目标尺寸,整个模型会被缩放,使其最长边为 150 毫米——这与其他打印格式导出所使用的上限相同,该上限经过选定,可适配所有主流的打印平台。当 layout"on_plate" 时,该上限适用于整个排版后的打印板;当为 assembled 时,各部件保持源模型中的位置,需要你自行在 slicer 中排列。

  • Name
    layout
    Type
    string
    默认值 assembled
    Description

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

    可用值:

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

    在这两种排版方式下,导出的文件中每个部件对应一个对象,且不含其他内容:切割后残留的坍缩薄片或点状碎片会在导出前被移除,因此文件中出现的每个对象都是可打印的。

  • Name
    connectors
    Type
    boolean
    默认值 false
    Description

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

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

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

    可用值:cubecylinder

  • Name
    connector_size
    Type
    number
    默认值 0.5
    Description

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

    有效范围:0.10.8

  • Name
    connector_height
    Type
    number
    默认值 0.1
    Description

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

    有效范围:0.10.8

返回值

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

失败情形

  • Name
    400 - Bad Request
    Description

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

    • 缺少 prompt:当 modeby_partsby_color 时,prompt 为必填项。
    • prompt 命名的部件少于两个by_parts / by_color 至少需要两个命名的部件(例如 head, torso, base);诸如 split into individual parts 之类的泛化指令将被拒绝。不会产生扣费。
    • 不支持的输入任务input_task_id 必须指向一个由 Meshy 6 或 Meshy 7 生成的、类型受支持的成功任务。
    • 带纹理的输入:输入模型带有 texture。目前仅支持不带 texture 的模型。
    • 缺少参考图像by_color 要求输入来自上传图像生成的结果。
    • 不支持的格式target_formats 中包含 stl
    • 连接件参数超出范围connector_sizeconnector_height 超出 0.10.8 的范围。
  • Name
    401 - Unauthorized
    Description

    authentication 失败。请检查你的 API key。

  • Name
    402 - Payment Required
    Description

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

  • Name
    404 - Not Found
    Description

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

  • Name
    429 - Too Many Requests
    Description

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

  • Name
    503 - Service Unavailable
    Description

    基于 prompt 的分割(by_partsby_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。

返回值

成功时返回 200 OK

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

// Returns 200 Ok on success.

GET/openapi/v1/print/split

List Auto Split Tasks

此 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;当任务处于 PENDINGIN_PROGRESS 状态时,帧与帧之间发生变化的字段是 progressstatusstarted_atpreceding_tasks,而 model_urlsthumbnail_urlpart_countparts 会在任务到达 SUCCEEDED 状态后出现。error 事件仅携带 status_codemessage,因此在读取 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
}

Auto Split 任务对象

一个 Auto Split 任务仅包含以下属性。其他任务对象中包含的生成提示词字段(nameobject_prompttexture_prompt 等)、单个 model_url,以及 texture_urls,在拆分任务中永远不会被填充,也不会被返回。随着任务运行而填充的属性(thumbnail_urlmodel_urls、时间戳)始终存在,在没有值之前为空,因此这些键的集合在 PENDINGSUCCEEDED 之间不会发生变化。

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

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

  • Name
    model_urls
    Type
    object
    Description

    拆分模型的可下载 URL,每个请求的格式对应一个。文件中每个部件都是一个独立的对象。如果未请求某种格式,则对应该格式的属性将被省略。

    • Name
      glb
      Type
      string
      Description

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

    • Name
      obj
      Type
      string
      Description

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

    • Name
      fbx
      Type
      string
      Description

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

    • Name
      usdz
      Type
      string
      Description

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

    • Name
      blend
      Type
      string
      Description

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

    • Name
      3mf
      Type
      string
      Description

      3MF 格式拆分模型的可下载 URL:每个部件对应一个对象,每个对象都位于自己的耗材槽位上,单位为毫米,缩放比例使最长边为 150 毫米,并带有 Bambu Studio 项目配置。

  • Name
    thumbnail_url
    Type
    string
    Description

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

  • Name
    prompt_ignored
    Type
    boolean
    Description

    by_partsby_color 请求中的 prompt 未指定任何部件名称时为 true,此时 Meshy 会自动拆分模型 —— 结果中的部件名称由 Meshy 生成,而非由你指定。从 PENDING 状态起就会出现该字段。对于 auto 任务,以及在提示词被遵循时,该字段会被省略。

  • Name
    part_count
    Type
    integer
    Description

    拆分模型中可打印部件的数量 —— 每个导出文件中的对象对应一个部件。分割过程中无法转换为可打印部件的坍缩碎片,会在导出前从文件中移除,不计入此数量。

  • Name
    progress
    Type
    integer
    Description

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

  • Name
    status
    Type
    string
    Description

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

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