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

# AI context

> A condensed primer on the Viggle API for coding agents: base URL, auth, the job model, endpoints, prices and the mistakes to avoid.

Paste this page into your coding agent's context, or point it here, before it writes code against the Viggle API.

## Basics

* Base URL: `https://apis.viggle.ai/v1`. REST over HTTPS, JSON responses.
* Auth: `Authorization: Bearer $VIGGLE_API_KEY` on every request. Keys start with `sk-`. Server-side only. Missing or bad key: `401 UNAUTHENTICATED`.
* Billing: credits, 1 credit = \$0.01. New personal accounts get 100 free credits. Reads, lists, exports and deletes are free. Failed and cancelled jobs are refunded automatically. Balance: `GET /v1/credits` returns `{"balance": number}`.
* There is no official SDK. Use plain HTTP (`fetch`, `requests`, `curl`).
* There are no webhooks. Poll.

## The job model

1. `POST` creates a job and returns `{"id": "...", "status": "queued", ...}` right away.
2. Poll the matching `GET` every 3–5 s until `status` is `ready`, `failed` or `cancelled`. Treat any other status as in progress.
3. On `ready`, download the output URL immediately and store your own copy.
4. On `failed`, read `error.code`, `error.retryable` and `error.remediation.action` (`retry` or `none`). For a 3D character or motion, the failure is in `vsplat.error` or `glb.error`; the top-level `error` stays `null`.

Characters (`char_`) and motions (`mot_`) are reusable assets. 2D ones are owned by the account; `type=vsplat` characters, `type=glb` and text-generated motions, and every `/export` are owned by the API key that created them (other keys get `404`). Every other ID is a job owned by the API key that created it (scenes excepted: account-owned).

## Endpoints and prices

| Capability | Create | Read back | Price |
| - | - | - | - |
| Viggle H3 video (text, first frame, first+last frame, reference) | `POST /v1/videos` multipart: `prompt`, `quality=low\|high\|ultrafast` (both required) | `GET /v1/videos/{vid_…}` → `video_url` | `ceil(duration_s) × rate`; rate 1 (480p/768p), 2 (1080p), 3 (2k), 5 (4k) credits/s, +1/s with `enhance` (default on). 5 s at 768p = 10 credits. `ultrafast`: 480p/768p only, no `enhance`, 2.2 (480p) or 3 (768p) credits/s on output plus reference-video seconds, total rounded up |
| Viggle Remake (replace people in a video) | `POST /v1/videos` with `driving_video`/`driving_video_url` + `character_image`/`character_image_url`/`character_image_urls` (multipart, form or JSON) | `GET /v1/videos/{anim_…}` | per driving-video second, rounded up: 1 (`normal`), 5 (`planner`, default), 10 (`agent`) credits |
| Video Remix, JST-1 (character image + motion video) | `POST /v1/renders` multipart: `image`/`image_url`/`character_id` + `motion_video`/`motion_video_url`/`motion_id` | `GET /v1/videos/{render_…}`, SSE `GET /v1/renders/{id}/events` | 1 credit per character per finished second, minimum 0.5; reserved from the motion length (10 s if unknown) |
| Upscale 2x, FlashVSR | `POST /v1/videos/super-resolution` multipart: `video` or `video_url` | `GET /v1/videos/{vsr_…}` | `ceil(seconds)` credits |
| 3D character, JST-2 | `POST /v1/characters` multipart: `image`/`image_url`, `type=vsplat` (or `all`) | `GET /v1/characters/{char_…}`, then `GET …/export?download_type=vsplat` | 30 credits, 25 with `enhance=false`; `type=all` adds 1 credit for the 2D part (31, or 26) |
| 3D motion from video, JST-2 | `POST /v1/motions` multipart: `motion_video`/`motion_video_url`, `type=glb` (or `all`) | `GET /v1/motions/{mot_…}`, then `GET …/export?download_type=glb\|fbx` | `ceil(seconds) × 5` credits |
| 3D motion from text, JST-2 | `POST /v1/motions` JSON: `{"text": "...", "duration_seconds": 5}` | same as above | 10 credits flat |
| 3D scene, JST-2 | `POST /v1/scenes/pano` (then `/generate`, `/reconstruct`) JSON, camelCase | `GET /v1/scenes/{scn_…}` → `result` | 1 credit per view; panorama = 6 |
| Viggle Image | `POST /v1/images` multipart: `prompt`, `n` 1–6, `resolution=1K\|2K` | `GET /v1/images/{img_…}` → `images[].url` | `n × 1` (1K) or `n × 2` (2K) credits |

