# Video Editing

**What**：Generate an edited video from a source video + instruction; supports instruction-only edits (restyle) and reference-image local replacement (e.g. clothing swap).

**When**：Use to restyle, alter visuals, or edit an existing video.

## 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-videoedit / happyhorse-1.0-video-edit |
| prompt | string | Yes | Edit instruction |
| imageUrls | string[] | — | First item is the source video URL (required, 2-10s, mp4/mov, <=100MB); the rest are reference images for local replacement (jpg/png; wan2.7 <=4, happyhorse <=5) |
| duration | integer | — | Output duration in seconds; default = same as input, truncates only within [2,10]. Post-paid: final charge follows real usage, not this value |
| aspectRatio | string | — | Ratio / resolution mapping |
| 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-videoedit",
  "prompt": "把视频改成冬季雪景氛围",
  "imageUrls": [
    "https://example.com/source-video.mp4"
  ],
  "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-videoedit",
        "prompt": "把视频改成冬季雪景氛围",
        "imageUrls": [
            "https://example.com/source-video.mp4",
        ],
        "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-videoedit",
    "prompt": "把视频改成冬季雪景氛围",
    "imageUrls": [
      "https://example.com/source-video.mp4"
    ],
    "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-videoedit",
  "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-videoedit",
  "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
```
