重構網格 API
重構網格 API 允許你對由其他 Meshy API(如影象生成 3D 或文字生成 3D)生成的現有 3D 模型進行重構網格,並將其匯出為多種格式。本節將詳細介紹如何使用重構網格 API。
建立 Remesh 任務
此 endpoint 用於建立一個新的 remesh 任務。
如需進行格式轉換和尺寸調整,請使用專用的 Convert API 和 Resize API。下面已 deprecated 的 參數 仍將繼續可用,但我們建議在新的整合中使用新的 endpoint。
參數
input_task_id 和 model_url 中只需提供一個,必須提供其中之一。如果兩者都提供了,則以 input_task_id 為準。
- Name
- input_task_id
- Type
- string
- 必選
- Description
您希望進行 remesh 的、已完成的 影象生成 3D 或 文字生成 3D 任務的 ID。 該任務必須是以下類型之一:Text to 3D Preview、Text to 3D Refine、影象生成 3D 或 重新貼圖。此外,其狀態必須為
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。
- Name
- target_formats
- Type
- string[]
- 預設值 ["glb"]
- Description
remesh 後模型的目標格式清單。若省略,則僅生成 GLB。
可用值:
glb、fbx、obj、usdz、blend、stl、3mf。
- Name
- topology
- Type
- string
- 預設值 triangle
- Description
指定生成模型的 topology。
可用值:
quad:生成以四邊形為主的 網格。triangle:生成經過簡化的三角形 網格。
- Name
- target_polycount
- Type
- integer
- 預設值 30,000
- Description
指定生成模型的目標多邊形數量。實際的多邊形數量可能會因 幾何體 的複雜程度而與目標值有所偏差。
有效取值範圍因 使用者等級 而異:
- 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指定的檔案。 - 無效的 topology:
topology參數無效。 - 互斥 參數:
auto_size和resize_height不能同時設定。
- 缺少 參數:必須提供
- Name
401 - Unauthorized- Description
身份驗證 失敗。請檢查您的 API 金鑰。
- Name
402 - Payment Required- Description
積分 不足,無法執行此任務。
- 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 檢索重構網格任務。
參數
- Name
- id
- Type
- path
- Description
要檢索的重構網格任務的 ID。
返回值
重構網格任務物件。
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
}