多色列印 API
格式轉換 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。
- 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必須指向一個成功的任務。 - max_colors 無效:數值必須介於 1 到 16 之間。
- style 無效:數值必須為
realistic或cartoon。 - 無顏色來源:輸入模型沒有基礎顏色 texture(
realistic需要每個 mesh 部件上都有一個帶 UV 的基礎顏色 texture)且沒有頂點顏色(cartoon兩者皆可接受)。請先為模型加入 texture,或對具有頂點顏色的模型使用cartoon。.fbx上傳檔案會在任務將其規範化後進行檢查,如果失敗會回傳model_missing_texture。
- 缺少參數:必須提供
- Name
401 - Unauthorized- Description
身份驗證失敗。請檢查您的 API 金鑰。
- Name
402 - Payment Required- Description
執行此任務所需的積分不足。
- 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 狀態的任務將被刪除,建立時所消耗的積分將被退還。
已處於 IN_PROGRESS 狀態的任務無法被刪除:該請求會被拒絕並回傳 409 Conflict,任務將繼續執行。已經開始由工作節點處理的任務所消耗的積分是不可退還的,因此在執行過程中刪除該任務會讓你同時損失積分和結果。請等待其進入 SUCCEEDED、FAILED 或 CANCELED 狀態後再刪除。
處於終止狀態(SUCCEEDED、FAILED 或 CANCELED)的任務將被刪除,且不會退還積分。
回傳值
成功時回傳 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 列印任務清單
此端點允許你取得多色 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
任務的 progress。如果任務尚未開始,此屬性將為
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
此任務消耗的 積分 數量。當任務狀態為
PENDING、IN_PROGRESS或SUCCEEDED時會顯示此欄位。對於FAILED的任務,回傳0(失敗時 積分 會被退還)。
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
}