骨骼綁定 API
骨骼綁定 API 讓您能夠以程式化方式為 3D 人形模型加入骨架(armature),並將網格綁定至該骨架上,使其能夠進行動畫。有關如何為已完成骨骼綁定的角色套用動畫,請參閱 動畫 API。
請注意,目前程式化骨骼綁定僅在具有清楚定義四肢和身體結構的標準人形(雙足)資產上效果良好。
建立骨骼綁定任務
此 endpoint 允許您為給定的 3D 模型建立一個新的骨骼綁定任務。任務成功完成後,將提供標準格式的骨骼綁定角色,並可選擇性提供基礎的行走/跑步動畫。
目前,自動骨骼綁定不適用於以下模型:
- 未貼圖的網格
- 非人形資產
- 肢體和身體結構不清晰的人形資產
使用 input_task_id 時,面數超過 300,000 的模型不支援骨骼綁定。請使用 Remesh API 在骨骼綁定前降低面數。
使用 model_url 時,角色的正面必須朝向 +Z 軸(標準的 glTF 前方方向)。朝向其他軸的模型將導致姿態估計失敗。
參數
input_task_id 和 model_url 中只需提供一個,此為必填項目。如果兩者都提供,則 input_task_id 具有更高的優先順序。
- Name
- input_task_id
- Type
- string
- 必選
- Description
需要進行骨骼綁定的輸入任務。我們目前支援已貼圖的人形模型。
- Name
- model_url
- Type
- string
- 必選
- Description
請透過公開可存取的 URL 或 Data URI 提供一個 3D 模型供 Meshy 進行骨骼綁定。我們目前支援已貼圖的人形 GLB 檔案(
.glb格式)。
- Name
- height_meters
- Type
- number
- 預設值 1.7
- Description
角色模型的大致高度(以公尺為單位)。這有助於提高縮放和骨骼綁定的準確性。它必須是一個正數。
- Name
- texture_image_url
- Type
- string
- Description
模型經過 UV 展開的基礎顏色 texture 圖像。可以是公開可存取的 URL 或 Data URI。我們目前支援
.png格式。
回傳值
回應中的 result 屬性包含新建立的骨骼綁定任務的任務 id。
失敗模式
- Name
400 - Bad Request- Description
請求不可接受。常見原因:
- 缺少參數:必須提供
model_url或input_task_id之一。 - 模型格式無效:
model_url指向的檔案副檔名不受支援(僅支援 .glb)。 - URL 無法存取:無法下載
model_url指向的檔案。 - 輸入任務無效:
input_task_id未指向一個有效的 API 任務。 - 面數超限:輸入模型的面數超過 300,000。請使用 Remesh API 在骨骼綁定前降低面數。
- 缺少參數:必須提供
- Name
401 - Unauthorized- Description
Authentication 失敗。請檢查您的 API key。
- Name
402 - Payment Required- Description
credits 不足,無法執行此任務。
- Name
422 - Unprocessable Entity- Description
姿態估計失敗。提供的模型可能不是有效的人形角色。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# Rig a model from a URL
curl https://api.meshy.ai/openapi/v1/rigging \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"model_url": "YOUR_MODEL_URL_OR_DATA_URI",
"height_meters": 1.8
}'
Response
{
"result": "018b314a-a1b5-716d-c222-2f1776f7f579"
}
獲取骨骼綁定任務
此 endpoint 允許您根據有效的任務 id 獲取骨骼綁定任務。請參閱骨骼綁定任務物件以查看包含哪些屬性。
參數
- Name
- id
- Type
- path
- Description
要獲取的骨骼綁定任務的唯一識別碼。
返回值
回應包含骨骼綁定任務物件。請查看骨骼綁定任務物件部分了解詳情。
Request
curl https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"consumed_credits": 5,
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.fbx?Expires=...",
"rigged_character_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.glb?Expires=...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.glb?Expires=...",
"walking_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.fbx?Expires=...",
"walking_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin_armature.glb?Expires=...",
"running_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.glb?Expires=...",
"running_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.fbx?Expires=...",
"running_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin_armature.glb?Expires=..."
}
},
"preceding_tasks": 0
}
刪除骨骼綁定任務
此 endpoint 會永久刪除一個骨骼綁定任務,包括所有相關的模型和資料。此操作不可復原。
路徑參數
- Name
- id
- Type
- path
- Description
要刪除的骨骼綁定任務的 ID。
返回值
成功時返回 200 OK。
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// Returns 200 Ok on success.
列出骨骼綁定任務
返回呼叫者的骨骼綁定任務的分頁列表,按最新排序。透過 page_num 和 page_size 進行標準分頁。
請注意,透過 API 建立的任務由 API 進行管理——它們不會出現在網頁應用程式的「我的資產」中。當你不再擁有某個任務的 ID 時,可使用此 endpoint 查找該任務。
Request
curl "https://api.meshy.ai/openapi/v1/rigging?page_num=1&page_size=20" \
-H "Authorization: Bearer ${YOUR_API_KEY}"
流式取得骨骼綁定任務
此 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/rigging/018b314a-a1b5-716d-c222-2f1776f7f579/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": "018b314a-a1b5-716d-c222-2f1776f7f579",
"progress": 0,
"status": "PENDING"
}
event: message
data: {
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"progress": 50,
"status": "IN_PROGRESS"
}
event: message
data: { // Example of a SUCCEEDED task stream item, mirroring The Rigging Task Object structure
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"consumed_credits": 5,
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/.../Character_output.fbx?...",
"rigged_character_glb_url": "https://assets.meshy.ai/.../Character_output.glb?...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin.glb?...",
"walking_fbx_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin.fbx?...",
"walking_armature_glb_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin_armature.glb?...",
"running_glb_url": "https://assets.meshy.ai/.../Animation_Running_withSkin.glb?...",
"running_fbx_url": "https://assets.meshy.ai/.../Animation_Running_withSkin.fbx?...",
"running_armature_glb_url": "https://assets.meshy.ai/.../Animation_Running_withSkin_armature.glb?..."
}
},
"preceding_tasks": 0
}
The Rigging Task Object
骨骼綁定任務物件表示為角色進行骨骼綁定的工作單元。
屬性
- Name
- id
- Type
- string
- Description
任務的唯一識別碼。
- Name
- type
- Type
- string
- Description
骨骼綁定任務的類型。取值為
rig。
- Name
- status
- Type
- string
- Description
任務的狀態。可能的取值:
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED。
- Name
- progress
- Type
- integer
- Description
任務的 progress(0-100)。未開始時為
0,成功時為100。
- Name
- created_at
- Type
- timestamp
- Description
任務建立時的時間戳(自紀元起的毫秒數)。
timestamp 表示自 1970 年 1 月 1 日 UTC 起經過的毫秒數,遵循 RFC 3339
標準。 例如,2023 年 9 月 1 日星期五 GMT 時間 12:00:00 PM 表示為1693569600000。這適用於 Meshy API 中的所有 timestamp。
- Name
- started_at
- Type
- timestamp
- Description
任務開始處理時的時間戳(自紀元起的毫秒數)。未開始時為
0。
- Name
- finished_at
- Type
- timestamp
- Description
任務完成時的時間戳(自紀元起的毫秒數)。未完成時為
0。
- Name
- expires_at
- Type
- timestamp
- Description
任務結果資產過期並可能被刪除時的時間戳(自紀元起的毫秒數)。
- Name
- task_error
- Type
- object
- Description
失敗任務的錯誤詳情。有關完整的
task_error物件參考,請參閱 Errors。
- Name
- consumed_credits
- Type
- integer
- Description
此任務消耗的積分數量。當任務狀態為
PENDING、IN_PROGRESS或SUCCEEDED時會顯示。對於FAILED任務返回0(失敗時會退還積分)。
- Name
- result
- Type
- object
- Description
如果任務狀態為
SUCCEEDED,則包含輸出資產的 URL,否則為null。- Name
rigged_character_fbx_url- Type
- string
- Description
FBX 格式的骨骼綁定角色的可下載 URL。
- Name
rigged_character_glb_url- Type
- string
- Description
GLB 格式的骨骼綁定角色的可下載 URL。
- Name
basic_animations- Type
- object (optional)
- Description
包含預設動畫的 URL(例如,如果
generate_basic_animations隱式為 true 或預設啟用)。- Name
walking_glb_url- Type
- string
- Description
- GLB 格式(帶蒙皮)行走動畫的可下載 URL。
- Name
walking_fbx_url- Type
- string
- Description
- FBX 格式(帶蒙皮)行走動畫的可下載 URL。
- Name
walking_armature_glb_url- Type
- string
- Description
- GLB 格式行走動畫骨架的可下載 URL。
- Name
running_glb_url- Type
- string
- Description
- GLB 格式(帶蒙皮)跑步動畫的可下載 URL。
- Name
running_fbx_url- Type
- string
- Description
- FBX 格式(帶蒙皮)跑步動畫的可下載 URL。
- Name
running_armature_glb_url- Type
- string
- Description
- GLB 格式跑步動畫骨架的可下載 URL。
- Name
- preceding_tasks
- Type
- integer
- Description
佇列中前面排隊的任務數量。僅當狀態為
PENDING時才有意義。
Example Rigging Task Object
{
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"consumed_credits": 5,
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.fbx?Expires=...",
"rigged_character_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.glb?Expires=...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.glb?Expires=...",
"walking_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.fbx?Expires=...",
"walking_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin_armature.glb?Expires=...",
"running_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.glb?Expires=...",
"running_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.fbx?Expires=...",
"running_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin_armature.glb?Expires=..."
}
},
"preceding_tasks": 0
}