多色打印 API
将 3D 模型 Convert 为用于 3D 打印的多色 3MF 格式,调色板最多可配置 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。
- 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:将颜色扁平化为干净、统一的区域,呈现风格化外观。生成的文件更小。
返回值
响应中的 result 属性包含新创建的 3D 打印任务的 id。
失败模式
- Name
400 - Bad Request- Description
请求不可接受。常见原因:
- 缺少参数:必须提供
model_url或input_task_id中的一个。 - 模型格式无效:
model_url指向的文件扩展名不受支持(仅支持.glb和.fbx)。 - URL 无法访问:无法下载
model_url指向的文件。 - 输入任务无效:
input_task_id必须指向一个成功的任务。 - max_colors 无效:值必须介于 1 到 16 之间。
- style 无效:值必须为
realistic或cartoon。
- 缺少参数:必须提供
- Name
401 - Unauthorized- Description
身份验证失败。请检查您的 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。
返回值
成功时返回 200 OK。
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
// Returns 200 Ok on success.
获取多色 3D 打印任务列表
此 endpoint 允许您获取多色 3D 打印任务的列表。
参数
可选属性
- Name
- page_num
- Type
- integer
- Description
用于分页的页码。起始值和默认值均为
1。
- Name
- page_size
- Type
- integer
- Description
每页数量限制。默认值为
10项,最大允许值为50项。
- 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
}