Remesh API
Remesh API 讓您能夠對其他 Meshy API(如影象生成 3D 或文字生成 3D)產生的現有 3D 模型進行重構網格,並將其匯出為多種格式。本節將詳細介紹如何使用 Remesh API。
建立 Remesh 任務
此端點用於建立一個新的 Remesh 任務。
如需進行格式轉換和尺寸調整,請使用專用的 Convert API 和 Resize API。以下已棄用的參數仍可繼續使用,但我們建議新的整合使用新的端點。
參數
input_task_id 和 model_url 中只需提供一個,即為必填。如果兩者都提供,則 input_task_id 具有更高優先順序。
- Name
- input_task_id
- Type
- string
- 必選
- Description
您希望進行重拓撲的、已完成的 影象生成 3D 或 文字生成 3D 任務的 ID。 該任務必須是以下任務之一:Text to 3D Preview、Text to 3D Refine、影象生成 3D 或 重新貼圖。此外,其狀態必須為
SUCCEEDED。
- Name
- model_url
- Type
- string
- 必選
- Description
請透過可公開存取的 URL 或 data URI 提供一個供 Meshy 進行重拓撲的 3D 模型。 支援的格式:
.glb、.gltf、.obj、.fbx、.stl。對於 Data URI,請使用 MIME type:
application/octet-stream。
- Name
- target_formats
- Type
- string[]
- 預設值 ["glb"]
- Description
重拓撲後模型的目標格式清單。若省略,則僅產生 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 屬性包含新建立的重拓撲任務的 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,
}
刪除重構網格任務
此 endpoint 將永久刪除一個重構網格任務,包括所有相關的模型和資料。此操作無法復原。
路徑參數
- Name
- id
- Type
- path
- Description
要刪除的重構網格任務的 ID。
回傳值
成功時回傳 200 OK。
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/remesh/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// Returns 200 Ok on success.
獲取 Remesh 任務清單
此端點允許您獲取 Remesh 任務的清單。
參數
- Name
- page_num
- Type
- integer
- 預設值 1
- Description
用於分頁的頁碼。
- Name
- page_size
- Type
- integer
- 預設值 10
- Description
每頁大小限制。最大允許為
50項。
- 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
}
]
流式取得重構網格任務
此 endpoint 使用 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,
}
The Remesh Task Object
Remesh Task 物件表示 Meshy 用於將現有 3D 模型重構網格並匯出為多種格式的工作單元。 該物件具有以下屬性:
Properties
- Name
- id
- Type
- string
- Description
任務的唯一識別碼。雖然我們在實作細節上使用 k-sortable 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
}