> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nunchux.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Authenticate every request with your API key in the `X-API-Key` header or `Authorization: Bearer`. Keys start with `sk-nunchux-`.
> Image generation is synchronous: the image is in the response.
> Video generation is asynchronous: submit the job, poll its task until it reaches a terminal status, then download the output promptly, because output URLs expire.

# Wan

> Alibaba Cloud's Wan video models for text-to-video, image-to-video, reference-to-video and video editing through one asynchronous endpoint.

# Wan

Wan is Alibaba Cloud's video model line. Each version generates a clip with a soundtrack from a text prompt, from a still image, or from a set of reference images, videos and audio. Wan 2.7 Video Edit restyles a clip you send. Generation is asynchronous. You submit a task, poll it until the status is terminal, then download the clip. The route mirrors Alibaba Cloud's own API, so the request and response shapes are the provider's.

> [!NOTE]
>
> Best for
>
> * Longer takes. Wan 3.0 holds a shot for up to 30 seconds in one clip.
> * Reference-driven scenes. Reference images, videos and audio carry a subject, a motion or a voice into new footage instead of animating one frame.
> * Draft passes. Wan 3.0 and Wan 3.0 Prime sell a 480P tier that the earlier versions do not.
> * Speed grades. Wan 3.0 Prime returns the same capabilities sooner than the standard grade.

## Models

| Model | Model ID | Tasks | Resolution | Duration | Reference images |
| - | - | - | - | - | - |
| Wan 3.0 | `wan3.0-video` | t2v, i2v, r2v | 480P, 720P, 1080P | 2 to 30 s | Up to 10 |
| Wan 3.0 Prime | `wan3.0-video-prime` | t2v, i2v, r2v | 480P, 720P, 1080P | 2 to 30 s | Up to 10 |
| Wan 2.7 | `wan2.7-t2v`, `wan2.7-i2v`, `wan2.7-r2v` | t2v, i2v, r2v | 720P, 1080P | 2 to 15 s | Up to 5 |
| Wan 2.7 Video Edit | `wan2.7-videoedit` | video edit | 720P, 1080P | 2 to 10 s | None |

Durations are whole seconds. Wan 3.0 and Wan 3.0 Prime use one model ID for all three tasks. The items in `input.media[]` select the task. No media item gives text-to-video. A `first_frame` item gives image-to-video. `reference_image` items give reference-to-video. Wan 2.7 uses one model ID per task.

Wan 3.0 gives the longest clips and the widest reference set. Use it when a shot has to develop, or when a subject must carry across a new scene. It takes an optional end frame on image-to-video.

Wan 3.0 Prime is the accelerated grade of Wan 3.0. Alibaba Cloud describes it as the high-speed version with capabilities aligned to the standard version. It has the same tasks, tiers, lengths and reference ceiling as Wan 3.0. Use it while you iterate.

Wan 2.7 has a shorter ceiling and a smaller reference set. On image-to-video it takes an optional end frame and a driving audio track.

Wan 2.7 Video Edit takes one source clip of 2 to 10 seconds and a prompt that says how to change it.

