# Image to Video

**What**：Animate a reference image into a video. wan2.7-i2v supports three tasks: first-frame, first+last frame (pass lastFrameUrl), and video continuation (pass a .mp4/.mov clip in imageUrls).

**When**：Use to animate an image, or to control start/end with first+last frame, or to continue from a clip.

## Endpoints
- POST `/v1/videos`
- GET `/v1/videos/{id}`
- GET `/v1/videos/{id}/content`

> This page uses the unified API: create with `POST /v1/videos`, poll with `GET /v1/videos/{id}`, authenticate with `Authorization: Bearer <key>`; errors use the OpenAI format.

Creating returns a video object right away (`status: queued`). Poll `GET /v1/videos/{id}` until `status` is `completed` or `failed`; `url` is the result address, or download it with `GET /v1/videos/{id}/content`.

## Request params
| Param | Type | Required | Description |
| --- | --- | --- | --- |
| model | string | Yes | wan2.7-i2v / wan2.5-i2v-preview (audio on by default) / happyhorse-1.0-i2v / happyhorse-1.1-i2v / wan3.0-video / wan3.0-video-prime (all-in-one: pass imageUrls for image-to-video, lastFrameUrl for keyframes) / vidu/viduq3-pro_img2video (account not enabled, currently unavailable) |
| imageUrls | string[] | Yes | Input image URL(s), usually first image is used as the first frame. Note: jpg / png only, no webp. For wan2.7-i2v continuation the first item may be a .mp4/.mov clip. |
| lastFrameUrl | string | — | Last frame URL (wan2.7-i2v first+last frame / continuation end frame) |
| prompt | string | — | Motion / camera prompt |
| duration | integer | — | Duration in seconds, default 5, affects billing; wan2.5-preview only 5 / 10; happyhorse 3-15; wan3.0-video/prime 2-30 (pass -1 for smart duration) |
| aspectRatio | string | — | Ratio / resolution mapping: 16:9 and 9:16 usually map to 1080P; 1:1 maps to 720P; 4:3/3:4 map to 480P |
| audio | boolean | — | Generate video with audio when supported |
| audioUrl | string | — | Optional audio URL |
| webhookUrl | string | — | Completion webhook URL |

`model`, `prompt`, `seconds`, `size` and `input_reference` are the common fields; the other fields are specific to this model channel and go in the same body under their own names. `seconds` / `size` (must be `WIDTHxHEIGHT`) are only translated when the matching channel field is absent.

## Request example
```bash
curl https://api.novapi.ai/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "wan2.7-i2v",
  "prompt": "镜头缓慢推进，光影自然变化",
  "imageUrls": [
    "https://example.com/first-frame.jpg"
  ],
  "aspectRatio": "16:9",
  "duration": 5
}'
```

```python
import os, requests

r = requests.post(
    "https://api.novapi.ai/v1/videos",
    headers={"Authorization": "Bearer " + os.environ["API_KEY"]},
    json={
        "model": "wan2.7-i2v",
        "prompt": "镜头缓慢推进，光影自然变化",
        "imageUrls": [
            "https://example.com/first-frame.jpg",
        ],
        "aspectRatio": "16:9",
        "duration": 5,
    },
)
print(r.json())  # poll GET /v1/videos/{id} until status is completed
```

```ts
const resp = await fetch("https://api.novapi.ai/v1/videos", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "wan2.7-i2v",
    "prompt": "镜头缓慢推进，光影自然变化",
    "imageUrls": [
      "https://example.com/first-frame.jpg"
    ],
    "aspectRatio": "16:9",
    "duration": 5
  }),
});
console.log(await resp.json()); // poll GET /v1/videos/{id} until status is completed
```

## Response example
```json
{
  "id": "video_<task-id>",
  "object": "video",
  "model": "wan2.7-i2v",
  "status": "queued",
  "progress": 0,
  "created_at": <unix-seconds>,
  "completed_at": null,
  "expires_at": null,
  "error": null
}
```

```json
{
  "id": "video_<task-id>",
  "object": "video",
  "model": "wan2.7-i2v",
  "status": "completed",
  "progress": 100,
  "created_at": <unix-seconds>,
  "completed_at": <unix-seconds>,
  "expires_at": null,
  "error": null,
  "url": "https://..."
}
```

```bash
curl https://api.novapi.ai/v1/videos/video_<task-id> \
  -H "Authorization: Bearer $API_KEY"

# completed: "status": "completed", "progress": 100, and a "url" field with the result
curl -L https://api.novapi.ai/v1/videos/video_<task-id>/content \
  -H "Authorization: Bearer $API_KEY" \
  --output result.mp4
```
