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

# Quickstart

> Generate your first video with the Viggle API in four steps: get a key, submit a job, poll it, download the result.

This guide makes one 5-second video with Viggle H3 from a text prompt. It needs no input files, so you can run it as soon as you have a key. Every other capability follows the same four steps.

> [!NOTE]
>
> \*\*New accounts get 100 free credits ($1.00).** This example costs 10 credits ($0.10). Free credits land in your personal wallet; a key created under an organization spends the organization's credits instead. See [Pricing](https://docs.viggle.ai/v1/pricing.md).

**1. Get an API key**

Create a key in the [Viggle Dashboard](https://portal.viggle.ai/keys). Keys start with `sk-`. Keep it in a server-side environment variable and never ship it in browser or mobile code.

```bash theme={null}
export VIGGLE_API_KEY="sk-..."
```

**2. Submit a job**

`POST /v1/videos` with a `prompt` and a `quality` starts a Viggle H3 job. Send the body as `multipart/form-data`. The call returns right away with a `vid_` ID and `status: "queued"`.

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

**3. Poll until it finishes**

Read `GET /v1/videos/{video_id}` every 5 seconds. Stop when `status` is `ready`, `failed` or `cancelled`. A failed job carries an `error` object and is refunded.

**4. Download the video**

When the job is `ready`, download `video_url`. The link lasts one hour and every read returns a fresh one. The file is deleted 24 hours after the job finishes, so store your own copy.

## Complete script

Each script runs the four steps and saves `video.mp4`. The cURL version needs `jq`; Node.js needs version 20 or later; Python needs `requests`.

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

BASE="https://apis.viggle.ai/v1"
AUTH="Authorization: Bearer $VIGGLE_API_KEY"

# Step 2: submit the job (multipart/form-data)
response=$(curl -sS "$BASE/videos" \
  -H "$AUTH" \
  -F prompt="a paper airplane gliding through a sunlit office" \
  -F quality=low \
  -F duration_s=5)
video_id=$(echo "$response" | jq -r '.id // empty')
if [ -z "$video_id" ]; then
  echo "Create failed: $response" >&2
  exit 1
fi
echo "Submitted $video_id"

# Step 3: poll until a terminal status
for _ in $(seq 1 1440); do
  video=$(curl -sS "$BASE/videos/$video_id" -H "$AUTH")
  status=$(echo "$video" | jq -r '.status // "error"')

  case "$status" in
    ready)
      # Step 4: download within the hour
      url=$(echo "$video" | jq -r '.video_url')
      curl -sS -L -o video.mp4 "$url"
      echo "Saved video.mp4 ($url)"
      exit 0
      ;;
    failed|cancelled|error)
      echo "Video $status: $(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}
import { writeFile } from "node:fs/promises";

const BASE = "https://apis.viggle.ai/v1";
const headers = { Authorization: `Bearer ${process.env.VIGGLE_API_KEY}` };

async function api(path, init = {}) {
  const response = await fetch(`${BASE}${path}`, { ...init, headers });
  const body = await response.json().catch(() => ({}));
  if (!response.ok) {
    throw new Error(`HTTP ${response.status}: ${JSON.stringify(body.error ?? body)}`);
  }
  return body;
}

// Step 2: submit the job (FormData sends multipart/form-data)
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 created = await api("/videos", { method: "POST", body: form });
console.log(`Submitted ${created.id}`);

// Step 3: poll until a terminal status
let video = created;
for (let i = 0; i < 1440 && !["ready", "failed", "cancelled"].includes(video.status); i++) {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  video = await api(`/videos/${created.id}`);
}
if (video.status !== "ready") {
  throw new Error(`Video ${video.status}: ${JSON.stringify(video.error)}`);
}

// Step 4: download within the hour
const file = await fetch(video.video_url);
await writeFile("video.mp4", Buffer.from(await file.arrayBuffer()));
console.log(`Saved video.mp4 (${video.video_url})`);
```

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

import requests

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


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


# Step 2: submit the job. Passing fields through `files` makes requests send
# multipart/form-data, which this endpoint requires.
video = check(requests.post(
    f"{BASE}/videos",
    headers=HEADERS,
    files={
        "prompt": (None, "a paper airplane gliding through a sunlit office"),
        "quality": (None, "low"),
        "duration_s": (None, "5"),
    },
))
print(f"Submitted {video['id']}")

# Step 3: poll until a terminal status
for _ in range(1440):
    if video["status"] in ("ready", "failed", "cancelled"):
        break
    time.sleep(5)
    video = check(requests.get(f"{BASE}/videos/{video['id']}", headers=HEADERS))

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

# Step 4: download within the hour
with requests.get(video["video_url"], stream=True) as download:
    download.raise_for_status()
    with open("video.mp4", "wb") as out:
        for chunk in download.iter_content(chunk_size=1 << 20):
            out.write(chunk)
print(f"Saved video.mp4 ({video['video_url']})")
```

The defaults give a 768p, 16:9 video with native audio and `enhance` on, which costs 2 credits per second: 10 credits (\$0.10) for 5 seconds. `quality=high` costs the same and takes longer. [Generate video](https://docs.viggle.ai/v1/video/generate-video) lists every parameter and rate.

> [!TIP]
>
> If something goes wrong, read `error.code` first. A missing or wrong key answers `401 UNAUTHENTICATED`. If your balance is too low, a Viggle H3 job is still accepted and then ends `failed` with `INSUFFICIENT_CREDITS`. See [Errors](https://docs.viggle.ai/v1/production/errors.md).

## Try another capability

The same submit, poll and download loop works everywhere. Only the endpoint, the inputs and the ID prefix change.

> [card] [Replace people in a video](https://docs.viggle.ai/v1/video/remake.md)
>
> Viggle Remake swaps up to 10 people in your clip and keeps the camera and timing.

> [card] [Put a character on a motion video](https://docs.viggle.ai/v1/video/video-remix)
>
> Video Remix (JST-1): one image plus a dance or motion clip, with optional alpha output.

> [card] [Animate a first frame](https://docs.viggle.ai/v1/video/first-frame-to-video.md)
>
> Viggle H3 from a still image, keeping its look.

> [card] [Upscale a video 2x](https://docs.viggle.ai/v1/video/upscale.md)
>
> FlashVSR doubles the resolution of any clip.

> [card] [Create a rigged 3D character](https://docs.viggle.ai/v1/3d/characters.md)
>
> JST-2 turns one image into a `.vsplat` character.

> [card] [Turn video or text into 3D motion](https://docs.viggle.ai/v1/3d/motion.md)
>
> JST-2 exports GLB or FBX on Mixamo and MetaHuman rigs.

> [card] [Build a 3D scene](https://docs.viggle.ai/v1/3d/scenes.md)
>
> An explorable `.spz` scene from a prompt or a panorama.

> [card] [Generate images](https://docs.viggle.ai/v1/image/viggle-image.md)
>
> 1–6 PNGs from a prompt and optional reference images.


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