Auto Split API
將 3D 模型拆分為可分別列印的多個部件——可自動拆分,也可依你指定的部件名稱或依顏色區域拆分——並可選擇加入連接件;切割後留下的薄弱區域一律會加固,確保每個部件都能以實心方式列印。
建立 Auto Split 任務
此 endpoint 用於建立一個新的 Auto Split 任務。該任務會將先前任務生成的模型切割為可分別列印的多個部件,並返回切分後的模型,其中每個部件都是檔案中的獨立物件。
參數
- Name
- input_task_id
- Type
- string
- 必選
- Description
要拆分其模型的成功任務的 ID。支援的任務類型:Image to 3D、Multi-Image to 3D、Text to 3D(預覽版)、Remesh、Convert 以及 Resize。該任務的狀態必須為
SUCCEEDED,且其模型必須由 Meshy 6 或 Meshy 7 生成(ai_model為meshy-6、meshy-7或latest)。不支援 low-poly 和 Smart Topology(meshy-t2)模型。
- Name
- mode
- Type
- string
- 預設值 auto
- Description
模型如何被劃分為多個部件。
可選值:
auto:由 Meshy 自行選擇切割方式,prompt會被忽略。by_parts:沿著你在prompt中指定的結構部件進行切割,例如頭部、手臂和軀幹。by_color:沿著你在prompt中指定的顏色區域進行切割。需要輸入內容由已上傳圖片生成(Image to 3D 或 Multi-Image to 3D);其他輸入會被拒絕並返回400。
mode = by_parts or by_color- Name
- prompt
- Type
- string
- 必選
- Description
描述要拆分成的部件,可使用任意語言。Meshy 會從中讀取 1 到 10 個部件名稱,因此請直接命名各個部件而不是描述整個模型——例如
split into the figure and the base,或head, torso, left arm, right arm, legs。最多 600 個字元。有兩種失敗情形:如果描述看起來是要拆分,但命名的部件少於兩個(例如split into individual parts),會被拒絕並返回400,且不會計費;如果 Meshy 完全無法理解該描述,則會回退為auto,任務仍會執行並計費,其回應中會帶有prompt_ignored: true。
- Name
- target_formats
- Type
- array
- 預設值 ["glb"]
- Description
要匯出的拆分模型格式。在每種格式中,每個部件都是一個獨立物件。系統始終會生成
glb格式並在model_urls中返回;如需其他格式,請在此列出。可選值:
glb、obj、fbx、usdz、blend、3mf。
- Name
- layout
- Type
- string
- 預設值 assembled
- Description
各部件在每種輸出格式以及 thumbnail 中的排列方式。
可選值:
assembled:部件保持在原始模型中的位置。on_plate:部件被平鋪展開擺放在列印平台上,可直接用於切片——與 Web App 中的 On Plate 檢視排列方式相同。
在這兩種佈局中,匯出的檔案裡每個部件都是一個物件,且僅包含這些物件:切割後殘留的塌陷薄片或類似點狀的碎片會在匯出前被移除,因此檔案中出現的每個物件都是可列印的。
- Name
- connectors
- Type
- boolean
- 預設值 false
- Description
在每個切割處新增榫卯連接件,使列印出的部件能夠拼合在一起。
connectors = true- Name
- connector_type
- Type
- string
- 預設值 cube
- Description
每個切割面上連接件的形狀。
可選值:
cube、cylinder。
- Name
- connector_size
- Type
- number
- 預設值 0.5
- Description
連接件相對於切割面的大小。
有效範圍:
0.1到0.8。
- Name
- connector_height
- Type
- number
- 預設值 0.1
- Description
連接件相對於切割面向外延伸的距離比例。
有效範圍:
0.1到0.8。
返回值
回應的 result 屬性包含新建立的 Auto Split 任務的 id。
失敗情形
- Name
400 - Bad Request- Description
請求無法被接受。常見原因包括:
- 缺少 prompt:當
mode為by_parts或by_color時,必須提供prompt。 - prompt 命名的部件少於兩個:
by_parts/by_color至少需要命名兩個部件(例如head, torso, base);諸如split into individual parts這類泛泛的指令會被拒絕。此情況不會計費。 - 不受支援的輸入任務:
input_task_id必須指向一個由 Meshy 6 或 Meshy 7 生成的、類型受支援的成功任務。 - 輸入帶有貼圖:輸入模型帶有 texture。目前僅支援不帶 texture 的模型。
- 缺少參考圖片:
by_color需要輸入內容由已上傳圖片生成。 - 不受支援的格式:
target_formats中包含stl。 - 連接件參數超出範圍:
connector_size或connector_height超出0.1到0.8的範圍。
- 缺少 prompt:當
- Name
401 - Unauthorized- Description
身份驗證失敗,請檢查你的 API key。
- Name
402 - Payment Required- Description
credits 不足,無法執行此任務。
- Name
404 - Not Found- Description
input_task_id不存在,或不屬於你的帳戶。
- Name
429 - Too Many Requests- Description
你已超出速率限制。
by_parts和by_color請求還共用一個 prompt 解析限制:每個帳戶每分鐘最多 12 次請求。
- Name
503 - Service Unavailable- Description
基於 prompt 的拆分方式(
by_parts和by_color)暫時不可用。請稍後重試,或使用不受影響的mode: "auto"。此情況不會計費。
Request
# Simple request: let Meshy choose the cuts
curl https://api.meshy.cn/openapi/v1/print/split \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578"
}'
# Advanced request: name the parts, add connectors, export glb and obj
curl https://api.meshy.cn/openapi/v1/print/split \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"mode": "by_parts",
"prompt": "split into the figure and the base",
"target_formats": ["glb", "obj"],
"layout": "on_plate",
"connectors": true,
"connector_type": "cylinder",
"connector_size": 0.4
}'
Response
{
"result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}
取得 Auto Split 任務
此端點用於根據 ID 取得 Auto Split 任務。
參數
- Name
- id
- Type
- path
- Description
要取得的 Auto Split 任務的 ID。
回傳值
Auto Split 任務物件。
Request
curl https://api.meshy.cn/openapi/v1/print/split/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-split",
"model_urls": {
"glb": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"obj": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***"
},
"thumbnail_url": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
"part_count": 4,
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000082000,
"task_error": null,
"consumed_credits": 10
}
刪除一個 Auto Split 任務
此 endpoint 將永久刪除一個 Auto Split 任務,包括所有相關的模型和資料。此操作無法復原。
路徑參數
- Name
- id
- Type
- path
- Description
要刪除的 Auto Split 任務的 ID。
回傳值
成功時回傳 200 OK。
Request
curl --request DELETE \
--url https://api.meshy.cn/openapi/v1/print/split/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// Returns 200 Ok on success.
List Auto Split Tasks
此端點允許您檢索 Auto Split 任務列表。
參數
可選屬性
- Name
- page_num
- Type
- integer
- Description
用於分頁的頁碼。起始值和預設值均為
1。
- Name
- page_size
- Type
- integer
- Description
每頁數量限制。預設為
10項。最多允許100項;超出的值將被限制為100。
- Name
- sort_by
- Type
- string
- Description
用於排序的欄位。可用值:
+created_at:依建立時間升冪排序。-created_at:依建立時間降冪排序。
回傳值
回傳一個分頁的 Auto Split 任務物件 列表。
Request
curl https://api.meshy.cn/openapi/v1/print/split?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
[
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-split",
"model_urls": {
"glb": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***"
},
"thumbnail_url": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
"part_count": 4,
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000082000,
"task_error": null,
"consumed_credits": 10
}
]
流式取得 Auto Split 任務
此端點使用 Server-Sent Events(SSE)以串流方式傳輸 Auto Split 任務的即時更新。
參數
- Name
- id
- Type
- path
- Description
要進行串流傳輸的 Auto Split 任務的唯一識別碼。
回傳值
以 Server-Sent Events 的形式回傳一個 Auto Split 任務物件 的串流。
每個 message 事件都會攜帶由 取得 Auto Split 任務 回傳的完整任務物件,包括 consumed_credits、時間戳記以及 prompt_ignored;當任務處於 PENDING 或 IN_PROGRESS 狀態時,帧與帧之間會變化的欄位是 progress、status、started_at 和 preceding_tasks,而 model_urls、thumbnail_url、part_count 和 parts 則會在任務到達 SUCCEEDED 狀態後才出現。error 事件僅攜帶 status_code 和 message,因此在讀取 status 之前,應先依據事件名稱進行分支處理。
Request
curl -N https://api.meshy.cn/openapi/v1/print/split/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 (other task fields omitted here for brevity;
// each frame is 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-split",
"model_urls": {
"glb": "https://assets.meshy.cn/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/model.glb?Expires=***"
},
"thumbnail_url": "https://assets.meshy.cn/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/preview.png?Expires=***",
"part_count": 4,
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000082000,
"task_error": null,
"consumed_credits": 10
}
Auto Split 任務物件
Auto Split 任務只包含以下屬性。其他任務物件所包含的生成提示詞欄位(name、object_prompt、texture_prompt 等)、單一的 model_url,以及 texture_urls,在拆分任務中都不會被填入,也不會回傳。隨任務執行而逐步填入的屬性(thumbnail_url、model_urls、時間戳)則始終存在,在有值之前為空,因此鍵的集合在 PENDING 和 SUCCEEDED 之間不會發生變化。
- Name
- id
- Type
- string
- Description
任務的唯一識別碼。雖然我們在實作細節上使用 k-sortable UUID 作為任務 id,但你不應該對 id 的格式做任何假設。
- Name
- type
- Type
- string
- Description
任務的類型。此值為
print-split。
- Name
- model_urls
- Type
- object
- Description
拆分模型的可下載 URL,每種請求的格式對應一個。檔案中的每個部件都是一個獨立的物件。如果未請求某種格式,則該格式對應的屬性將被省略。
- Name
glb- Type
- string
- Description
GLB 格式的拆分模型可下載 URL。
- Name
obj- Type
- string
- Description
OBJ 格式的拆分模型可下載 URL。
- Name
fbx- Type
- string
- Description
FBX 格式的拆分模型可下載 URL。
- Name
usdz- Type
- string
- Description
USDZ 格式的拆分模型可下載 URL。
- Name
blend- Type
- string
- Description
Blender 格式的拆分模型可下載 URL。
- Name
3mf- Type
- string
- Description
3MF 格式的拆分模型可下載 URL。
- Name
- thumbnail_url
- Type
- string
- Description
拆分模型渲染預覽圖的可下載 URL,其中每個部件以不同顏色顯示,按所請求的
layout排列。
- Name
- prompt_ignored
- Type
- boolean
- Description
當
by_parts或by_color請求的prompt未指定任何部件名稱時,此值為true,表示 Meshy 轉而自動拆分了模型——結果中的部件名稱是 Meshy 產生的,而非你提供的。從PENDING狀態起即存在。對於auto任務,以及提示詞被正確遵循的情況下,此欄位會被省略。
- Name
- part_count
- Type
- integer
- Description
拆分模型中可列印部件的數量——匯出檔案中每個物件對應一個部件。分割過程中無法轉換為可列印部件的坍縮碎片會在匯出前從檔案中移除,不計入此數量。
- Name
- progress
- Type
- integer
- Description
任務的進度。如果任務尚未開始,此屬性為
0。一旦任務成功完成,此屬性將變為100。
- Name
- status
- Type
- string
- Description
任務的狀態。可能的值為
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED之一。
- 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 數量。此屬性始終存在:任務一旦被接受即為
10,而對於FAILED任務則為0,因為失敗時費用會被退還。在任務仍處於PENDING狀態時刪除任務,同樣會退還費用。
The Auto Split Task Object
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "print-split",
"model_urls": {
"glb": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"obj": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***"
},
"thumbnail_url": "https://assets.meshy.cn/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
"part_count": 4,
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000082000,
"task_error": null,
"consumed_credits": 10
}