Animation API

用于发现可用 Animation 并将其应用到已完成骨骼绑定的角色的 endpoint。


POST/openapi/v1/animations

创建动画任务

此 endpoint 允许您创建一个新任务,将动画应用到先前已完成骨骼绑定的角色上——可以是动画库中的预设动作(action_id),也可以是您使用 Text to Motion API 生成的动作片段(motion_task_id)。支持后处理选项。

参数

  • Name
    rig_task_id
    Type
    string
    必选
    Description

    成功完成的骨骼绑定任务的 id(来自 POST /openapi/v1/rigging)。此任务中的角色将被应用动画。

  • Name
    action_id
    Type
    integer
    Description

    要应用的预设动画动作的标识符。有关可用动画的完整列表,请参阅 动画库参考action_idmotion_task_id 二者必须提供且仅提供一个。

  • Name
    motion_task_id
    Type
    string
    Description

    要应用的、成功完成的 Text to Motion 任务的 id,用于代替预设动作。生成的动作片段会被重定向到已完成骨骼绑定的角色上,并且该片段会在创建时被快照保存,因此即使源任务之后过期或被删除,也不会影响此任务。源任务的 asset 保留 3 天——请在其过期前应用该片段。需要双足骨骼绑定。action_idmotion_task_id 二者必须提供且仅提供一个。

  • Name
    post_process
    Type
    object
    Description

    动画输出的可选后处理。省略此参数将获得标准动画文件。

仅当 post_process is set
  • 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_id,或既未提供 action_id 也未提供 motion_task_id
    • 参数冲突:同时提供了 action_idmotion_task_id——二者互斥。
    • 骨骼绑定任务无效rig_task_id 无效,或指向一个失败/不存在的任务。
    • 动作 ID 无效action_id 未对应任何有效动画。
    • 动作任务尚未就绪motion_task_id 对应的任务尚未 SUCCEEDED
    • 不支持的骨骼绑定类型motion_task_id 需要双足骨骼绑定;四足骨骼绑定将被拒绝。
  • Name
    401 - Unauthorized
    Description

    Authentication 失败。请检查您的 API key。

  • Name
    402 - Payment Required
    Description

    credits 不足,无法执行此任务。

  • Name
    404 - Not Found
    Description

    未找到 rig_task_id 指定的骨骼绑定任务,或未找到 motion_task_id 指定的动作任务,或该动作片段已过期(源任务的 asset 保留 3 天)。

  • Name
    429 - Too Many Requests
    Description

    您已超出 速率限制。

Request

POST
/openapi/v1/animations
# Animate a rigged model with required params only
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
  }'

# Apply a generated Text to Motion clip instead of a preset action
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",
    "motion_task_id": "018c425b-b2c6-727e-d333-3c1887i9h791"
  }'

# With post-processing to change FPS
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

获取 Animation 任务

此 endpoint 允许您通过有效的任务 id 获取一个 Animation 任务。请参阅 The Animation Task Object 以查看包含哪些属性。

参数

  • Name
    id
    Type
    path
    Description

    要获取的 Animation 任务的唯一标识符。

返回值

响应中包含 Animation Task 对象。有关详细信息,请查看 The Animation Task Object 部分。

Request

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

Response

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

删除 Animation 任务

此 endpoint 会永久删除一个 Animation 任务,包括所有关联的模型和数据。此操作不可撤销。

路径参数

  • Name
    id
    Type
    path
    Description

    要删除的 Animation 任务的 ID。

返回值

成功时返回 200 OK

Request

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

Response

// Returns 200 Ok on success.

GET/openapi/v1/animations

获取 Animation 任务列表

返回调用者的 Animation 任务的分页列表,按最新排序。通过 page_numpage_size 进行标准分页。

请注意,通过 API 创建的任务由 API 进行管理——它们不会出现在 Web App 的“我的资产”中。如果你不再拥有某个任务的 ID,可以使用此 endpoint 来查找该任务。

Request

GET
/openapi/v1/animations
curl "https://api.meshy.ai/openapi/v1/animations?page_num=1&page_size=20" \
-H "Authorization: Bearer ${YOUR_API_KEY}"

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

流式获取 Animation 任务

此 endpoint 通过 Server-Sent Events (SSE) 流式传输 Animation 任务的实时更新。

参数

  • Name
    id
    Type
    path
    Description

    要进行流式传输的 Animation 任务的唯一标识符。

返回

以 Server-Sent Events 的形式返回一个 The Animation Task Objects 流。

对于 PENDINGIN_PROGRESS 状态的任务,响应流将仅包含必要的 progressstatus 字段。

Request

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

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": "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: { // Example of a SUCCEEDED task stream item, mirroring The Animation Task Object structure
  "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
}

Animation 任务对象

Animation 任务对象表示将动画应用于已绑定骨骼的角色的工作单元。

属性

  • Name
    id
    Type
    string
    Description

    任务的唯一标识符。

  • Name
    type
    Type
    string
    Description

    Animation 任务的类型。值为 animate

  • Name
    status
    Type
    string
    Description

    任务的状态。可能的值:PENDINGIN_PROGRESSSUCCEEDEDFAILEDCANCELED

  • Name
    progress
    Type
    integer
    Description

    任务的进度(0-100)。

  • Name
    created_at
    Type
    timestamp
    Description

    任务创建时的时间戳(自纪元以来的毫秒数)。

  • 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

    此任务消耗的 credits 数量。当任务状态为 PENDINGIN_PROGRESSSUCCEEDED 时会显示此字段。对于 FAILED 任务返回 0(失败时会退还 credits)。

  • 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 格式处理后 armature 的可下载 URL。
    • Name
      processed_animation_fps_fbx_url
      Type
      string
      Description
      FPS 已更改的动画的 FBX 格式可下载 URL(例如,如果使用了 change_fps 操作)。
  • Name
    preceding_tasks
    Type
    integer
    Description

    队列中前面等待的任务数量。仅当状态为 PENDING 时有意义。

Example Animation Task Object

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