多色打印 API
Convert 3D 模型,生成可用于 3D 打印的多色 3MF 文件。选择最多 16 种颜色的调色板,以及适用于您打印机品牌的 slicer 预设。
创建 Multi-Color Print 任务
创建一个 Multi-Color Print 任务,将 3D 模型转换为用于 3D 打印的多色 3MF 文件。该任务在后台运行。有关任务通常需要多长时间,请参阅处理时间。
Request
# Convert a 3D model to a multi-color 3MF with a Creality slicer preset
curl https://api.meshy.ai/openapi/v1/print/multi-color \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"max_colors": 8,
"printer_brand": "creality"
}'
Response
{
"result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}
参数
- Name
- input_task_id
- Type
- string
- 必选
- Description
除非你发送
model_url,否则此参数为必填项。你想打印其模型的任务 ID,例如 Image to 3D、Multi-Image to 3D、Text to 3D、Remesh 或 Retexture 任务。该任务必须是你通过 API 创建的任务,且状态为SUCCEEDED。Multi-Color Print 会读取该任务的 GLB 文件,其面数最多为 8,000,000。面数超出的模型将返回
400。此时请先对其运行 Remesh 任务,然后改为发送该 Remesh 任务的 ID。
- Name
- model_url
- Type
- string
- 必选
- Description
除非你发送
input_task_id,否则此参数为必填项。要打印的模型,可以是公开 URL 或 data URI。如果两者都发送,Meshy 会使用input_task_id。http或httpsURL 必须指向大小不超过 400 MB 的.glb或.fbx文件。data URI 必须是不超过 100 MB 的 base64 编码 GLB 文件,需使用data:model/gltf-binary;base64,。.fbx文件须以http或httpsURL 形式发送。超过 100 MB 的文件还必须遵循以下规则:
- 面数最多为 8,000,000。Meshy 按三角形计算面数,因此一个四边形计为 2 个面,被多次绘制的 mesh 每份副本都会计入一次。
- FBX 文件必须是 7.1 或更高版本的二进制 FBX。
- GLB 文件不得使用 Draco 压缩。
- Name
- max_colors
- Type
- integer
- 默认值 4
- Description
输出调色板中的最大颜色数,范围为
1到16。若要使用默认值,请省略该参数,而不是发送0。
- Name
- style
- Type
- string
- 默认值 realistic
- Description
3MF 文件的颜色风格。
可用取值:
realistic:直接从模型的 texture 中采样颜色,以获得精细的照片级真实细节,生成的文件较大。cartoon:将颜色扁平化为简洁、均匀的区域,呈现风格化外观,生成的文件较小。
模型必须具有颜色。
realistic需要每个 mesh 部件都带有 UV 的单一基础颜色 texture,cartoon也接受顶点颜色。Meshy 会拒绝没有 texture(纯白色)的模型。参见model_missing_texture。
- Name
- max_depth
- Type
- integer
- 默认值 4
- Description
Meshy 用于将 texture 颜色采样到 mesh 上的细分深度,范围为
3到6。0等同于省略该参数。值越大,捕捉的颜色细节越精细,生成的文件也越大。仅realistic风格使用此参数,cartoon会忽略它。
- Name
- printer_brand
- Type
- string
- 默认值 bambu
- Description
Meshy 写入 3MF 文件中的 slicer 预设所对应的打印机品牌。该文件随后会在该品牌的 slicer 中打开,并带有匹配的打印机、耗材和工艺配置文件。预设使用该品牌的默认打印机,喷嘴为 0.4 mm。
可用取值:
bambuanycubiccrealityelegooflashforgeprusaqidisnapmakerankermake
任何其他值都会返回
400。
返回值
响应的 result 字段保存新创建的 Multi-Color Print 任务的 ID。
失败情形
- Name
400 - Bad Request- Description
请求无法执行。错误消息会说明发现的问题。例如:
- 缺少参数:既没有发送
model_url,也没有发送input_task_id。 - 模型格式无效:
model_url文件不是.glb或.fbx文件。 - URL 不可访问:Meshy 无法下载
model_url文件。 - 模型文件过大:
model_url文件以http或httpsURL 形式提供时超过 400 MB,或以 data URI 形式提供时超过 100 MB。 - 面数过多:
model_url文件超过 100 MB,且面数超过 8,000,000。请减少面数后重新发送该文件。 - ASCII FBX 超过 100 MB:
model_url文件是超过 100 MB 的 ASCII FBX。请将其作为二进制 FBX 或 GLB 发送。 - 模型文件不可读:
model_url文件超过 100 MB,且 Meshy 无法读取其文件头。例如,它是经过 Draco 压缩的 GLB,或是早于 7.1 版本的二进制 FBX。 - 模型文件头过于复杂:
model_url文件超过 100 MB,且其文件头中包含过多需要检查的 mesh、节点或记录。请减少文件中的对象数量后重新发送。 - 输入任务无效:
input_task_id不是一个成功的任务。 - 输入任务中的面数过多:
input_task_id对应的模型面数超过 8,000,000。请先对其运行 Remesh 任务,然后改为发送该 Remesh 任务的 ID。 - max_colors 无效:
max_colors为负数或超过16。 - style 无效:
style不是realistic或cartoon。 - max_depth 无效:
max_depth不在3到6范围内,且不是0。 - printer_brand 无效:
printer_brand不是可用取值之一。 - 缺少颜色来源:模型缺少
style所需的颜色。realistic需要每个 mesh 部件都带有 UV 的单一基础颜色 texture。cartoon接受基础颜色 texture 或顶点颜色。请先为模型添加 texture,或者对带有顶点颜色的模型使用cartoon。Meshy 仅在任务对.fbx上传文件完成规范化后才进行检查,因此该任务会改为以model_missing_texture失败。
请修正请求后重新发送。参见错误。
- 缺少参数:既没有发送
- Name
401 - Unauthorized- Description
API key 缺失或无效。请检查
Authorization请求头。
- Name
402 - Payment Required- Description
例如:
- 积分不足:账户没有足够的积分来执行此任务,或账户达到了积分限额。请检查你的积分余额,然后重试。
- 免费计划:创建任务需要付费计划。请在你的 subscription 设置中升级你的计划,然后重试。
- Name
403 - Forbidden- Description
input_task_id是一个浮雕模型,此 endpoint 无法打印此类模型。错误消息为This model type does not support this operation。请发送其他模型。
- Name
404 - Not Found- Description
input_task_id与你的任何任务都不匹配。请检查任务 ID,然后重新发送请求。
- Name
429 - Too Many Requests- Description
你超出了速率限制。请稍候后重试。参见速率限制。
获取多色打印任务
根据 ID 返回一个多色打印任务。
Request
curl https://api.meshy.ai/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-multi-color",
"model_urls": {
"3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
"consumed_credits": 10
}
删除多色打印任务
永久删除一个多色打印任务,包括其模型和数据。删除操作无法撤销。
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/print/multi-color/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 keeps 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."
}
路径参数
- Name
- id
- Type
- path
- Description
要删除的任务的 ID。
任务状态
删除处于 PENDING 状态的任务会退还你创建该任务时所使用的积分。
处于 IN_PROGRESS 状态的任务无法删除。该请求会返回 409 Conflict,
任务会继续运行。Meshy 不会为已经开始的任务退款,
因此删除它会让你同时失去积分和结果。请等待任务
变为 SUCCEEDED、FAILED 或 CANCELED 状态后再删除。
删除处于最终状态(SUCCEEDED、FAILED 或 CANCELED)的任务
不会退还其积分。
返回
任务删除成功时返回 200 OK;当任务处于
IN_PROGRESS 状态时返回 409 Conflict。
List Multi-Color Print tasks
返回您的多色打印任务列表。
Request
curl https://api.meshy.ai/openapi/v1/print/multi-color?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
[
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-multi-color",
"model_urls": {
"3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
"consumed_credits": 10
}
]
参数
- Name
- page_num
- Type
- integer
- 默认值 1
- Description
要返回的页码。页码从
1开始。
- Name
- page_size
- Type
- integer
- 默认值 10
- Description
每页的任务数量,最多为
100。
- Name
- sort_by
- Type
- string
- Description
排序方式。
可用值:
+created_at:最早优先-created_at:最新优先
返回
分页的多色打印任务对象列表。
流式获取多色打印任务
以服务器发送事件(SSE)的形式流式获取多色打印任务的更新。
Request
curl -N https://api.meshy.ai/openapi/v1/print/multi-color/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.
// These examples are shortened. Each event holds 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-multi-color",
"model_urls": {
"3mf": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/model.3mf?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
"consumed_credits": 10
}
参数
- Name
- id
- Type
- path
- Description
创建响应中返回的任务 ID。
返回值
以 Server-Sent Events 形式返回的 多色打印任务对象 流。
每个事件都包含完整的任务对象,其结构与 Get endpoint 返回的内容相同。当任务处于 PENDING 或 IN_PROGRESS 状态时,其结果字段尚无值。
多色打印任务对象
多色打印任务对象描述了一次将 3D 模型转换为多色 3MF 文件的转换过程。它保存了任务成功时的状态、进度和 3MF 文件。
The 3D Print Task Object
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-multi-color",
"model_urls": {
"3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
"consumed_credits": 10
}
- Name
- id
- Type
- string
- Description
任务 ID。请将其视为不透明字符串,不要依赖其格式。
- Name
- type
- Type
- string
- Description
任务类型,始终为
print-multi-color。
- Name
- model_urls
- Type
- object
- Description
打印模型的下载链接,每种文件格式对应一个。任务未生成的格式不会有对应的键,而不是空字符串。
- Name
3mf- Type
- string
- Description
多色 3MF 文件。
- Name
- progress
- Type
- integer
- Description
任务完成的百分比。任务开始前为
0,成功后为100。
- Name
- status
- Type
- string
- Description
任务状态,取值为
PENDING、IN_PROGRESS、SUCCEEDED或FAILED之一。
- Name
- preceding_tasks
- Type
- integer
- Description
排在该任务之前的队列中的任务数量。该值仅在任务处于
PENDING状态时才有意义。
- Name
- created_at
- Type
- timestamp
- Description
任务创建的时间,以 Unix 毫秒表示。
- Name
- started_at
- Type
- timestamp
- Description
任务开始的时间,以 Unix 毫秒表示。任务开始前为
0。
- Name
- finished_at
- Type
- timestamp
- Description
任务完成的时间,以 Unix 毫秒表示。任务完成前为
0。
- Name
- task_error
- Type
- object
- Description
任务失败时的错误详情。参见 Errors。
- Name
- consumed_credits
- Type
- integer
- Description
任务消耗的积分数量。当状态为
PENDING、IN_PROGRESS或SUCCEEDED时存在。对于FAILED的任务,该值为0,因为 Meshy 会在任务失败时退还积分。