Animation API
用于发现可用 Animation 并将其应用到已完成骨骼绑定的角色的 endpoint。
创建动画任务
此 endpoint 允许您创建一个新任务,将动画应用到先前已完成骨骼绑定的角色上——可以是动画库中的预设动作(action_id),也可以是您使用 Text to Motion APImotion_task_id)。支持后处理选项。
参数
- Name
- rig_task_id
- Type
- string
- 必选
- Description
成功完成的骨骼绑定任务的
id(来自POST /openapi/v1/rigging)。此任务中的角色将被应用动画。
- Name
- action_id
- Type
- integer
- Description
要应用的预设动画动作的标识符。有关可用动画的完整列表,请参阅 动画库参考
。action_id和motion_task_id二者必须提供且仅提供一个。
- Name
- motion_task_id
- Type
- string
- Description
要应用的、成功完成的 Text to Motion
任务的id,用于代替预设动作。生成的动作片段会被重定向到已完成骨骼绑定的角色上,并且该片段会在创建时被快照保存,因此即使源任务之后过期或被删除,也不会影响此任务。源任务的 asset 保留 3 天——请在其过期前应用该片段。需要双足骨骼绑定。action_id和motion_task_id二者必须提供且仅提供一个。
- Name
- post_process
- Type
- object
- Description
动画输出的可选后处理。省略此参数将获得标准动画文件。
post_process is set- Name
- operation_type
- Type
- string
- 必选
- Description
要执行的操作类型。可用值:
change_fps、fbx2usdz、extract_armature。
- Name
- fps
- Type
- integer
- 默认值 30
- Description
目标帧率。仅当
operation_type为change_fps时适用。允许的值:24、25、30、60。
使用 motion_task_id 时,重定向可能只会生成 GLB 格式的动画。如果您请求了 post_process 但没有可用的 FBX,任务将以 task_error 失败,您的 credits 将自动退还;如果未请求 post_process,任务将成功,且 animation_fbx_url 为空。
返回值
响应中的 result 属性包含新创建的动画任务的 id。
失败模式
- Name
400 - Bad Request- Description
请求不可接受。常见原因:
- 缺少参数:缺少
rig_task_id,或既未提供action_id也未提供motion_task_id。 - 参数冲突:同时提供了
action_id和motion_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
# 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"
}
获取 Animation 任务
此 endpoint 允许您通过有效的任务 id 获取一个 Animation 任务。请参阅 The Animation Task Object 以查看包含哪些属性。
参数
- Name
- id
- Type
- path
- Description
要获取的 Animation 任务的唯一标识符。
返回值
响应中包含 Animation Task 对象。有关详细信息,请查看 The Animation Task Object 部分。
Request
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
}
删除 Animation 任务
此 endpoint 会永久删除一个 Animation 任务,包括所有关联的模型和数据。此操作不可撤销。
路径参数
- Name
- id
- Type
- path
- Description
要删除的 Animation 任务的 ID。
返回值
成功时返回 200 OK。
Request
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.
获取 Animation 任务列表
返回调用者的 Animation 任务的分页列表,按最新排序。通过 page_num 和 page_size 进行标准分页。
请注意,通过 API 创建的任务由 API 进行管理——它们不会出现在 Web App 的“我的资产”中。如果你不再拥有某个任务的 ID,可以使用此 endpoint 来查找该任务。
Request
curl "https://api.meshy.ai/openapi/v1/animations?page_num=1&page_size=20" \
-H "Authorization: Bearer ${YOUR_API_KEY}"
流式获取 Animation 任务
此 endpoint 通过 Server-Sent Events (SSE) 流式传输 Animation 任务的实时更新。
参数
- Name
- id
- Type
- path
- Description
要进行流式传输的 Animation 任务的唯一标识符。
返回
以 Server-Sent Events 的形式返回一个 The Animation Task Objects 流。
对于 PENDING 或 IN_PROGRESS 状态的任务,响应流将仅包含必要的 progress 和 status 字段。
Request
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
任务的状态。可能的值:
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED。
- Name
- progress
- Type
- integer
- Description
任务的进度(0-100)。
- Name
- created_at
- Type
- timestamp
- Description
任务创建时的时间戳(自纪元以来的毫秒数)。
时间戳表示自 1970 年 1 月 1 日 UTC 起经过的毫秒数,遵循 RFC 3339
标准。 例如,2023 年 9 月 1 日星期五格林尼治标准时间中午 12:00:00 表示为1693569600000。这适用于 Meshy API 中的所有时间戳。
- 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 数量。当任务状态为
PENDING、IN_PROGRESS或SUCCEEDED时会显示此字段。对于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
}