> ## 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: First Frame to Video

> Anchor a MiniMax H3 video on a starting frame, uploaded directly or by URL.

Supply a starting frame alongside a text prompt to `POST /v1/videos`, and poll the returned video until it's ready. `prompt` is still required even though you're also supplying an image — text guides how the frame animates. This is one of three **H3 Video** modes; see also [Text to Video](/v1/guides/quickstart-text-to-video) and [First-Last Frames to Video](/v1/guides/quickstart-first-last-frame-to-video).

Set `VIGGLE_API_KEY` and run the example below as-is — it uses a Viggle-hosted sample image, so you don't need to prepare your own starting frame first.

## 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 and a `quality` choice: `low` or `high`

<Note>
  The example below references a placeholder sample asset URL (`https://assets.viggle.ai/samples/first-frame.png`). Swap in your own `first_frame_image`/`first_frame_image_url`, or Viggle's published sample asset once available.
</Note>

## 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="camera slowly zooms out" \
    -F quality=high \
    -F first_frame_image_url=https://assets.viggle.ai/samples/first-frame.png)
  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", "camera slowly zooms out");
    form.append("quality", "high");
    form.append("first_frame_image_url", "https://assets.viggle.ai/samples/first-frame.png");

    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": "camera slowly zooms out", "quality": "high"},
      files={"first_frame_image_url": (None, "https://assets.viggle.ai/samples/first-frame.png")},
  )
  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"` — 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. Supply exactly one of `first_frame_image` (file upload) or `first_frame_image_url`; supplying both answers `400 INVALID_REQUEST`.

See [Pricing and retention](/v1/pricing#h3-video) — image-conditioned generation costs the same as text-only for the same `quality` and `duration_s`.

<Card title="Generate Video (from First Frame and/or Text)" icon="image" href="/v1/api-reference/videos/create-from-first-frame">
  See every field, both upload forms, and common validation errors.
</Card>