Full parameters: `https://docs.viggle.ai/v1/api-reference/overview`.

## Top mistakes

1. Accidentally switching `POST /v1/videos` to Remake. Any `driving_video*` or `character_image*` field turns the request into Viggle Remake, a different model and price. To animate a still with Viggle H3, send `first_frame_image` or `first_frame_image_url` (and optionally `last_frame_image*`), not `character_image`. Never send `quality` on a Remake request: it is rejected. A Remake request without a driving video is rejected with `400` too.
2. Sending urlencoded or JSON to Viggle H3. `POST /v1/videos` for H3 requires `multipart/form-data`. In Python `requests`, pass fields through `files={"prompt": (None, "...")}`; `data=` alone sends urlencoded and fails with `400`.
3. Treating `200 queued` as paid. Viggle H3, upscale, 3D characters, 3D motion from video and motion from text are accepted even if the balance is too low, then end `failed` with `INSUFFICIENT_CREDITS`. Remake, renders, images, scenes, 2D characters and motion template imports answer `402` at submit instead.
4. Caching output URLs. H3, Remake, upscale, image and export URLs last 1 hour and are re-signed on every read; scene URLs last 3 hours. Read the job again for a fresh URL.
5. Downloading too late. All job results are deleted 24 hours after the job finishes (3D exports of characters and motions stay until you delete the asset). The job record stays readable afterwards, with null URLs, so download as soon as a job is `ready`.
6. Using snake\_case on scenes. `/v1/scenes/*` bodies and responses are camelCase: `sessionId`, `panoramaUri`, `referenceBatchIds`, `queuePosition`, `createdAt`. Unknown fields are rejected. One running task per `sessionId` (a second answers `409`).
7. Assuming one character per render. Video Remix supports several: map each person (track ID) of a multi-person motion to a character with `character_mapping` (a JSON object sent as a string). Billing counts one character per mapping entry. Remake takes up to 10 character images.
8. Reading renders from `/v1/renders/{id}`. That GET does not exist (`405`). Read every video job, renders included, with `GET /v1/videos/{id}`.
9. Expecting to cancel everything. Only renders can be cancelled: `DELETE /v1/renders/{render_id}` (refunds). Other jobs run to completion.
10. Expecting lists to be complete. `GET /v1/videos` omits upscales. `GET /v1/characters` and `GET /v1/motions` cap at 100 and skip 3D-only characters, 3D-only motions and text motions. Store the IDs you create.
11. Retrying blindly. Retry only when `error.retryable` is `true`, with exponential backoff. `429 RATE_LIMITED` is a brief credit-system contention on Remake, images and scenes, not a quota; there is no per-account rate limit. Use `Idempotency-Key` on `POST /v1/renders` to make submits safe to repeat.
12. Using one key's job ID with another key. Jobs are visible only to the key that created them (`404` otherwise).

## Limits worth knowing

* Any input video: at most 100 MiB, 0.5–600 s, at least 64×64, even dimensions.
* H3: `duration_s` 5–15; up to 6 reference images and 1 reference video; references can't be combined with frames.
* Remake: driving video 5–16 s (`normal`, `planner`) or 5–60 s (`agent`); up to 10 images, uploads 20 MiB each; `https://` URLs only; output 768p.
* Images: up to 8 reference images; prompt up to 4,000 characters.
* Text-to-motion: `text` up to 400 bytes; `duration_seconds` 3–60; unknown JSON fields rejected.

## Minimal example (Python)

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

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

job = requests.post(f"{BASE}/videos", headers=H, files={
    "prompt": (None, "a paper airplane gliding through a sunlit office"),
    "quality": (None, "low"),
}).json()
while job["status"] not in ("ready", "failed", "cancelled"):
    time.sleep(5)
    job = requests.get(f"{BASE}/videos/{job['id']}", headers=H).json()
print(job["video_url"] if job["status"] == "ready" else job["error"])
```


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