Remesh API
Remesh API 讓你能夠對由其他 Meshy API(例如影象生成 3D 或文字生成 3D)產生的現有 3D 模型進行重構網格,並將其匯出為多種格式。本節將詳細介紹如何使用 Remesh 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 的、已完成的 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。
- 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
透過設定 polycount 等級來啟用自適應簡化。設定後,
target_polycount將被忽略。可用值:
1:自適應 —— 超高 polycount。2:自適應 —— 高 polycount。3:自適應 —— 中等 polycount。4:自適應 —— 低 polycount。
- 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
origin 的位置。我們建議改用專用的 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 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"
}
檢索 Remesh 任務
此 endpoint 透過 ID 檢索一個 remesh 任務。
參數
- Name
- id
- Type
- path
- Description
要檢索的 remesh 任務的 ID。
回傳值
Remesh 任務物件。
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,
}
Remesh 任務物件
Remesh 任務物件表示 Meshy 用於將現有 3D 模型重新網格化(remesh)並匯出為各種格式的工作單元。 該物件具有以下屬性:
屬性
- 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
}