動畫 API

用於探索可用動畫並將其套用至已綁定角色的介面。


POST/openapi/v1/animations

建立動畫任務

此端點可讓您建立新任務,將特定動畫動作套用到先前已完成骨骼綁定的角色上。包含後處理選項。

參數

  • Name
    rig_task_id
    Type
    string
    必选
    Description

    成功完成的骨骼綁定任務的id(來自POST /openapi/v1/rigging)。此任務中的角色將會進行動畫處理。

  • Name
    action_id
    Type
    integer
    必选
    Description

    要套用的動畫動作識別碼。查看動畫庫參考以取得可用動畫的完整清單。

  • Name
    post_process
    Type
    object
    Description

    選用的動畫輸出後處理。省略此參數將回傳標準動畫檔案。

仅当 post_process 已设置
  • Name
    operation_type
    Type
    string
    必选
    Description

    要執行的操作類型。可選值:change_fpsfbx2usdzextract_armature

  • Name
    fps
    Type
    integer
    默认值 30
    Description

    目標影格率。僅在operation_typechange_fps時適用。允許的值:24253060

回傳

回應的result屬性包含新建立的動畫任務的id

失敗模式

  • Name
    400 - Bad Request
    Description

    請求不合法。常見原因:

    • 缺少參數rig_task_idaction_id 未提供。
    • 骨骼綁定任務無效rig_task_id 無效或參照了一個失敗/不存在的任務。
    • 動作 ID 無效action_id 不對應任何有效的動畫。
  • Name
    401 - Unauthorized
    Description

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

  • Name
    402 - Payment Required
    Description

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

  • Name
    404 - Not Found
    Description

    找不到 rig_task_id 指定的骨骼綁定任務。

  • Name
    429 - Too Many Requests
    Description

    您已超出請求頻率限制。

请求

POST
/openapi/v1/animations
# 仅使用必需参数为绑定模型添加动画
curl https://api.meshy.ai/openapi/v1/animations \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "rig_task_id": "018b314a-a1b5-716d-c222-2f1776f7f579",
    "action_id": 92
  }'

# 使用后处理更改帧率
curl https://api.meshy.ai/openapi/v1/animations \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "rig_task_id": "018b314a-a1b5-716d-c222-2f1776f7f579",
    "action_id": 92,
    "post_process": {
      "operation_type": "change_fps",
      "fps": 24
    }
  }'

Response

{
  "result": "018c425b-b2c6-727e-d333-3c1887i9h791"
}

GET/openapi/v1/animations/:id

取得動畫任務

此 API 可讓您透過有效的任務 id 取得動畫任務。請參考動畫任務物件查看包含的屬性。

參數

  • Name
    id
    Type
    path
    Description

    要取得的動畫任務唯一識別碼。

回傳

回應包含動畫任務物件。詳細資訊請查看動畫任務物件章節。

请求

GET
/openapi/v1/animations/018c425b-b2c6-727e-d333-3c1887i9h791
curl https://api.meshy.ai/openapi/v1/animations/018c425b-b2c6-727e-d333-3c1887i9h791 
  -H "Authorization: Bearer ${YOUR_API_KEY}"

响应

{
  "id": "018c425b-b2c6-727e-d333-3c1887i9h791",
  "type": "animate",
  "status": "SUCCEEDED",
  "created_at": 1747032440896,
  "progress": 100,
  "started_at": 1747032441210,
  "finished_at": 1747032457530,
  "expires_at": 1747291657530,
  "task_error": {

    "message": ""

  },

  "consumed_credits": 3,
  "result": {
    "animation_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/Animation_Reaping_Swing_withSkin.glb?Expires=...",
    "animation_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/Animation_Reaping_Swing_withSkin.fbx?Expires=...",
    "processed_usdz_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/processed.usdz?Expires=...",
    "processed_armature_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/processed_armature.fbx?Expires=...",
    "processed_animation_fps_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/processed_60fps.fbx?Expires=..."
  },
  "preceding_tasks": 0
}

DELETE/openapi/v1/animations/:id

刪除動畫任務

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

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的動畫任務 ID。

回傳值

成功則回傳 200 OK

请求

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

响应

// 成功则返回 200 Ok。

GET/openapi/v1/animations/:id/stream

串流取得動畫任務

此介面使用伺服器傳送事件 (SSE) 為動畫任務提供即時更新串流。

參數

  • Name
    id
    Type
    path
    Description

    要以串流方式取得的動畫任務唯一識別碼。

回傳

以伺服器傳送事件的形式回傳動畫任務物件的串流。

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

请求

GET
/openapi/v1/animations/018c425b-b2c6-727e-d333-3c1887i9h791/stream
curl -N https://api.meshy.ai/openapi/v1/animations/018c425b-b2c6-727e-d333-3c1887i9h791/stream 
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应流

