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

# Video Remix (JST-1)

> Make a character from one image perform the motion in any video. One request, $0.01 per character per second, optional alpha output.

Video Remix puts a character on a motion. You send one character image and one motion video (a dance, a meme, a performance), and JST-1 renders that character doing the same moves. Output is an MP4, with an optional alpha video for compositing.

Use it for character dances, meme templates and mascot videos where the motion comes from an existing clip. To replace the people inside a video while keeping its scene, use [Viggle Remake](https://docs.viggle.ai/v1/video/remake.md) instead.

The API resource is a render: you create it with `POST /v1/renders`, its ID starts with `render_`, and you read it back with `GET /v1/videos/{render_id}`.

## What you send

One character source and one motion source, as `multipart/form-data`.

| Input | Send one of | Notes |
| - | - | - |
| Character | `image` (file), `image_url`, or `character_id` | `character_id` is a saved [Character](https://docs.viggle.ai/v1/video/reusable-characters-and-motions.md) |
| Motion | `motion_video` (file), `motion_video_url`, or `motion_id` | `motion_id` is a saved Motion, or one imported from a Viggle template |
| `background_mode` | Optional | `original` (default), `solid` or `transparent`. See [Transparent output](https://docs.viggle.ai/v1/video/transparent-output.md) |
| `bg_color` | With `solid` only | `R,G,B`, for example `0,255,0` |
| `character_mapping` | Optional | Multi-person motions: which Character replaces which person. See [below](#multi-person-renders) |

### Media limits

| Input | Limit |
| - | - |
| Character image | Upload up to 20 MiB. JPEG, PNG, WebP, GIF, BMP, TIFF or HEIC. Images with a long edge of 3840 px or more, or a short edge of 2160 px or more, are scaled down to fit 1920×1080 (1080×1920 for portrait images) |
| Motion video | Up to 100 MiB, 0.5–600 seconds, at least 64×64 pixels, even width and height. Any common video container works; MP4, MOV or WebM is recommended |
| URLs | Public `http(s)://` URLs the service can fetch |

A saved Character or Motion keeps working after its uploaded source is deleted (1 hour after processing), as long as you leave `mode` unset and render with the same `model` it was created with. See [Manage saved assets](https://docs.viggle.ai/v1/video/reusable-characters-and-motions.md#manage-saved-assets).

## Price

$0.01 (1 credit) per character, per second of finished video, with a minimum of 0.5 credit ($0.005) per render.

```text theme={null}
reserved = max(0.5, motion seconds × characters)   (10 s when the length isn't known yet)
charged  = 1 credit per character per finished second, minimum 0.5
```

A 10-second render of one character costs 10 credits ($0.10). Mapping 3 people in the same 10-second motion costs 30 credits ($0.30).

* At create, the service reserves the motion's measured length × characters, or 10 seconds when the length isn't known yet. If your balance can't cover it, the request fails with `402 INSUFFICIENT_CREDITS`.
* When the render is `ready`, the charge is settled to the finished length.
* A failed or cancelled render is refunded in full.

## Make your first render

Export `VIGGLE_API_KEY` and run one of these as-is. They use a sample character image and a 6.88-second sample dance hosted by Viggle, so the render costs about 6.88 credits (\$0.07). Each script 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"

render_id=$(curl -sS --fail-with-body "$API/renders" \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F image_url="https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp" \
  -F motion_video_url="https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4" | jq -er '.id')
echo "Submitted $render_id"

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

```javascript Node.js theme={null}
// Node.js 20+. Save as video-remix.mjs, then run: node video-remix.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("image_url", "https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp");
form.append("motion_video_url", "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4");
const { id } = await call("/renders", { method: "POST", body: form });
console.log(`Submitted ${id}`);

for (let i = 0; i < 120; i++) {
  const render = await call(`/videos/${id}`);
  if (render.status === "ready") {
    console.log(render.video_url);
    process.exit(0);
  }
  if (render.status === "failed" || render.status === "cancelled") {
    throw new Error(`${render.status}: ${JSON.stringify(render.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.
render = check(requests.post(f"{API}/renders", headers=HEADERS, timeout=300, files={
    "image_url": (None, "https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp"),
    "motion_video_url": (None, "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4"),
}))
print("Submitted", render["id"])

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

To upload local files instead, send `image=@character.png` and `motion_video=@motion.mp4` in place of the URL fields. To resend a request safely after a network error, add an `Idempotency-Key` header. For 24 hours, a second request with the same key never starts a second render. With saved IDs (`character_id`, `motion_id`) or a draft, it returns the original render. With uploaded files or URLs, it answers `409 IDEMPOTENCY_KEY_REUSED` instead; find the original in `GET /v1/videos`.

## Track, download and cancel

| Action | Call | What happens |
| - | - | - |
| Poll | `GET /v1/videos/{render_id}` | Returns `status`, `progress` and, while processing, `stage` (`analyzing`, `rendering`, `finishing`) |
| Watch | `GET /v1/renders/{render_id}/events` | A Server-Sent Events stream of the same state. See below |
| Download | `GET /v1/renders/{render_id}/download` | `302` redirect to the finished MP4 |
| Cancel | `DELETE /v1/renders/{render_id}` | Stops a queued or processing render and refunds its reservation. Returns the render; a finished render is returned unchanged |

When the render is `ready`, `video_url` holds the finished MP4 (and `alpha_url` the alpha video, for `transparent`). These are CDN links, not one-hour signed links. Results are deleted 24 hours after the render finishes: after that the URLs read `null` and download answers `404 RESULT_EXPIRED`. Only the API key that created a render can read, download or cancel it.

### Watch with Server-Sent Events

Instead of polling, hold one connection open:

```bash theme={null}
curl -N "https://apis.viggle.ai/v1/renders/$RENDER_ID/events" \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -H "Accept: text/event-stream"
```

The first event is a `snapshot` of the current state. After that you get an event named after each status change (`queued`, `processing`, `ready`, `failed`, `cancelled`), `progress` events when progress or stage moves, and a `heartbeat` every 12 seconds. The stream closes after a terminal status. Each event's `data` is JSON with `status`, `stage`, `progress`, `video_url`, `alpha_url` and `error`.

> [!NOTE]
>
> The stream does not replay missed events, and `Last-Event-ID` is ignored. If the connection drops, reconnect: you get a fresh `snapshot` of the current state.

## Direct upload vs draft

There are two ways to submit a render. Both cost the same and produce the same render.

| | Direct (`multipart/form-data`) | Draft (`prepare`, then JSON) |
| - | - | - |
| Media travels | In the request body | Straight to storage with a signed `PUT` |
| Calls | One | Prepare, upload, create |
| Best for | Servers, scripts, URL or saved-asset inputs | Browser or mobile clients, large files, retried uploads |
| Response | `200` | `202` |
| `Idempotency-Key` | Optional | Required |

### Draft flow

**1. Prepare**

Describe each input. `kind` is `upload` (with `filename`, `content_type` and `bytes`, plus an optional `sha256`), `url` (an `https://` URL), or `asset` (a saved `char_` or `mot_` ID). To use a Viggle motion template, import it first and pass the `mot_` ID as an `asset`. Prepare is free.

```bash theme={null}
curl https://apis.viggle.ai/v1/renders/prepare \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"character\": {\"kind\": \"upload\", \"filename\": \"character.png\", \"content_type\": \"image/png\", \"bytes\": $(wc -c < character.png | tr -d ' ')},
    \"motion\": {\"kind\": \"asset\", \"asset_id\": \"mot_550e8400-e29b-41d4-a716-446655440000\"}
  }"
```

The response has a `draft_id` and one upload plan per `upload` input:

```json theme={null}
{
  "draft_id": "draft_7d0c5d0e-9a43-4c1e-8f1b-1f2a3b4c5d6e",
  "state": "awaiting_uploads",
  "uploads": [
    {
      "slot": "character",
      "upload_handle": "draft_7d0c5d0e-9a43-4c1e-8f1b-1f2a3b4c5d6e:character",
      "method": "PUT",
      "url": "https://...",
      "required_headers": { "Content-Type": "image/png" },
      "expires_at": "2026-11-20T10:12:03Z"
    }
  ]
}
```

**2. Upload**

`PUT` the exact bytes to each `uploads[].url` with its `required_headers`, before `expires_at` (one hour). Upload limits are the same as direct: 20 MiB for the character, 100 MiB for the motion.

```bash theme={null}
curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/png" --data-binary @character.png
```

**3. Create**

Send the `draft_id` as JSON with an `Idempotency-Key`. The service checks that each upload arrived with the declared size (and `sha256`, if you gave one), then starts the render.

```bash theme={null}
curl https://apis.viggle.ai/v1/renders \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"draft_id": "draft_7d0c5d0e-9a43-4c1e-8f1b-1f2a3b4c5d6e"}'
```

It answers `202` with a `render_` ID. Track it like any other render.

A draft lasts one hour. Prepare also takes an optional `output` object: `background_mode` (`original`, `green`, `white` or `transparent`). Only the source aspect ratio is supported.

## Multi-person renders

A Motion imported from a multi-person Viggle template keeps one track per person, keyed by that person's UUID in the template. Send `character_mapping` to choose which saved Character replaces each person:

```bash theme={null}
curl https://apis.viggle.ai/v1/renders \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F motion_id=mot_550e8400-e29b-41d4-a716-446655440000 \
  -F character_id=char_4b8d1e6a-2f3c-4a9e-b5d7-0c1e2f3a4b5c \
  -F 'character_mapping={"TRACK_ID_1":"char_4b8d1e6a-2f3c-4a9e-b5d7-0c1e2f3a4b5c","TRACK_ID_2":"char_9e7c5a3b-1d2f-4e6a-8b0c-2d4f6a8c0e1b"}'
```

* Keys are the Motion's track IDs. An unknown key is rejected with `400`, and the error message lists the valid keys.
* Values are Character IDs you own that are `ready`.
* `character_id` (or `image` / `image_url`) is still required. People you leave out of the mapping are rendered with it.
* Each mapping entry counts as one character in the price.

## Use a Viggle motion template

Viggle motion templates are ready-made motions, including multi-person ones. Find template IDs on [viggle.ai](https://viggle.ai): an official template from the Viggle template catalog, or a template made in the Viggle app (its ID may start with `3s`; send it as copied). The API has no endpoint that lists templates. A render can't take a template ID directly: import the template once with `POST /v1/motions/import` and `{"template_id": "..."}`. You get a reusable `mot_` ID to pass as `motion_id` (or as an `asset` in a draft), which is also what multi-person renders need. Importing costs 1 credit per second of the template, at least 1 credit. See [Import a motion template](https://docs.viggle.ai/v1/api-reference/motions/import-a-motion-template.md).

## Next steps

> [card] [Reusable characters and motions](https://docs.viggle.ai/v1/video/reusable-characters-and-motions.md)
>
> Save a character or motion once and render it many times.

> [card] [Transparent output](https://docs.viggle.ai/v1/video/transparent-output.md)
>
> Get an alpha video for compositing, or a solid background.

> [card] [Create a render (API reference)](https://docs.viggle.ai/v1/api-reference/renders/create-a-render.md)
>
> Every field for `POST /v1/renders`.

> [card] [Prepare a render (API reference)](https://docs.viggle.ai/v1/api-reference/renders/prepare-a-render.md)
>
> The draft request and upload plans.


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