Text to Motion API
Generate a character animation from a text prompt, then play it on any two-legged character you rigged with the Rigging API.
Moving from v1? The main changes for Text to Motion:
- The request is the same.
- Results are in
outputinstead ofresult. outputisnulluntil the task succeeds.
Create a Text to Motion task
Creates a Text to Motion task and returns the task object. The task runs in the background. To read its result, see Get the result. For how long a task usually takes, see Processing times.
To play the motion on a character, see Apply the motion to a character.
Parameters
- Name
- prompt
- Type
- string
- Required
- Description
Text that describes the motion to generate, up to 400 characters. For example,
A person waves with the right hand, then takes a bow. Longer text returns400.Try and previewYou can write the prompt in other languages.
- Name
- duration
- Type
- number
- Required
- Description
The clip length in seconds, from
2to10in steps of0.5, for example3or4.5. Any other value returns400.Try and preview
- Name
- mode
- Type
- string
- default prime
- Description
The motion model, which also sets the clip's file format.
Try and previewAvailable values:
prime: returns an FBX clipswift: returns a BVH clip
Any other value returns
400. The two modes cost different amounts. See Pricing.
Returns
202 Accepted with the task object. The task starts as PENDING, with your request in input and output set to null.
Two response headers help you read the task:
Location: the task's URL on TasksRetry-After: how many seconds to wait before you first read it
Failure modes
- Name
400 - Bad Request- Description
The request can't run. For example:
promptis missing, blank (prompt must not be empty), or longer than 400 charactersdurationis missing, outside 2 to 10 seconds, or not a multiple of 0.5 (duration must be between 2 and 10 seconds in 0.5 second steps)
The error message says which problem it found. See Errors.
- Name
401 - Unauthorized- Description
The API key is missing or invalid. Check the
Authorizationheader.
- Name
402 - Payment Required- Description
One of these applies:
- The account doesn't have enough credits.
- The account reached a credit limit.
- The account is on the free plan.
Check your credits and plan, then retry.
- Name
403 - Forbidden- Description
Content moderation blocked the prompt. The message is
explicit contentorprohibited content. Change the prompt, then send the request again.
- Name
429 - Too Many Requests- Description
One of these limits was reached:
- You sent too many requests. Wait the number of seconds in
Retry-After, then retry. - Too many of your tasks are queued or running. Wait for some to finish, then retry.
- On an unlimited plan with no credits left, you reached the number of tasks that can run without credits. Wait for a task to finish, or add credits.
- You sent too many requests. Wait the number of seconds in
Apply the motion to a character
The clip in output.motion_url has the motion on its own, with no character. To play it on your character, wait until the Text to Motion task's status is SUCCEEDED. Then create an Animation task with these parameters:
motion_task_id: the Text to Motion task'sidrig_task_id: theidof a Rigging task
Create the Animation task within 3 days after the Text to Motion task finishes. After that, Meshy deletes the clip, like other task files, and Animation returns 404. Enterprise accounts keep their files.
Meshy charges for each task separately. See 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>"
}'
Get the result
Read Text to Motion tasks the same way as every other v2 task, through the Tasks routes. To list only Text to Motion tasks, filter by type=text-to-motion.
| To | Call |
|---|---|
| Get one task | GET /openapi/v2/tasks/{id} |
| Wait for updates | GET /openapi/v2/tasks/{id}/stream or a webhook |
| List your tasks | GET /openapi/v2/tasks?type=text-to-motion |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Text to Motion output
When the task succeeds, output holds these fields. The rest of the task object is the same for every task type. The URL in output stops working at expires_at.
curl https://api.meshy.ai/openapi/v2/tasks/01a157df-f3c8-7433-b18a-5f1304c246d4 \
-H "Authorization: Bearer ${MESHY_API_KEY}"Loading…- Name
- motion_url
- Type
- string | null
- Description
Signed URL to the motion clip, an FBX file for
primeor a BVH file forswift.
- Name
- motion_format
- Type
- string
- Description
The clip's file format,
fbxorbvh.
- Name
- duration_ms
- Type
- integer
- Description
The clip length you asked for, in milliseconds.
- Name
- mode
- Type
- string
- Description
The
modeMeshy used to make the clip,primeorswift.