lowpoly 将于 2026年10月30日 下线。 meshy-7 作为 3D 生成模型将于 2026年12月31日 下线;作为贴图模型仍可使用。 请在这些日期前切换模型,以免请求报错。 查看所有弃用信息

Text to Motion API

根据文本 prompt 生成角色 Animation,然后将其应用到任意一个使用 Rigging API 完成 rigging 的双足角色上。


POST/openapi/v2/text-to-motion

创建 Text to Motion 任务

创建一个 Text to Motion 任务,并返回任务对象。任务会在后台运行。要读取其结果,请参阅获取结果。关于任务通常需要多长时间,请参阅处理时间。

要将动作应用到角色上进行播放,请参阅将动作应用到角色。

预览修改“试用并预览”中的值即可更新
格式FBX
费用10 积分
请求
curl https://api.meshy.ai/openapi/v2/text-to-motion \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "a person waves hello",
    "duration": 6
  }'
响应
加载中…

参数

  • Name
    prompt
    Type
    string
    必选
    Description

    描述要生成的动作的文本,最多 400 个字符。例如,A person waves with the right hand, then takes a bow。超过长度限制会返回 400。

    试用并预览

    你可以使用其他语言编写 prompt。

  • Name
    duration
    Type
    number
    必选
    Description

    片段时长(秒),范围从 2 到 10,以 0.5 为步长,例如 3 或 4.5。任何其他值都会返回 400。

    试用并预览
  • Name
    mode
    Type
    string
    默认值 prime
    Description

    动作生成模型,同时也决定了片段的文件格式。

    试用并预览

    可用值:

    • prime:返回 FBX 格式的片段
    • swift:返回 BVH 格式的片段

    任何其他值都会返回 400。这两种 mode 的费用不同。请参阅 Pricing。

返回值

202 Accepted,包含任务对象。任务开始时状态为 PENDING,input 中包含你的请求内容,output 设为 null。

两个响应头可帮助你读取任务:

  • Location:该任务在 Tasks 中的 URL
  • Retry-After:首次读取前需要等待的秒数

失败情况

  • Name
    400 - Bad Request
    Description

    请求无法运行。例如:

    • prompt 缺失、为空(prompt must not be empty),或超过 400 个字符
    • duration 缺失、不在 2 到 10 秒范围内,或不是 0.5 的倍数(duration must be between 2 and 10 seconds in 0.5 second steps)

    错误消息会说明发现的具体问题。请参阅 Errors。

  • Name
    401 - Unauthorized
    Description

    API key 缺失或无效。请检查 Authorization 请求头。

  • Name
    402 - Payment Required
    Description

    以下情况之一:

    • 账户没有足够的积分。
    • 账户达到了积分限制。
    • 账户处于免费计划。

    请检查你的积分和计划,然后重试。

  • Name
    403 - Forbidden
    Description

    内容 moderation 拦截了该 prompt。消息为 explicit content 或 prohibited content。请修改 prompt 后重新发送请求。

  • Name
    429 - Too Many Requests
    Description

    触发了以下限制之一:

    • 你发送的请求过多。请等待 Retry-After 中给出的秒数后重试。
    • 你排队或正在运行的任务过多。请等待部分任务完成后重试。
    • 在无限计划下且没有剩余积分时,你已达到可在没有积分的情况下运行的任务数量上限。请等待某个任务完成,或增加积分。

将动作应用到角色

output.motion_url 中的片段只包含动作本身,没有角色。要在你的角色上播放该动作,请等到 Text to Motion 任务的状态变为 SUCCEEDED。然后使用以下参数创建一个 Animation 任务:

  • motion_task_id:Text to Motion 任务的 id
  • rig_task_id:某个 Rigging 任务的 id

请在 Text to Motion 任务完成后的 3 天内创建 Animation 任务。超过这段时间后,Meshy 会像删除其他任务文件一样删除该片段,此时 Animation 会返回 404。企业账户会保留其文件。

Meshy 会对每个任务分别计费。请参阅 Pricing。

Text to Motion, then Animation

# 1. Generate a 3-second motion
curl https://api.meshy.ai/openapi/v2/text-to-motion \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "A person waves with the right hand, then takes a bow",
    "duration": 3
  }'

# 2. When it succeeds, play it on a rigged character
curl https://api.meshy.ai/openapi/v2/animations \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "rig_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "motion_task_id": "<Text to Motion task ID>"
  }'

获取结果

读取 Text to Motion 任务的方式与其他所有 v2 任务相同,均通过 Tasks 路由进行。若只想列出 Text to Motion 任务,请使用 type=text-to-motion 进行筛选。


文本生成动作输出

当任务成功时,output 会包含以下字段。任务对象的其余部分对所有任务类型都是相同的。output 中的 URL 会在 expires_at 之后失效。

请求
curl https://api.meshy.ai/openapi/v2/tasks/01a157df-f3c8-7433-b18a-5f1304c246d4 \
  -H "Authorization: Bearer ${MESHY_API_KEY}"
响应
加载中…
  • Name
    motion_url
    Type
    string | null
    Description

    动作片段的签名 URL,对于 prime 是 FBX 文件,对于 swift 是 BVH 文件。

  • Name
    motion_format
    Type
    string
    Description

    该片段的文件格式,fbx 或 bvh。

  • Name
    duration_ms
    Type
    integer
    Description

    你所要求的片段时长,单位为毫秒。

  • Name
    mode
    Type
    string
    Description

    Meshy 用于生成该片段的 mode,prime 或 swift。