骨骼绑定 API
骨骼绑定 API 允许您以编程方式为 3D 人形模型添加骨骼(armature),并将 mesh 绑定到该骨骼上,使其可以进行 Animation。有关如何为已完成骨骼绑定的角色应用 Animation,请参阅 Animation 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 进行管理——它们不会出现在 Web App 的“我的资产”中。当你不再拥有某个任务的 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
任务的进度(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
此任务消耗的 credits 数量。当任务状态为
PENDING、IN_PROGRESS或SUCCEEDED时会显示。对于FAILED任务返回0(失败时会退还 credits)。
- 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 格式行走动画 armature 的可下载 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 格式跑步动画 armature 的可下载 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
}