Wan 2.7 API Integration Guide & Examples
| Model | Capability | Required fields |
|---|---|---|
wan2.7-t2v | Text to video | input.prompt |
wan2.7-i2v | Image 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) athttps://api.modelgo.ai/api/v1and use your ModelGo API key asapi_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.
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:
"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
| Field | Applies to | Description |
|---|---|---|
input.prompt | All | Scene 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[] | All | Items 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_url | i2v | Legacy spellings, equivalent to the first_frame / last_frame media items |
input.audio_url | All | Driving-audio URL (wav/mp3), the official t2v spelling; on i2v use the driving_audio media item |
input.negative_prompt | All | Negative prompt |
parameters.resolution | All | 720P / 1080P, default 1080P |
parameters.ratio | All | 16: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.size | t2v | Pixel spelling (see the table below); when given together with ratio, the aspect ratios must match |
parameters.duration | All | Duration in seconds, default 5 |
parameters.prompt_extend / watermark / seed | All | Prompt rewriting / watermark / random seed |
- The same item cannot be given in both the new and the legacy spelling.
- Keys in
inputoutside the table (e.g.ref_images_url, or a flatfirst_clip_url) are refused; keys inparametersoutside the table (e.g. the deprecatedshot_type) do not raise an error, and the upstream ignores them.
Resolution tiers
| Tier | 16:9 | 9:16 | 1:1 | 4:3 | 3:4 |
|---|---|---|---|---|---|
| 720P | 1280*720 | 720*1280 | 960*960 | 1088*832 | 832*1088 |
| 1080P | 1920*1080 | 1080*1920 | 1440*1440 | 1632*1248 | 1248*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}
curl https://api.modelgo.ai/api/v1/tasks/gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5 \
-H "Authorization: Bearer $MODELGO_API_KEY"On completion:
{
"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 failureoutput.code/output.messagegive the reason, and the task is not charged.- Generation usually takes 1–3 minutes; poll every 5–10 seconds with backoff.
output.video_urlpoints 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
curl https://api.modelgo.ai/v1/videos/gw_e99647a0-692d-4fdd-ae46-e1d777e72bf5/content -o cat.mp4Returns 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.