多色列印 API
將 3D 模型格式轉換為多色 3MF 格式,用於 3D 列印,並配備最多可包含 16 種顏色的可配置調色盤。
建立多色 3D 列印任務
此端點會建立一個新的多色 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
可公開存取的
.glb或.fbx模型的 URL,或 GLB 的 base64data:URL(data:model/gltf-binary;base64,...)。.fbx必須以http或httpsURL 的形式傳送。最大檔案大小:
http或httpsURL 為 400 MB,data:URI 為 100 MB。超過 100 MB 的檔案最多可包含 8,000,000 個面。面以三角形計數:一個四邊形計為 2 個面,被多次繪製的 mesh 每份副本計為一次。超過 100 MB 時,FBX 檔案必須是二進位 FBX 7.1 或更高版本,GLB 檔案不得使用 Draco 壓縮。
- 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。
- Name
- max_depth
- Type
- integer
- 預設值 4
- Description
用於將 texture 顏色取樣到 mesh 上的細分深度。數值越高,擷取的顏色細節越精細,但檔案也會更大。僅適用於
realistic風格;cartoon會忽略此參數。有效範圍:
3到6。
- Name
- printer_brand
- Type
- string
- 預設值 bambu
- Description
寫入 3MF 的 slicer 預設所對應的印表機品牌,使檔案能在該品牌的 slicer 中開啟,並比對相應的印表機、耗材和製程設定檔。每個品牌都使用其預設印表機,配備 0.4 mm 噴嘴。
可用取值:
bambu、anycubic、creality、elegoo、flashforge、prusa、qidi、snapmaker、ankermake。
回傳值
回應的 result 屬性包含新建立的 3D 列印任務的 id。
失敗模式
- Name
400 - Bad Request- Description
請求不可接受。常見原因:
- 缺少參數:必須提供
model_url或input_task_id其中之一。 - 模型格式無效:
model_url指向的檔案副檔名不受支援(僅支援.glb和.fbx)。 - URL 無法存取:無法下載
model_url指向的檔案。 - 模型檔案過大:
model_url檔案超過 400 MB(http或httpsURL)或 100 MB(data:URI)。 - 面數過多:
model_url檔案超過 100 MB 且面數超過 8,000,000。請減少面數後重新傳送檔案。 - ASCII FBX 超過 100 MB:
model_url檔案是超過 100 MB 的 ASCII FBX。請將其傳送為二進位 FBX 或 GLB。 - 模型檔案無法讀取:
model_url檔案超過 100 MB,且其檔案標頭無法讀取,例如經過 Draco 壓縮的 GLB,或早於 7.1 版本的二進位 FBX。 - 模型檔案標頭過於複雜:
model_url檔案超過 100 MB,其檔案標頭包含過多需要檢查的 mesh、節點或記錄。請減少檔案中物件的數量後重新傳送。 - 輸入任務無效:
input_task_id必須指向一個成功的任務。 - max_colors 無效:取值必須介於 1 到 16 之間。
- style 無效:取值必須為
realistic或cartoon。 - max_depth 無效:取值必須介於 3 到 6 之間。
- printer_brand 無效:取值必須是上述列出的品牌之一。
- 缺少顏色來源:輸入模型沒有基礎顏色 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 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"
}
取得多色 3D 列印任務
此端點根據 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,任務將繼續執行。對於 worker 已經開始處理的任務,其 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
此任務消耗的積分數量。當任務狀態為
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
}