重構網格 API
重構網格 API 允許你對由其他 Meshy API(如影象生成 3D 或文字生成 3D)生成的現有 3D 模型進行重構網格,並將其匯出為多種格式。本節將詳細介紹如何使用重構網格 API。
建立 Remesh 任務
此 endpoint 用於建立一個新的 remesh 任務。
該任務將在後台執行。有關通常所需時間,請參閱處理時間。
如需進行格式轉換和尺寸調整,請使用專用的 Convert API 和 Resize API。以下已棄用的參數仍可繼續使用,但我們建議新的整合使用新的 endpoint。
參數
input_task_id 或 model_url 中只有一個是必填的。如果兩者都提供,則 input_task_id 具有更高的優先順序。
- Name
- input_task_id
- Type
- string
- 必選
- Description
您希望 remesh 的已完成的 Image to 3D 或 Text to 3D 任務的 ID。 該任務必須是以下任務之一:Text to 3D Preview、Text to 3D Refine、Image to 3D 或 Retexture。此外,其狀態必須為
SUCCEEDED。
- Name
- model_url
- Type
- string
- 必選
- Description
請透過可公開存取的 URL 或 data URI 為 Meshy 提供一個要進行 remesh 的 3D 模型。 支援的格式:
.glb、.gltf、.obj、.fbx、.stl。對於 Data URI,請使用 MIME type:
application/octet-stream。最大檔案大小:
http或httpsURL 為 400 MB,data:URI 為 100 MB。超過 100 MB 的 GLB、glTF、FBX 或 OBJ 檔案最多可包含 10,000,000 個面。面以三角形計數:一個四邊形計為 2 個,被多次繪製的 mesh 每份副本計一次。超過 100 MB 時,FBX 檔案必須是 7.1 或更高版本的二進位 FBX,且 GLB 或 glTF 檔案不得使用 Draco 壓縮。
- Name
- target_formats
- Type
- string[]
- 預設值 ["glb"]
- Description
remesh 後模型的目標格式清單。如果省略,則僅生成 GLB。
可用值:
glb、fbx、obj、usdz、blend、stl、3mf。
- Name
- topology
- Type
- string
- 預設值 triangle
- Description
指定生成模型的 topology。
可用值:
quad:生成以四邊形為主的 mesh。triangle:生成經過精簡的三角形 mesh。
- Name
- target_polycount
- Type
- integer
- 預設值 30,000
- Description
指定生成模型中的目標多邊形數量。實際多邊形數量可能會因 geometry 的複雜程度而與目標值有所偏差。
有效範圍為 100 到 300,000(含兩端)。
- Name
- decimation_mode
- Type
- integer
- Description
透過設定 面數 等級來啟用自適應精簡。設定後,
target_polycount將被忽略。可用值:
1:自適應 — 超高面數。2:自適應 — 高面數。3:自適應 — 中等面數。4:自適應 — 低面數。
- Name
- resize_height
- Type
- number
- ⚠ 已棄用
- 預設值 0
- Description
將模型調整到指定高度(以公尺為單位)。我們建議改用專用的 Resize API。
auto_size、resize_height和resize_longest_side是互斥的。
- Name
- resize_longest_side
- Type
- number
- ⚠ 已棄用
- 預設值 0
- Description
調整模型尺寸,使其包圍盒最長的一邊等於指定的值(以公尺為單位)。我們建議改用專用的 Resize API。
auto_size、resize_height和resize_longest_side是互斥的。
- Name
- auto_size
- Type
- boolean
- ⚠ 已棄用
- 預設值 false
- Description
當設定為
true時,服務將使用 AI 視覺自動估算物體的真實世界高度,並據此調整模型尺寸。我們建議改用專用的 Resize API。auto_size、resize_height和resize_longest_side是互斥的。
auto_size = true- Name
- origin_at
- Type
- string
- ⚠ 已棄用
- 預設值 bottom
- Description
原點的位置。我們建議改用專用的 Resize API。
可用值:
bottom、center。
- Name
- convert_format_only
- Type
- boolean
- ⚠ 已棄用
- Description
如果為
true,服務將僅變更輸入模型檔案的格式,忽略其他輸入項,如topology、resize_height和target_polycount。我們建議改用專用的 Convert API。如果
convert_format_only設定為true,則必須提供target_formats。
- Name
- alpha_thumbnail
- Type
- boolean
- 預設值 false
- Description
當設定為
true時,任務將額外渲染預覽圖的透明背景(RGBA)版本,並在 GET 回應中以alpha_thumbnail_url返回。現有的thumbnail_url欄位保持不變。
返回值
回應中的 result 屬性包含新建立的 remesh 任務的 id。
失敗模式
- Name
400 - Bad Request- Description
請求不可接受。常見原因:
- 缺少參數:必須提供
model_url或input_task_id其中之一。 - 輸入任務無效:
input_task_id必須指向來自受支援模型的成功任務。 - 模型格式無效:
model_url指向的檔案副檔名不受支援。 - URL 無法存取:無法下載
model_url指向的檔案。 - 模型檔案過大:
model_url檔案超過 400 MB(http或httpsURL)或 100 MB(data:URI)。 - 面數過多:
model_url檔案超過 100 MB 且面數超過 10,000,000。請減少面數後重新傳送檔案。 - ASCII FBX 超過 100 MB:
model_url檔案是超過 100 MB 的 ASCII FBX。請將其以二進位 FBX 或 GLB 格式傳送。 - 模型檔案無法讀取:
model_url檔案超過 100 MB 且其標頭資訊無法讀取,例如經過 Draco 壓縮的 GLB 或 glTF,或低於 7.1 版本的二進位 FBX。 - 模型標頭過於複雜:
model_url檔案超過 100 MB,且其標頭包含過多的 mesh、節點或記錄,無法完成檢查。請減少檔案中的物件數量後重新傳送。 - topology 無效:
topology參數無效。 - 參數互斥:
auto_size和resize_height不能同時設定。
- 缺少參數:必須提供
- Name
401 - Unauthorized- Description
身分驗證失敗。請檢查您的 API key。
- Name
402 - Payment Required- Description
credits 不足,無法執行此任務。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# Basic remesh with custom formats and resize
curl https://api.meshy.ai/openapi/v1/remesh \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"target_formats": ["glb", "fbx"],
"topology": "quad",
"target_polycount": 50000,
"resize_height": 1.0,
"origin_at": "bottom"
}'
# Quad remesh with auto-size
curl https://api.meshy.ai/openapi/v1/remesh \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"target_formats": ["glb", "fbx"],
"topology": "quad",
"target_polycount": 50000,
"auto_size": true
}'
Response
{
"result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}
取得重構網格任務
此 endpoint 透過 ID 取得一個 remesh 任務。
參數
- Name
- id
- Type
- path
- Description
要取得的 remesh 任務的 ID。
回傳
Remesh Task 物件。
Request
curl https://api.meshy.ai/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "remesh",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
"usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
"blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
"stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
}
刪除 Remesh 任務
此 endpoint 會永久刪除一個 remesh 任務,包括所有關聯的模型和資料。此操作不可逆。
路徑參數
- Name
- id
- Type
- path
- Description
要刪除的 remesh 任務的 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/remesh/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."
}
取得 Remesh 任務列表
此 endpoint 允許您取得 Remesh 任務列表。
參數
- Name
- page_num
- Type
- integer
- 預設值 1
- Description
用於分頁的頁碼。
- Name
- page_size
- Type
- integer
- 預設值 10
- Description
每頁數量限制。最多允許
100項。
- Name
- sort_by
- Type
- string
- Description
用於排序的欄位。
可用值:
+created_at:依建立時間升冪排列。-created_at:依建立時間降冪排列。
回傳值
回傳分頁的 Remesh 任務物件 列表。
Request
curl https://api.meshy.ai/openapi/v1/remesh?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
[
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "remesh",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
"usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
"blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
"stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null
}
]
流式取得重構網格任務
此端點使用 Server-Sent Events(SSE)串流傳輸重構網格任務的即時更新。
參數
- Name
- id
- Type
- path
- Description
要串流取得的重構網格任務的唯一識別碼。
回傳
以 Server-Sent Events 的形式回傳一個重構網格任務物件串流。
對於 PENDING 或 IN_PROGRESS 狀態的任務,回應串流中只會包含必要的 progress 和 status 欄位。
Request
curl -N https://api.meshy.ai/openapi/v1/remesh/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": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"progress": 0,
"status": "PENDING"
}
event: message
data: {
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "remesh",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
"usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
"blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
"stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": null,
}
Remesh 任務物件
Remesh 任務物件表示 Meshy 用於將現有 3D 模型進行重新拓撲並匯出為多種格式的工作單元。 該物件具有以下屬性:
屬性
- Name
- id
- Type
- string
- Description
任務的唯一識別碼。雖然我們在實作細節上使用 k-可排序 UUID 作為任務 id,但你不應對 id 的格式做任何假設。
- Name
- type
- Type
- string
- Description
Remesh 任務的類型。該值為
remesh。
- Name
- model_urls
- Type
- object
- Description
Meshy 生成的帶貼圖 3D 模型檔案的可下載 URL。如果某種格式未被生成,則該格式對應的屬性將被省略,而不是回傳空字串。
- Name
glb- Type
- string
- Description
GLB 檔案的可下載 URL。
- Name
fbx- Type
- string
- Description
FBX 檔案的可下載 URL。
- Name
obj- Type
- string
- Description
OBJ 檔案的可下載 URL。
- Name
usdz- Type
- string
- Description
USDZ 檔案的可下載 URL。
- Name
blend- Type
- string
- Description
Blender 檔案的可下載 URL。
- Name
stl- Type
- string
- Description
STL 檔案的可下載 URL。
- Name
3mf- Type
- string
- Description
3MF 檔案的可下載 URL。僅當透過
target_formats請求了3mf時才會出現。
- Name
- thumbnail_url
- Type
- string
- Description
由重新拓撲後的模型渲染生成的預覽圖片的可下載 URL。
- Name
- alpha_thumbnail_url
- Type
- string
- Description
thumbnail_url的透明背景(RGBA)版本的可下載 URL。僅當任務建立時設定了alpha_thumbnail: true且透明預覽成功渲染時才會出現;否則將省略此欄位。
- 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(失敗時 積分 將被退還)。
Example Remesh Task Object
{
"id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
"type": "remesh",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
"fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
"usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
"blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
"stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
"progress": 100,
"status": "SUCCEEDED",
"preceding_tasks": 0,
"created_at": 1699999999000,
"started_at": 1700000000000,
"finished_at": 1700000001000,
"task_error": {
"message": ""
},
"consumed_credits": 5
}