> ## 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 Video

> Generate a MiniMax H3 video from a text prompt alone.

Describe a shot in text, submit it to `POST /v1/videos`, and poll the returned video until it's ready. No source image or video is required — this is the **H3 Video Generation** text-to-video mode, a Viggle-optimized MiniMax H3 capability separate from the character+motion [Video Remix](/v1/guides/quickstart-mix) flow. Every generated video includes **native audio**.

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 non-empty text prompt
* A `quality` choice: `low` for faster generation and quicker iteration, or `high` for higher-fidelity output — both are billed at the same **\$0.01/sec** rate

## Generate and poll the video

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

  response=$(curl -s "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F prompt="a paper airplane gliding through a sunlit office" \
    -F quality=low \
    -F duration_s=5)
  video_id=$(echo "$response" | jq -r '.id')

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

    case "$status" in
      ready)
        echo "$video" | jq -r '.video_url'
        exit 0
        ;;
      failed|cancelled)
        echo "Video $status: $(echo "$video" | jq -c '.error')" >&2
        exit 1
        ;;
    esac
    sleep 5
  done

  echo "Timed out waiting for video $video_id" >&2
  exit 1
  ```

  ```javascript Node theme={null}
  const baseUrl = "https://apis.viggle.ai/v1";
  const headers = { Authorization: `Bearer ${process.env.VIGGLE_API_KEY}` };
  const TERMINAL = new Set(["ready", "failed", "cancelled"]);

  async function createVideo() {
    const form = new FormData();
    form.append("prompt", "a paper airplane gliding through a sunlit office");
    form.append("quality", "low");
    form.append("duration_s", "5");

    const response = await fetch(`${baseUrl}/videos`, {
      method: "POST",
      headers,
      body: form,
    });
    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 waitForVideo(id) {
    for (let attempt = 0; attempt < 60; attempt++) {
      const response = await fetch(`${baseUrl}/videos/${id}`, { headers });
      if (!response.ok) {
        const body = await response.json().catch(() => ({}));
        throw new Error(`HTTP ${response.status}: ${JSON.stringify(body.error ?? body)}`);
      }
      const video = await response.json();
      if (TERMINAL.has(video.status)) return video;
      await new Promise((resolve) => setTimeout(resolve, 5000));
    }
    throw new Error(`Timed out waiting for video ${id}`);
  }

  const created = await createVideo();
  const video = await waitForVideo(created.id);

  if (video.status !== "ready") {
    throw new Error(`Video ${video.status}: ${JSON.stringify(video.error)}`);
  }
  console.log(video.video_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']}"}
  TERMINAL_STATES = {"ready", "failed", "cancelled"}

  response = requests.post(
      f"{base_url}/videos",
      headers=headers,
      data={
          "prompt": "a paper airplane gliding through a sunlit office",
          "quality": "low",
          "duration_s": 5,
      },
  )
  response.raise_for_status()
  video = response.json()

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

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

  print(video["video_url"])
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "id": "vid_3f2a9c",
  "status": "queued",
  "progress": null,
  "created_at": "2026-08-24T09:12:03Z"
}
```

The create request answers immediately with `status: "queued"` and no `video_url` yet — it's an acceptance acknowledgment, not the final result. Poll `GET /v1/videos/{video_id}` every 3–5 seconds until `status` is `ready`, `failed`, or `cancelled`, then read `video_url` — a signed link, valid for 1 hour and re-signed on every read. `duration_s` (3–15, default `5`), `resolution` (default `768p`), and `aspect_ratio` (default `16:9`) are all optional; `prompt` and `quality` are not.

See [Pricing and retention](/v1/pricing#h3-video) — H3 Video is billed at \$0.01 per generated second regardless of `quality`, `resolution`, or `aspect_ratio`.

<Card title="Generate Video (from Text)" icon="text" href="/v1/api-reference/videos/create-from-text">
  See every field and the full response shape.
</Card>
