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

# Text to video

> Generate a 5–15 second Viggle H3 video with native audio from a text prompt alone. No input files needed.

Text to video turns a written description into an MP4 with native audio. You send a prompt, Viggle H3 plans and renders the shot, and you download the result. It needs no images or video, so it is the fastest way to try the API.

Use it when you can describe the shot in words and don't need to match an existing image. To start from a still, use [First frame to video](https://docs.viggle.ai/v1/video/first-frame-to-video.md). To carry a subject or style from your own media, use [Reference to video](https://docs.viggle.ai/v1/video/reference-to-video.md).

## What you send

`POST /v1/videos` as `multipart/form-data`. Sending only a prompt (no frame, reference or Remake fields) selects text to video.

| Parameter | Required | Notes |
| - | - | - |
| `prompt` | Yes | The shot: subject, action, setting, camera. Must not be blank |
| `quality` | Yes | `low` (faster) or `high` (higher fidelity), same price. Or [`ultrafast`](https://docs.viggle.ai/v1/video/generate-video#ultrafast), the fastest tier, priced separately |
| `duration_s` | No | 5–15 seconds. Default `5` |
| `resolution` | No | `480p`, `768p` (default), `1080p`, `2k`, `4k` |
| `aspect_ratio` | No | `16:9` (default), `9:16`, `1:1`, `4:3`, `3:4`, `21:9` |
| `enhance` | No | Default `true`. A planning pass rewrites the prompt before generating |

The remaining options (`seed`, `watermark`) are in [Common parameters](https://docs.viggle.ai/v1/video/generate-video#common-parameters) and the [API reference](https://docs.viggle.ai/v1/api-reference/videos/create-a-video.md).

## Price

You pay per second of video, by `resolution`, plus $0.01 per second while `enhance` is on. The example below (5 seconds, 768p, enhance on) costs 5 × (1 + 1) = 10 credits ($0.10). Every rate is on the [overview](https://docs.viggle.ai/v1/video/generate-video#price).

## Generate a video

Export your key as `VIGGLE_API_KEY` and run one of these as-is. Each script submits the job, polls every 5 seconds and prints the video URL. The cURL version needs `jq`.

```bash cURL theme={null}
#!/usr/bin/env bash
set -euo pipefail
API="https://apis.viggle.ai/v1"

video_id=$(curl -sS --fail-with-body "$API/videos" \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F prompt="a paper airplane gliding through a sunlit office" \
  -F quality=low \
  -F duration_s=5 | jq -er '.id')
echo "Submitted $video_id"

for _ in $(seq 1 1440); do
  video=$(curl -sS --fail-with-body "$API/videos/$video_id" \
    -H "Authorization: Bearer $VIGGLE_API_KEY")
  case $(echo "$video" | jq -r '.status') in
    ready) echo "$video" | jq -r '.video_url'; exit 0 ;;
    failed|cancelled) echo "$video" | jq -c '.error' >&2; exit 1 ;;
  esac
  sleep 5
done
echo "Timed out waiting for $video_id" >&2; exit 1
```

```javascript Node.js theme={null}
// Node.js 20+. Save as text-to-video.mjs, then run: node text-to-video.mjs
const API = "https://apis.viggle.ai/v1";
const headers = { Authorization: `Bearer ${process.env.VIGGLE_API_KEY}` };

async function call(path, init = {}) {
  const res = await fetch(`${API}${path}`, { ...init, headers });
  const body = await res.json();
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${JSON.stringify(body.error)}`);
  return body;
}

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 { id } = await call("/videos", { method: "POST", body: form });
console.log(`Submitted ${id}`);

for (let i = 0; i < 1440; i++) {
  const video = await call(`/videos/${id}`);
  if (video.status === "ready") {
    console.log(video.video_url);
    process.exit(0);
  }
  if (video.status === "failed" || video.status === "cancelled") {
    throw new Error(`${video.status}: ${JSON.stringify(video.error)}`);
  }
  await new Promise((resolve) => setTimeout(resolve, 5000));
}
throw new Error(`Timed out waiting for ${id}`);
```

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

import requests

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


def check(resp):
    if not resp.ok:
        raise RuntimeError(f"HTTP {resp.status_code}: {resp.text}")
    return resp.json()


# Passing fields through files= makes requests send multipart/form-data,
# which this endpoint requires. data= alone would send a urlencoded body.
video = check(requests.post(f"{API}/videos", headers=HEADERS, files={
    "prompt": (None, "a paper airplane gliding through a sunlit office"),
    "quality": (None, "low"),
    "duration_s": (None, "5"),
}))
print("Submitted", video["id"])

for _ in range(1440):
    video = check(requests.get(f"{API}/videos/{video['id']}", headers=HEADERS))
    if video["status"] == "ready":
        print(video["video_url"])
        break
    if video["status"] in ("failed", "cancelled"):
        raise RuntimeError(f"{video['status']}: {video['error']}")
    time.sleep(5)
else:
    raise TimeoutError(f"Timed out waiting for {video['id']}")
```

The create call answers right away with the job ID:

```json theme={null}
{ "id": "vid_7d3f0b8e-2c41-4f6a-9b1e-5a2c8d4e6f10", "status": "queued", "progress": null, "created_at": "2026-11-20T09:12:03Z" }
```

> [!WARNING]
>
> If your balance can't cover the job, the request is still accepted, and the job then ends `failed` with `error.code: "INSUFFICIENT_CREDITS"`. Check `GET /v1/credits` before large batches.

## Get the result

While the job runs, `GET /v1/videos/{video_id}` reports `status` (`queued`, then `processing`) and, while queued, `queue_position` and `estimated_wait_seconds`. When `status` is `ready`, download `video_url`.

* The link is valid for one hour. Every read returns a fresh one, so re-read the job rather than storing the link.
* The video is deleted 24 hours after the job finishes. Copy it to your own storage.
* The response includes the `seed` that was used. Send the same `seed` and prompt to get a similar result again.
* Only the API key that created the job can read it.

See [Task lifecycle](https://docs.viggle.ai/v1/concepts/task-lifecycle.md) for statuses and failures, and [Errors](https://docs.viggle.ai/v1/production/errors.md) for error codes.

## Write a better prompt

* Describe one shot: who or what is in frame, what happens, where, and how the camera moves.
* Keep `enhance` on while you explore. It expands a short prompt before generating. Turn it off (`enhance=false`, half the price at 768p) when you want your prompt used as written.
* Iterate with `quality=low`, then switch to `high` for the final take. Both cost the same.

## Next steps

> [card] [First frame to video](https://docs.viggle.ai/v1/video/first-frame-to-video.md)
>
> Animate a still and keep its composition.

> [card] [Reference to video](https://docs.viggle.ai/v1/video/reference-to-video.md)
>
> Bring a subject or style from your own images or video.

> [card] [Upscale a video](https://docs.viggle.ai/v1/video/upscale.md)
>
> Double the resolution of a finished video with FlashVSR.

> [card] [Create a video (API reference)](https://docs.viggle.ai/v1/api-reference/videos/create-a-video.md)
>
> Every field, limit and error for `POST /v1/videos`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.