> ## Documentation Index
> Fetch the complete documentation index at: https://docs.viggle.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start: Text to Motion

> Generate a downloadable 3D animation from a text prompt.

Describe a motion in text, submit it as JSON, and poll the returned Motion until the generated glb is ready. No source video is required — this is a separate, flat-priced path from the [Motion 3D](/v1/guides/quickstart-mocap) `glb` extraction, which is billed by source-video duration instead.

Set `VIGGLE_API_KEY` and run the example below as-is — it needs no other input.

## What you need

* An API key from the [Viggle Dashboard](https://portal.viggle.ai/keys), exported as `VIGGLE_API_KEY`
* A motion prompt between 1 and 400 characters

## Create, poll, and export the Motion

<CodeGroup>
  ```bash cURL theme={null}
  #!/usr/bin/env bash
  set -euo pipefail

  response=$(curl -s -X POST "https://apis.viggle.ai/v1/motions" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"text":"a person doing a cartwheel","duration_seconds":5}')
  motion_id=$(echo "$response" | jq -r '.id')

  for _ in $(seq 1 60); do
    motion=$(curl -s "https://apis.viggle.ai/v1/motions/$motion_id" \
      -H "Authorization: Bearer $VIGGLE_API_KEY")
    status=$(echo "$motion" | jq -r '.status')

    case "$status" in
      ready)
        exported=$(curl -s "https://apis.viggle.ai/v1/motions/$motion_id/export?download_type=mixamo" \
          -H "Authorization: Bearer $VIGGLE_API_KEY")
        echo "$exported" | jq -r '.glb_url'
        exit 0
        ;;
      failed)
        echo "Motion failed: $(echo "$motion" | jq -c '.error')" >&2
        exit 1
        ;;
    esac
    sleep 5
  done

  echo "Timed out waiting for motion $motion_id" >&2
  exit 1
  ```

  ```javascript Node theme={null}
  const baseUrl = "https://apis.viggle.ai/v1";
  const headers = {
    Authorization: `Bearer ${process.env.VIGGLE_API_KEY}`,
    "Content-Type": "application/json",
  };

  async function createMotion() {
    const response = await fetch(`${baseUrl}/motions`, {
      method: "POST",
      headers,
      body: JSON.stringify({
        text: "a person doing a cartwheel",
        duration_seconds: 5,
      }),
    });
    if (!response.ok) {
      const body = await response.json().catch(() => ({}));
      throw new Error(`HTTP ${response.status}: ${JSON.stringify(body.error ?? body)}`);
    }
    return response.json();
  }

  async function waitForMotion(id) {
    for (let attempt = 0; attempt < 60; attempt++) {
      const response = await fetch(`${baseUrl}/motions/${id}`, {
        headers: { Authorization: headers.Authorization },
      });
      if (!response.ok) {
        const body = await response.json().catch(() => ({}));
        throw new Error(`HTTP ${response.status}: ${JSON.stringify(body.error ?? body)}`);
      }
      const motion = await response.json();
      if (["ready", "failed"].includes(motion.status)) return motion;
      await new Promise((resolve) => setTimeout(resolve, 5000));
    }
    throw new Error(`Timed out waiting for motion ${id}`);
  }

  const created = await createMotion();
  const motion = await waitForMotion(created.id);

  if (motion.status !== "ready") {
    throw new Error(`Motion failed: ${JSON.stringify(motion.error)}`);
  }

  const exportResponse = await fetch(
    `${baseUrl}/motions/${motion.id}/export?download_type=mixamo`,
    { headers: { Authorization: headers.Authorization } },
  );
  if (!exportResponse.ok) {
    const body = await exportResponse.json().catch(() => ({}));
    throw new Error(`HTTP ${exportResponse.status}: ${JSON.stringify(body.error ?? body)}`);
  }
  const exported = await exportResponse.json();
  console.log(exported.glb_url);
  ```

  ```python Python theme={null}
  import os
  import time
  import requests

  base_url = "https://apis.viggle.ai/v1"
  headers = {"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}

  response = requests.post(
      f"{base_url}/motions",
      headers=headers,
      json={
          "text": "a person doing a cartwheel",
          "duration_seconds": 5,
      },
  )
  response.raise_for_status()
  motion = response.json()

  for _ in range(60):
      if motion["status"] in {"ready", "failed"}:
          break
      time.sleep(5)
      response = requests.get(f"{base_url}/motions/{motion['id']}", headers=headers)
      response.raise_for_status()
      motion = response.json()
  else:
      raise TimeoutError(f"Timed out waiting for motion {motion['id']}")

  if motion["status"] != "ready":
      error = motion.get("error") or {}
      raise RuntimeError(f"failed: {error.get('code')} {error.get('message')}")

  response = requests.get(
      f"{base_url}/motions/{motion['id']}/export",
      params={"download_type": "mixamo"},
      headers=headers,
  )
  response.raise_for_status()
  print(response.json()["glb_url"])
  ```
</CodeGroup>

The create request returns immediately with a Motion whose `status` is normally `queued`. Poll `GET /v1/motions/{motion_id}` every five seconds until it becomes `ready` or `failed` — there is no `cancelled` state for a Motion.

When ready, call `GET /v1/motions/{motion_id}/export?download_type=mixamo` for the Mixamo skeleton, or use `download_type=metahuman`. Both variants are generated together; there is no `fbx` output. `glb_url` is a signed link, valid for 1 hour and re-signed on every call. The exported GLB works with **Mixamo**, **MetaHuman**, and other **Unity-compatible** animation workflows.

See [Pricing and retention](/v1/pricing#text-to-motion) — Text-to-Motion is a flat \$0.10 (10 credits) per request, independent of `duration_seconds`.

<Card title="Create Motion (from Text)" icon="message" href="/v1/api-reference/motions/create-from-text">
  See every JSON request and Motion response field.
</Card>
