多色打印 API
Convert 3D 模型为多色 3MF 格式以用于 3D 打印,并可配置最多 16 种颜色的调色板。
创建多色 3D 打印任务
此 endpoint 用于创建一个新的多色 3D 打印任务。该任务将一个 3D 模型转换为适用于 3D 打印的多色 3MF 文件。
参数
input_task_id 和 model_url 中只需提供其中一个。如果两者都提供,则以 input_task_id 为准。
- Name
- input_task_id
- Type
- string
- 必选
- Description
用作输入的已成功任务的 ID。支持的任务类型:Image to 3D、Multi-Image to 3D、Text to 3D、Remesh 和 Retexture。该任务的状态必须为
SUCCEEDED。目前尚不支持使用geometry_resolution: "4k"(Ultra 4K)生成的任务。
- Name
- model_url
- Type
- string
- 必选
- Description
可公开访问的 3D 模型 URL 或 Data URI。我们目前支持
.glb和.fbx格式。
- Name
- max_colors
- Type
- integer
- 默认值 4
- Description
输出调色板中的最大颜色数量。
有效范围:
1到16。
- Name
- style
- Type
- string
- 默认值 realistic
- Description
生成的 3MF 文件的视觉颜色风格。
可用取值:
realistic:直接从模型的 texture 中采样颜色,以获得精细的照片级真实细节。生成的文件较大。cartoon:将颜色平铺为干净、统一的区域,呈现风格化外观。生成的文件较小。
输入必须携带颜色信息:
realistic要求每个 mesh 部件都具有带 UV 坐标的单一底色 texture;cartoon也接受逐顶点颜色。未添加 texture(白模)的模型将被拒绝——参见model_missing_texture。
返回值
响应中的 result 属性包含新创建的 3D 打印任务的 id。
失败模式
- Name
400 - Bad Request- Description
请求不可接受。常见原因:
- 缺少参数:必须提供
model_url或input_task_id之一。 - 模型格式无效:
model_url指向的文件扩展名不受支持(仅支持.glb和.fbx)。 - URL 不可访问:无法下载
model_url。 - 输入任务无效:
input_task_id必须指向一个成功的任务。 - Ultra 4K 输入:输入任务的模型是使用
geometry_resolution: "4k"生成的,而 Multi-Color Print 目前尚不支持该分辨率。 - max_colors 无效:取值必须介于 1 到 16 之间。
- style 无效:取值必须为
realistic或cartoon。 - 没有颜色来源:输入模型没有底色 texture(
realistic需要每个 mesh 部件都具有一个带 UV 的底色 texture),也没有顶点颜色(cartoon两者皆可接受)。请先为模型添加 texture,或对带顶点颜色的模型使用cartoon。.fbx上传文件会在任务对其进行标准化处理后进行检查,若不符合要求则会返回model_missing_texture错误。
- 缺少参数:必须提供
- Name
401 - Unauthorized- Description
Authentication 失败。请检查您的 API key。
- Name
402 - Payment Required- Description
credits 不足,无法执行此任务。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# Convert a 3D model to multi-color 3MF for printing
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
}'
Response
{
"result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}
检索多色 3D 打印任务
此 endpoint 用于根据 ID 检索多色 3D 打印任务。
参数
- Name
- id
- Type
- path
- Description
要检索的 3D 打印任务的 ID。
返回值
3D 打印任务对象。
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
}
删除多色 3D 打印任务
此 endpoint 会永久删除一个多色 3D 打印任务,包括所有相关的模型和数据。此操作不可逆。
路径参数
- Name
- id
- Type
- path
- Description
要删除的多色 3D 打印任务的 ID。
任务状态
仍处于 PENDING 状态的任务将被删除,创建时所消耗的 credits 将被退还。
已处于 IN_PROGRESS 状态的任务无法被删除:该请求会被拒绝并返回 409 Conflict,任务将继续运行。已经开始由工作节点处理的任务所消耗的 credits 是不可退还的,因此在运行过程中删除该任务会让你同时损失 credits 和结果。请等待其进入 SUCCEEDED、FAILED 或 CANCELED 状态后再删除。
处于终止状态(SUCCEEDED、FAILED 或 CANCELED)的任务将被删除,且不会退还 credits。
返回值
成功时返回 200 OK;当任务处于 IN_PROGRESS 状态时返回 409 Conflict。
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 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."
}
获取多色 3D 打印任务列表
此 endpoint 允许你获取多色 3D 打印任务的列表。
参数
可选属性
- Name
- page_num
- Type
- integer
- Description
用于分页的页码。起始值和默认值均为
1。
- Name
- page_size
- Type
- integer
- Description
每页数量限制。默认为
10项。最大允许100项。
- Name
- sort_by
- Type
- string
- Description
用于排序的字段。可用值:
+created_at:按创建时间升序排序。-created_at:按创建时间降序排序。
返回
返回一个分页列表,包含 3D 打印任务对象。
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
}
]
流式获取多色 3D 打印任务
此 endpoint 使用服务器发送事件(Server-Sent Events,SSE)流式传输多色 3D 打印任务的实时更新。
参数
- Name
- id
- Type
- path
- Description
要进行流式传输的多色 3D 打印任务的唯一标识符。
返回值
以 Server-Sent Events 的形式返回一个 3D 打印任务对象 流。
对于 PENDING 或 IN_PROGRESS 状态的任务,响应流中只会包含必要的 progress 和 status 字段。
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.
// For PENDING or IN_PROGRESS tasks, the response stream will not include all fields.
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
}
3D 打印任务对象
- Name
- id
- Type
- string
- Description
任务的唯一标识符。虽然我们在实现细节上使用 k-可排序 UUID 作为任务 id,但你不应对 id 的格式做任何假设。
- Name
- type
- Type
- string
- Description
3D 打印任务的类型。值为
print-multi-color。
- Name
- model_urls
- Type
- object
- Description
Meshy 生成的 3D 模型文件的可下载 URL。如果某种格式未被生成,则该格式对应的属性将被省略,而不是返回空字符串。
- Name
3mf- Type
- string
- Description
多色 3MF 文件的可下载 URL。
- 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
任务创建时的时间戳,以毫秒为单位。
- 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 数量。当任务状态为
PENDING、IN_PROGRESS或SUCCEEDED时会显示此字段。对于FAILED的任务,返回0(失败时 credits 会被退还)。
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
}