// 错误事件示例
event: error
data: {
  "status_code": 404,
  "message": "任务未找到"
}

// 消息事件示例展示了任务进度
// 对于PENDING或IN_PROGRESS状态的任务,响应流不会包含所有字段
event: message
data: {
  "id": "018c425b-b2c6-727e-d333-3c1887i9h791",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "018c425b-b2c6-727e-d333-3c1887i9h791",
  "progress": 50,
  "status": "IN_PROGRESS"
}

event: message
data: { // SUCCEEDED任务流项目的示例,反映了动画任务对象的结构
  "id": "018c425b-b2c6-727e-d333-3c1887i9h791",
  "type": "animate",
  "status": "SUCCEEDED",
  "created_at": 1747032440896,
  "progress": 100,
  "started_at": 1747032441210,
  "finished_at": 1747032457530,
  "expires_at": 1747291657530,
  "task_error": {

    "message": ""

  },

  "consumed_credits": 3,
  "result": {
    "animation_glb_url": "https://assets.meshy.ai/.../Animation_Reaping_Swing_withSkin.glb?...",
    "animation_fbx_url": "https://assets.meshy.ai/.../Animation_Reaping_Swing_withSkin.fbx?...",
    "processed_usdz_url": "https://assets.meshy.ai/.../processed.usdz?...",
    "processed_armature_fbx_url": "https://assets.meshy.ai/.../processed_armature.fbx?...",
    "processed_animation_fps_fbx_url": "https://assets.meshy.ai/.../processed_60fps.fbx?..."
  },
  "preceding_tasks": 0
}

動畫任務物件

動畫任務物件表示將動畫套用到已綁定骨架的角色上的工作單元。

屬性

  • Name
    id
    Type
    string
    Description

    任務的唯一識別碼。

  • Name
    type
    Type
    string
    Description

    動畫任務的類型。值為 animate

  • Name
    status
    Type
    string
    Description

    任務狀態。可能的值:PENDING(等待中)、IN_PROGRESS(進行中)、SUCCEEDED(成功)、FAILED(失敗)、CANCELED(已取消)。

  • Name
    progress
    Type
    integer
    Description

    任務進度(0-100)。

  • Name
    created_at
    Type
    timestamp
    Description

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

  • Name
    started_at
    Type
    timestamp
    Description

    任務開始處理時的時間戳(自1970年1月1日UTC以來的毫秒數)。如果尚未開始則為0

  • Name
    finished_at
    Type
    timestamp
    Description

    任務完成時的時間戳(自1970年1月1日UTC以來的毫秒數)。如果尚未完成則為0

  • Name
    expires_at
    Type
    timestamp
    Description

    任務結果資源過期時的時間戳(自1970年1月1日UTC以來的毫秒數)。

  • 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。

    • Name
      animation_glb_url
      Type
      string
      Description
      GLB格式動畫的可下載URL。
    • Name
      animation_fbx_url
      Type
      string
      Description
      FBX格式動畫的可下載URL。
    • Name
      processed_usdz_url
      Type
      string
      Description
      USDZ格式處理後動畫的可下載URL。
    • Name
      processed_armature_fbx_url
      Type
      string
      Description
      處理後骨架的FBX格式可下載URL。
    • Name
      processed_animation_fps_fbx_url
      Type
      string
      Description
      變更FPS後動畫的FBX格式可下載URL(例如,如果使用了change_fps操作)。
  • Name
    preceding_tasks
    Type
    integer
    Description

    佇列中前置任務的數量。僅在狀態為PENDING(等待中)時有意義。

动画任务对象示例

{
  "id": "018c425b-b2c6-727e-d333-3c1887i9h791",
  "type": "animate",
  "status": "SUCCEEDED",
  "created_at": 1747032440896,
  "progress": 100,
  "started_at": 1747032441210,
  "finished_at": 1747032457530,
  "expires_at": 1747291657530,
  "task_error": {

    "message": ""

  },

  "consumed_credits": 3,
  "result": {
    "animation_glb_url": "https://assets.meshy.ai/.../Animation_Reaping_Swing_withSkin.glb?...",
    "animation_fbx_url": "https://assets.meshy.ai/.../Animation_Reaping_Swing_withSkin.fbx?...",
    "processed_usdz_url": "https://assets.meshy.ai/.../processed.usdz?...",
    "processed_armature_fbx_url": "https://assets.meshy.ai/.../processed_armature.fbx?...",
    "processed_animation_fps_fbx_url": "https://assets.meshy.ai/.../processed_60fps.fbx?..."
  },
  "preceding_tasks": 0
}