骨骼綁定 API

骨骼綁定 API 可讓您透過程式化方式為 3D 人形模型新增骨骼(骨架),並將網格綁定到骨架上,使其能夠製作動畫。如需為已綁定的角色套用動畫,請參閱動畫 API

請注意,目前程式化骨骼綁定僅適用於標準人形(雙足)資產,且需具備清楚的四肢與身體結構。


POST/openapi/v1/rigging

建立骨骼绑定任務

此介面可讓您為指定的 3D 模型建立新的骨骼绑定任務。任務完成後,將回傳標準格式且已完成骨骼绑定的角色,並可選擇提供基礎的走路/跑步動畫。

目前,自動骨骼绑定不適用於以下模型:

  • 無貼圖網格
  • 非人形資產
  • 人形但四肢和身體結構不清晰的資產

參數

  • Name
    input_task_id
    Type
    string
    必选
    Description

    需要進行骨骼绑定的輸入任務 ID。目前僅支援帶有貼圖的人形模型。

  • Name
    model_url
    Type
    string
    必选
    Description

    請透過公開可存取的 URL 或 Data URI 提供需要進行骨骼绑定的 3D 模型。目前僅支援帶有貼圖的人形 GLB 檔案(.glb 格式)。

  • Name
    height_meters
    Type
    number
    默认值 1.7
    Description

    角色模型的大致身高(單位:公尺)。有助於縮放和骨骼绑定精度。必須為正數。

  • Name
    texture_image_url
    Type
    string
    Description

    模型的 UV 展開基礎色貼圖。需為公開可存取的 URL 或 Data URI。目前僅支援 .png 格式。

回傳值

回應的 result 欄位包含新建立骨骼绑定任務的任務 id

失敗模式

  • Name
    400 - Bad Request
    Description

    請求不合法。常見原因:

    • 缺少參數:必須提供 model_urlinput_task_id 其中之一。
    • 模型格式無效model_url 指向的檔案副檔名不受支援(僅支援 .glb 格式)。
    • URL 無法存取model_url 無法下載。
    • 輸入任務無效input_task_id 未指向有效的 API 任務。
    • 面數超限:輸入模型面數超過 300,000。請先使用 重構網格 API 降低面數後再進行骨骼绑定。
  • Name
    401 - Unauthorized
    Description

    驗證失敗。請檢查您的 API 金鑰。

  • Name
    402 - Payment Required
    Description

    點數不足,無法執行此任務。

  • Name
    422 - Unprocessable Entity
    Description

    姿態估計失敗。提供的模型可能不是有效的人形角色。

  • Name
    429 - Too Many Requests
    Description

    您已超出請求頻率限制。

请求

POST
/openapi/v1/rigging
# 从 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
  }'

响应

{
  "result": "018b314a-a1b5-716d-c222-2f1776f7f579"
}

GET/openapi/v1/rigging/:id

取得骨骼綁定任務

此端點可讓您透過有效的任務 id 取得骨骼綁定任務。請參閱骨骼綁定任務物件了解包含的屬性。

參數

  • Name
    id
    Type
    path
    Description

    要取得的骨骼綁定任務的唯一識別碼。

回傳

回應包含骨骼綁定任務物件。詳情請查看骨骼綁定任務物件部分。

请求

GET
/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579
curl https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579 
  -H "Authorization: Bearer ${YOUR_API_KEY}"

响应

{
  "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
}

DELETE/openapi/v1/rigging/:id

刪除骨骼綁定任務

此端點可永久刪除一個骨骼綁定任務,包括所有相關的模型和資料。此操作無法復原。

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的骨骼綁定任務 ID。

回傳值

成功時會傳回 200 OK

请求

DELETE
/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579
curl --request DELETE \
  --url https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

响应

// 成功则返回 200 Ok。
GET/openapi/v1/rigging/:id/stream

串流取得骨骼綁定任務

此端點使用伺服器傳送事件 (SSE) 串流傳輸骨骼綁定任務的即時更新。

參數

  • Name
    id
    Type
    path
    Description

    要以串流傳輸的骨骼綁定任務唯一識別碼。

回傳

以伺服器傳送事件的形式回傳骨骼綁定任務物件的串流。

對於PENDINGIN_PROGRESS狀態的任務,回應串流將只包含必要的progressstatus欄位。

请求

GET
/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579/stream
curl -N https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579/stream 
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应流

// 错误事件示例
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// 消息事件示例说明了任务进度
// 对于PENDING或IN_PROGRESS状态的任务,响应流不会包含所有字段
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
}

骨骼綁定任務物件

骨骼綁定任務物件代表角色骨骼綁定的工作單元。

屬性

  • 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

    任務進度(0-100)。尚未開始時為0,成功時為100

  • Name
    created_at
    Type
    timestamp
    Description

    任務建立時的時間戳(自 1970 年 1 月 1 日 UTC 以來的毫秒數)。

  • 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 物件參考,請查看錯誤處理

  • Name
    consumed_credits
    Type
    integer
    Description

    此任務消耗的積分數。當任務狀態為 PENDINGIN_PROGRESSSUCCEEDED 時返回。對於 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時有意義。

绑定任务对象示例

{
  "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
}