Reference videos and the edit source clip are billed by their length as well as the output. See [Billing for video inputs](#billing-for-video-inputs).

## Endpoints

| Step | Route |
| - | - |
| Submit | `POST /v1/alibaba/services/aigc/video-generation/video-synthesis` |
| Poll | `GET /v1/alibaba/tasks/{task_id}` |

[HappyHorse](https://docs.nunchux.ai/partner-models/happyhorse.md) uses the same two routes and the same body shape.

## Request

Send your API key in the `X-API-Key` header. See [Authentication](https://docs.nunchux.ai/authentication.md). Set `Content-Type: application/json`. The examples also send a `User-Agent` header that names your application.

**model** `string` *required*

The model ID from the table above. On Wan 3.0 and Wan 3.0 Prime the same ID serves every task.

**input** `object` *required*

The prompt and the media items.

**properties**

**prompt** `string` *required*

The text prompt. All tasks. Describe what moves and how the camera follows it. On reference-to-video, name a reference by its kind and position in `media[]`: `Image 1`, `Image 2`, `Video 1`, `Audio 1` and so on, with a space and a capital letter.

**media** `array`

The media items for image-to-video, reference-to-video and video editing. Omit it for text-to-video. A first frame and a reference set cannot appear in the same body.

**item properties**

**type** `string` *required*

What the item is.

* `first_frame`: the image the clip starts on. Image-to-video. One item.
* `last_frame`: the image the clip ends on. Image-to-video, optional. One item.
* `driving_audio`: a WAV or MP3 track for the clip. Wan 2.7 image-to-video only, optional.
* `reference_image`: a reference image. Reference-to-video. 1 to 10 items on Wan 3.0 and Wan 3.0 Prime, 1 to 5 items on Wan 2.7.
* `reference_video`: a reference clip. Reference-to-video on Wan 3.0, Wan 3.0 Prime and Wan 2.7. Its seconds are billed. See [Billing for video inputs](#billing-for-video-inputs).
* `reference_audio`: a reference voice or sound. Reference-to-video on Wan 3.0 and Wan 3.0 Prime. Up to 5 items and 15 seconds in total. Not billed as input.
* `video`: the clip to edit. Wan 2.7 Video Edit only, required. One item of 2 to 10 seconds. Its seconds are billed.

**url** `string` *required*

The URL of the file. The provider fetches it, so the URL must be reachable from the internet.

**parameters** `object`

The generation controls. All tasks read all three fields.

**properties**

**resolution** `string` (default: 1080P)

The output tier. `480P`, `720P` or `1080P` on Wan 3.0 and Wan 3.0 Prime. `720P` or `1080P` on Wan 2.7. The default is the most expensive tier, so name the one you want.

**duration** `integer` (default: 5)

The clip length in whole seconds. 2 to 30 on Wan 3.0 and Wan 3.0 Prime. 2 to 15 on Wan 2.7. On Wan 2.7 Video Edit it cuts the source clip to this length, 2 to 10. Omit it to keep the whole clip. You are billed per second of output, plus the input seconds of a reference video or an edit source.

**watermark** `boolean` (default: false)

Send `true` to burn the vendor's mark into the lower-right corner of every frame.

## Response

### Submit

A 200 status means that the provider accepted the task. It does not mean that the clip is ready.

**output** `object` *required*

**properties**

**task\_id** `string` *required*

The task ID. Poll `GET /v1/alibaba/tasks/{task_id}` with it.

**task\_status** `string` *required*

`PENDING` on a new task.

### Poll

**output.task\_status** `string` *required*

`PENDING` or `RUNNING` while the task runs. `SUCCEEDED`, `FAILED` or `CANCELED` when it ends. Poll until you read one of the three terminal values.

**output.video\_url** `string`

The URL of the clip. Present only when `task_status` is `SUCCEEDED`. The task ID and the URL expire after 24 hours. Download the clip as soon as the task succeeds.

**output.code** `string`

The failure code. Present when the task failed.

**output.message** `string`

The failure message. Read it before you resubmit.

## Example

Submit, poll, download. Swap the `model` value for the version you want.

```bash cURL theme={"system"}
BASE=https://api.nunchux.com

# 1. Submit
SUBMIT=$(curl -sS --fail-with-body "$BASE/v1/alibaba/services/aigc/video-generation/video-synthesis" \
  -H "X-API-Key: $NUNCHUX_API_KEY" \
  -H "Content-Type: application/json" \
  -H "User-Agent: YourApp/1.0" \
  -d '{
    "model": "wan3.0-video",
    "input": { "prompt": "a fox trotting through a snowy forest at dawn" },
    "parameters": { "resolution": "720P", "duration": 5, "watermark": false }
  }') || { echo "submit failed: $SUBMIT" >&2; exit 1; }
TASK=$(jq -er '.output.task_id' <<<"$SUBMIT") || { echo "no task_id in: $SUBMIT" >&2; exit 1; }

# 2. Poll until the status is terminal
DELAY=5
for _ in $(seq 1 90); do
  RESP=$(curl -sS "$BASE/v1/alibaba/tasks/$TASK" \
    -H "X-API-Key: $NUNCHUX_API_KEY" \
    -H "User-Agent: YourApp/1.0")
  STATUS=$(jq -r '.output.task_status // ""' <<<"$RESP")
  case "$STATUS" in SUCCEEDED|FAILED|CANCELED) break ;; esac
  sleep "$DELAY"; DELAY=$(( DELAY * 2 > 30 ? 30 : DELAY * 2 ))
done

# 3. Check for failure
[ "$STATUS" = "SUCCEEDED" ] || { echo "task $STATUS: $(jq -r '.output.message // "no message"' <<<"$RESP")" >&2; exit 1; }

# 4. Download
curl -sSL -o wan.mp4 "$(jq -r '.output.video_url' <<<"$RESP")"
```

```python Python theme={"system"}
# pip install requests
import os, time, requests

BASE = "https://api.nunchux.com"
HEADERS = {
    "X-API-Key": os.environ["NUNCHUX_API_KEY"],
    "User-Agent": "YourApp/1.0",
}

# 1. Submit
submit = requests.post(
    f"{BASE}/v1/alibaba/services/aigc/video-generation/video-synthesis",
    headers=HEADERS,
    json={
        "model": "wan3.0-video",
        "input": {"prompt": "a fox trotting through a snowy forest at dawn"},
        "parameters": {"resolution": "720P", "duration": 5, "watermark": False},
    },
)
if not submit.ok:
    raise RuntimeError(f"submit failed: HTTP {submit.status_code} {submit.text}")
task = submit.json()["output"]["task_id"]

# 2. Poll until the status is terminal
delay = 5
for _ in range(90):
    data = requests.get(f"{BASE}/v1/alibaba/tasks/{task}", headers=HEADERS).json()
    status = data.get("output", {}).get("task_status", "")
    if status in ("SUCCEEDED", "FAILED", "CANCELED"):
        break
    time.sleep(delay)
    delay = min(delay * 2, 30)
else:
    raise TimeoutError("Wan task did not reach a terminal status")

# 3. Check for failure
if status != "SUCCEEDED":
    raise RuntimeError(f"Wan task {status}: {data['output'].get('message')}")

# 4. Download
with requests.get(data["output"]["video_url"], stream=True, timeout=300) as r:
    r.raise_for_status()
    with open("wan.mp4", "wb") as f:
        for chunk in r.iter_content(1 << 14):
            f.write(chunk)
```

To animate a still, add a `first_frame` item to `input.media[]`. To carry a subject into a new scene, add `reference_image` items instead. A first frame and a reference set are separate tasks. The bodies below replace the submit body in the example.

```json Image-to-video theme={"system"}
{
  "model": "wan3.0-video",
  "input": {
    "prompt": "the fox turns and trots toward the camera",
    "media": [
      { "type": "first_frame", "url": "https://example.com/frame.jpg" }
    ]
  },
  "parameters": { "resolution": "720P", "duration": 5, "watermark": false }
}
```

```json Reference-to-video theme={"system"}
{
  "model": "wan3.0-video",
  "input": {
    "prompt": "the person from Image 1 walks through the doorway from Image 2, slow tracking shot",
    "media": [
      { "type": "reference_image", "url": "https://example.com/ref-1.jpg" },
      { "type": "reference_image", "url": "https://example.com/ref-2.jpg" }
    ]
  },
  "parameters": { "resolution": "720P", "duration": 5, "watermark": false }
}
```

```json Reference video theme={"system"}
{
  "model": "wan3.0-video",
  "input": {
    "prompt": "Video 1 dances through a sunlit park, handheld camera",
    "media": [
      { "type": "reference_video", "url": "https://example.com/dance.mp4" }
    ]
  },
  "parameters": { "resolution": "720P", "duration": 5, "watermark": false }
}
```

```json Video edit theme={"system"}
{
  "model": "wan2.7-videoedit",
  "input": {
    "prompt": "make the scene look like a watercolor painting",
    "media": [
      { "type": "video", "url": "https://example.com/source.mp4" }
    ]
  },
  "parameters": { "resolution": "720P", "duration": 5, "watermark": false }
}
```

## Billing for video inputs

Wan 3.0, Wan 3.0 Prime, Wan 2.7 reference-to-video and Wan 2.7 Video Edit bill the seconds of video you send as well as the seconds they generate. Both are billed at the per-second rate of the output tier you pick:

```text theme={"system"}
charge = (output seconds + billed input seconds) x per-second rate
```

How many input seconds are billed depends on the model:

| Model | Billed input seconds | Most per request |
| - | - | - |
| Wan 3.0, Wan 3.0 Prime | The total length of the reference videos | 15 s, and input plus output can't exceed 30 s |
| Wan 2.7 reference-to-video | The reference videos, shared out over a cap | 5 s, however many clips you send |
| Wan 2.7 Video Edit | The source clip, up to `duration` | 10 s |

Reference images and reference audio are not billed as input. A request without a video input is billed for its output only.

For example, a 5-second Wan 3.0 clip at 720P with an 8-second reference video bills 13 seconds: 5 output plus 8 input, at the 720P rate.

When you submit, your balance must cover the most the request can cost, which counts the input at the per-request maximum. The charge then settles to the seconds the provider reports, and the poll response shows them in `usage.input_video_duration` and `usage.output_video_duration`. On these models, [`GET /pricing`](https://docs.nunchux.ai/credits-pricing) marks the rows with `input_video_billed: true` and `max_billable_input_video_seconds`.

## Tips

* Say what moves and how the camera follows it. The prompt drives both, and motion is what the model has to generate.
* Name the sounds you want in the prompt when audio matters. The model scores what it reads.
* Send `resolution` and `duration` on every request. The defaults are 1080P and 5 seconds, and 1080P is the most expensive tier.
* Draft at 480P on Wan 3.0, then re-run the prompt at the tier and length you need. You are billed per second of output, so a long 1080P draft is the expensive way to test wording.
* Match the model to the job. A first frame fixes the composition. A reference set fixes the subject and lets the scene change.
* Upload the frame at the tier you intend to render. A small source limits what the model can resolve.
* Trim a reference video to the part you need before you send it. Its seconds are billed at the output rate.
* Poll every 5 seconds at first, then back off to 30 seconds. Polls are free and never use a concurrency slot.

## Errors and limits

A 200 status on submit means that the provider accepted the task. It does not mean that the task succeeded. A task that fails later ends with `task_status` set to `FAILED` or `CANCELED`, and `output.message` explains why. Read the message before you resubmit.

A failed submit returns an HTTP error status. The body carries `code`, `message` and `request_id`. See [Error codes](https://docs.nunchux.ai/errors.md).

A 5xx status or a timeout on submit does not tell you whether the task was created. Never resubmit blindly. If the submit returned a `task_id`, poll it. If it returned nothing, check your credits before you try again.

Alibaba Cloud applies these limits to each reference image:

* 240 to 8,000 pixels on each side
* An aspect ratio no wider than 8:1
* JPEG, JPG, PNG, BMP or WEBP. A transparent channel is not supported.
* Up to 20 MB per file

On Wan 3.0 and Wan 3.0 Prime, a reference video plus the output can't exceed 30 seconds, so a request with a reference video and `duration` 30 returns 400.

Every task counts toward the simultaneous-jobs cap of your plan. See [Rate limits](https://docs.nunchux.ai/rate-limits.md). Rates are per second of output, plus the input seconds of a video input, and depend on the tier. See [Credits & pricing](https://docs.nunchux.ai/credits-pricing.md) and the [Partner models overview](https://docs.nunchux.ai/partner-models/overview.md).


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