Wan 2.7 API Integration Guide & Examples

ModelCapabilityRequired fields
wan2.7-t2vText to videoinput.prompt
wan2.7-i2vImage to video (first frame, optional last frame)a first_frame (legacy spelling: input.img_url) or first_clip in input.media[]; input.prompt is optional

ModelGo accepts the official paths and request/response shapes of Alibaba Bailian's DashScope asynchronous video synthesis API: create → poll → fetch content.

With the official DashScope SDK, point base_url (DASHSCOPE_HTTP_BASE_URL) at https://api.modelgo.ai/api/v1 and use your ModelGo API key as api_key.

1. Create a task

POST https://api.modelgo.ai/api/v1/services/aigc/video-generation/video-synthesis, with the X-DashScope-Async: enable header.

bash
curl https://api.modelgo.ai/api/v1/services/aigc/video-generation/video-synthesis \
  -H "Authorization: Bearer $MODELGO_API_KEY" \
  -H "X-DashScope-Async: enable" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-t2v",
    "input": {"prompt": "A fluffy orange kitten playing with a ball of yarn on a sunny windowsill"},
    "parameters": {"resolution": "1080P", "duration": 5, "prompt_extend": true}
  }'

For image to video, set model to wan2.7-i2v and give the first frame in input.media; prompt may be omitted, in which case the model animates the frame on its own:

json
"input": {
  "prompt": "The cat slowly tilts its head and blinks",
  "media": [{"type": "first_frame", "url": "https://example-cdn.com/cat.jpg"}]
}

A successful create returns {"output": {"task_id": "gw_…", "task_status": "PENDING"}}; output.task_id is the gateway task id used for polling and downloading.

2. Parameters

FieldApplies toDescription
input.promptAllScene and motion description. Required on t2v; optional on i2v, where a first frame (first_frame / img_url) or a continuation clip (first_clip) alone is enough to create the task — but one of the two must be present
input.media[]AllItems of the form {"type": ..., "url": ...}: first_frame, last_frame and first_clip (video continuation) are i2v only and are refused on t2v; driving_audio works on both models. A type cannot repeat, and other type values are refused
input.img_url / input.last_frame_urli2vLegacy spellings, equivalent to the first_frame / last_frame media items
input.audio_urlAllDriving-audio URL (wav/mp3), the official t2v spelling; on i2v use the driving_audio media item
input.negative_promptAllNegative prompt
parameters.resolutionAll720P / 1080P, default 1080P
parameters.ratioAll16:9 (default) / 9:16 / 1:1 / 4:3 / 3:4; any other value returns 400. aspect_ratio is also accepted; when both are given they must match
parameters.sizet2vPixel spelling (see the table below); when given together with ratio, the aspect ratios must match
parameters.durationAllDuration in seconds, default 5
parameters.prompt_extend / watermark / seedAllPrompt rewriting / watermark / random seed
  • The same item cannot be given in both the new and the legacy spelling.
  • Keys in input outside the table (e.g. ref_images_url, or a flat first_clip_url) are refused; keys in parameters outside the table (e.g. the deprecated shot_type) do not raise an error, and the upstream ignores them.

Resolution tiers

Tier16:99:161:14:33:4
720P1280*720720*1280960*9601088*832832*1088
1080P1920*10801080*19201440*14401632*12481248*1632

Only 720P / 1080P are offered; 4K or a size outside the table returns 400 at create time and is not charged. For 4:3 / 3:4, size also accepts the Bailian spellings: 720P 1104*832 / 832*1104, 1080P 1648*1248 / 1248*1648.

Audio

Wan 2.7 has no audio switch: without driving audio the model generates matching background music or sound effects itself; with driving audio, your audio becomes the soundtrack. An explicit request for silence (parameters.audio=false or generate_audio=false) returns 400 at create time; true is the same as omitting it.

Video continuation (first_clip, i2v only)

The {"type": "first_clip", "url": "<direct video link>"} media item continues an existing clip: it must be a 2–10 s mp4 / mov, it cannot be combined with first_frame (img_url) or driving_audio (audio_url), and it can be paired with last_frame.

Media URL requirements

The first-frame image must be a direct link the upstream can GET: no authentication, no redirect, no Referer / Cookie dependency; a continuation clip must likewise be publicly downloadable. If the first frame cannot be fetched, the task fails (task_status=FAILED) and is not charged; use your own object storage or CDN.

3. Poll the task

GET https://api.modelgo.ai/api/v1/tasks/{task_id}

bash
curl https://api.modelgo.ai/api/v1/tasks/gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5 \
  -H "Authorization: Bearer $MODELGO_API_KEY"

On completion:

json
{
  "output": {
    "task_id": "gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5",
    "task_status": "SUCCEEDED",
    "video_url": "https://api.modelgo.ai/v1/videos/gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5/content"
  },
  "usage": {"video_duration": 6, "video_count": 1},
  "request_id": "gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5"
}
  • task_status: PENDING → RUNNING → SUCCEEDED / FAILED. On failure output.code / output.message give the reason, and the task is not charged.
  • Generation usually takes 1–3 minutes; poll every 5–10 seconds with backoff.
  • output.video_url points at the gateway content endpoint and needs no credential — the link itself is the credential, so do not share or persist it.

4. Download the video

bash
curl https://api.modelgo.ai/v1/videos/gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5/content -o cat.mp4

Returns the video/mp4 bytes and supports Range; 409 while unfinished, 404 when expired or missing.

5. Billing

Billed by delivered video seconds (usage.video_duration) × the resolution tier's unit price, as shown in the console model list; a refused create (400) or a failed generation (FAILED) is not charged.