Text to Motion API
根據自然語言描述產生角色動作片段。描述一個動作——「一個角色在揮手」、「一個殭屍蹣跚前行」——即可取得一個原始動作片段,你可以在自己的管線或 DCC 工具中,將其重定向套用到已完成骨骼綁定的角色上。
輸出結果是一個獨立的動作片段:它不需要角色模型,也不會附加到任何角色模型上。若要先為角色進行骨骼綁定,請參閱 Rigging APIid 作為 motion_task_id 傳遞給 Animation API
創建文本生成動作任務
此 endpoint 用於創建一個新任務,根據文本 prompt 生成動作片段。
mode 為 prime 的任務消耗 10 積分,使用我們品質最高的動作模型進行生成。mode 為 swift 的任務消耗 3 積分,使用我們經濟型動作模型更快地生成。
參數
- Name
- prompt
- Type
- string
- 必選
- Description
對要生成的動作的自然語言描述。最多 400 個字元。
- Name
- mode
- Type
- string
- 預設值 prime
- Description
動作生成 mode。可選值:
prime、swift。prime生成品質最高,輸出 FBX;swift更快更經濟,輸出 BVH。
- Name
- duration
- Type
- number
- 必選
- Description
動作片段的目標時長(秒)。範圍在
2到10之間,步長為0.5(例如2、2.5、3、……、10)。
回傳
響應中的 result 屬性包含新創建的文本生成動作任務的任務 id。
失敗模式
- Name
400 - Bad Request- Description
請求不可接受。常見原因:
- prompt 缺失或為空:
prompt缺失、為空,或超過 400 個字元。 - mode 無效:
mode不是prime或swift。 - duration 無效:
duration缺失、不在2–10範圍內,或不是0.5秒的整數倍步長。
- prompt 缺失或為空:
- Name
401 - Unauthorized- Description
身份驗證失敗。請檢查您的 API 金鑰。
- Name
402 - Payment Required- Description
執行此任務所需的積分不足。
- Name
403 - Forbidden- Description
該 prompt 被內容 moderation 標記。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# Generate a motion clip with required params only
curl https://api.meshy.ai/openapi/v1/text-to-motion \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "a character waving",
"duration": 3
}'
# Generate a fast, economical clip with Swift mode
curl https://api.meshy.ai/openapi/v1/text-to-motion \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "a character waving",
"mode": "swift",
"duration": 4.5
}'
Response
{
"result": "018c425b-b2c6-727e-d333-3c1887i9h791"
}
取得文本生成動作任務
此 endpoint 可讓您透過有效的任務 id 取得一個文本生成動作任務。請參閱文本生成動作任務物件以了解其中包含哪些屬性。
參數
- Name
- id
- Type
- path
- Description
要取得的文本生成動作任務的唯一識別碼。
回傳值
回應內容包含文本生成動作任務物件。詳情請參閱文本生成動作任務物件章節。
Request
curl https://api.meshy.ai/openapi/v1/text-to-motion/018c425b-b2c6-727e-d333-3c1887i9h791 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"id": "018c425b-b2c6-727e-d333-3c1887i9h791",
"type": "text-to-motion",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1787314497437,
"started_at": 1787314498012,
"finished_at": 1787314505881,
"expires_at": 1787573705881,
"task_error": null,
"result": {
"motion_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018c425b-b2c6-727e-d333-3c1887i9h791/output/clip.fbx?Expires=...",
"motion_format": "fbx",
"duration_ms": 3000,
"mode": "prime"
},
"consumed_credits": 10
}
List Text to Motion Tasks
返回呼叫者的 Text to Motion 任務的分頁清單,依最新排序。透過 page_num 和 page_size 進行標準分頁。
回應是一個由Text to Motion Task 物件組成的陣列。
請注意,透過 API 建立的任務由 API 進行管理——它們不會出現在網頁應用程式的「我的資產」中。當你不再擁有某個任務的 ID 時,可使用此 endpoint 來查詢該任務。
Request
curl "https://api.meshy.ai/openapi/v1/text-to-motion?page_num=1&page_size=20" \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
[
{
"id": "018c425b-b2c6-727e-d333-3c1887i9h791",
"type": "text-to-motion",
"status": "SUCCEEDED",
"...": "..."
}
]
流式取得 Text to Motion 任務
此 endpoint 使用 Server-Sent Events(SSE)串流傳輸 Text to Motion 任務的即時更新。
參數
- Name
- id
- Type
- path
- Description
要進行串流傳輸的 Text to Motion 任務的唯一識別碼。
回傳
以 Server-Sent Events 的形式回傳 Text to Motion 任務物件 的串流。
每個 message 事件都攜帶完整的任務物件。當任務處於 PENDING 或 IN_PROGRESS 狀態時,result 欄位仍為空("" / 0),finished_at / expires_at 為 0;請留意 status 和 progress。
Request
curl -N https://api.meshy.ai/openapi/v1/text-to-motion/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 events carry the full task object at every stage; the result
// fields stay empty until the task succeeds.
event: message
data: {
"id": "018c425b-b2c6-727e-d333-3c1887i9h791",
"type": "text-to-motion",
"status": "IN_PROGRESS",
"progress": 50,
"created_at": 1787314497437,
"started_at": 1787314498012,
"finished_at": 0,
"expires_at": 0,
"task_error": null,
"result": {
"motion_url": "",
"motion_format": "",
"duration_ms": 0,
"mode": ""
},
"consumed_credits": 10
}
event: message
data: { // Example of a SUCCEEDED task stream item, mirroring The Text to Motion Task Object structure
"id": "018c425b-b2c6-727e-d333-3c1887i9h791",
"type": "text-to-motion",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1787314497437,
"started_at": 1787314498012,
"finished_at": 1787314505881,
"expires_at": 1787573705881,
"task_error": null,
"result": {
"motion_url": "https://assets.meshy.ai/.../output/clip.fbx?Expires=...",
"motion_format": "fbx",
"duration_ms": 3000,
"mode": "prime"
},
"consumed_credits": 10
}
刪除 Text to Motion 任務
此 endpoint 將永久刪除一個 Text to Motion 任務,包括生成的動作片段。此操作不可逆。
路徑參數
- Name
- id
- Type
- path
- Description
要刪除的 Text to Motion 任務的 ID。
回傳
成功時回傳 200 OK。
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/text-to-motion/018c425b-b2c6-727e-d333-3c1887i9h791 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// Returns 200 Ok on success.
Text to Motion 任務物件
Text to Motion 任務物件表示根據文字 prompt 生成動作片段的工作單元。
屬性
- Name
- id
- Type
- string
- Description
任務的唯一識別碼。
- Name
- type
- Type
- string
- Description
任務的類型。值為
text-to-motion。
- Name
- status
- Type
- string
- Description
任務的狀態。可能的值:
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED。
- Name
- progress
- Type
- integer
- Description
任務的進度(0-100)。
- Name
- created_at
- Type
- timestamp
- Description
任務建立時的時間戳(自紀元起的毫秒數)。
timestamp 表示自 1970 年 1 月 1 日 UTC 起經過的毫秒數,遵循 RFC 3339
標準。 例如,格林威治標準時間 2023 年 9 月 1 日星期五中午 12:00:00 表示為1693569600000。這適用於 Meshy API 中的所有 timestamp。
- Name
- started_at
- Type
- timestamp
- Description
任務開始處理時的時間戳(自紀元起的毫秒數)。如果尚未開始,則為
0。
- Name
- finished_at
- Type
- timestamp
- Description
任務完成時的時間戳(自紀元起的毫秒數)。如果尚未完成,則為
0。
- Name
- expires_at
- Type
- timestamp
- Description
任務結果資產過期時的時間戳(自紀元起的毫秒數)。在任務完成之前為
0。生成的片段在任務完成後保留 3 天,請在過期前下載。
- Name
- preceding_tasks
- Type
- integer
- Description
佇列中位於前面的任務數量。僅當狀態為
PENDING時才有意義;為零時會省略此欄位。
- Name
- consumed_credits
- Type
- integer
- Description
此任務消耗的積分數量。
primemode 為10,swiftmode 為3。對於FAILED的任務會回傳0(失敗時會退還積分)。
- Name
- task_error
- Type
- object
- Description
失敗任務的錯誤詳情;除非任務為
FAILED,否則為null。完整的task_error物件參考請參閱 錯誤。
- Name
- result
- Type
- object
- Description
任務
SUCCEEDED後包含生成的動作片段;在此之前,這些欄位雖然存在但為空(""/0)。- Name
motion_url- Type
- string
- Description
- 生成的動作片段的可下載 URL。每次讀取時該 URL 都會重新簽署,並隨任務的保留期限一同過期。
- Name
motion_format- Type
- string
- Description
- 片段的檔案格式:
primemode 為fbx,swiftmode 為bvh。
- Name
duration_ms- Type
- integer
- Description
- 生成的片段的時長(毫秒)。
- Name
mode- Type
- string
- Description
- 生成該片段所使用的 mode:
prime或swift。
Example Text to Motion Task Object
{
"id": "018c425b-b2c6-727e-d333-3c1887i9h791",
"type": "text-to-motion",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1787314497437,
"started_at": 1787314498012,
"finished_at": 1787314505881,
"expires_at": 1787573705881,
"task_error": null,
"result": {
"motion_url": "https://assets.meshy.ai/.../output/clip.fbx?Expires=...",
"motion_format": "fbx",
"duration_ms": 3000,
"mode": "prime"
},
"consumed_credits": 10
}