Wan 2.7 API Examples (i2v / t2v / r2v)
Wan 2.7 supports Image-to-Video (wan2.7-i2v), Text-to-Video (wan2.7-t2v), and Reference-to-Video (wan2.7-r2v). Use the Agentsflare gateway endpoints below.
-- Create: POST https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis -- Query: GET https://api.agentsflare.com/alibabacloudapi/v1/tasks/{task_id}
- Headers:
Authorization: Bearer <API_KEY>,X-DashScope-Async: enable,Content-Type: application/json
Vendor reference: For detailed parameter descriptions, see the Alibaba Cloud Model Studio reference: https://www.alibabacloud.com/help/en/model-studio/image-to-video-general-api-reference?spm=a2c63.p38356.help-menu-2400256.d_2_3_0.77cc40e5A1aQsq
Request parameters (summary)
| Parameter | Required | Description |
|---|---|---|
model | Yes | Model identifier: wan2.7-i2v / wan2.7-t2v / wan2.7-r2v |
input.prompt | Conditional (required for t2v) | Text prompt; required for t2v, recommended for i2v/r2v |
input.media | Conditional | Media list with objects like { "type": "...", "url": "..." } |
input.media.type | Conditional | first_frame / reference_image / reference_video (i2v/r2v) |
input.media.url | Conditional | Publicly accessible media URL |
parameters.resolution | Optional | Output resolution, e.g. 1080P |
parameters.duration | Yes | Duration in seconds |
parameters.ratio | Optional | Aspect ratio, e.g. 16:9 |
X-DashScope-Async (header) | Yes | Must be set to enable to create async tasks |
Authorization (header) | Yes | Bearer <API_KEY> |
Image-to-Video (i2v)
Note: use type: "first_frame" for single-frame input.
Examples below show cURL, Python, Node and Java usage.
curl -X POST "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis" \
-H "Authorization: Bearer $API_KEY" \
-H "X-DashScope-Async: enable" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-i2v",
"input": {
"prompt": "A dynamic graffiti character on a rainy night",
"media": [{ "type": "first_frame", "url": "https://example.com/first-frame.png" }]
},
"parameters": { "resolution": "1080P", "duration": 5 }
}'import requests
import os
API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis'
API_KEY = os.getenv('API_KEY')
payload = {
'model': 'wan2.7-i2v',
'input': {
'prompt': 'A dynamic graffiti character on a rainy night',
'media': [{ 'type': 'first_frame', 'url': 'https://example.com/first-frame.png' }]
},
'parameters': { 'resolution': '1080P', 'duration': 5 }
}
headers = {
'Authorization': f'Bearer {API_KEY}',
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
}
resp = requests.post(API_BASE, json=payload, headers=headers)
print(resp.status_code)
print(resp.text)const fetch = require('node-fetch');
const API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis';
const API_KEY = process.env.API_KEY;
const payload = {
model: 'wan2.7-i2v',
input: {
prompt: 'A dynamic graffiti character on a rainy night',
media: [{ type: 'first_frame', url: 'https://example.com/first-frame.png' }]
},
parameters: { resolution: '1080P', duration: 5 }
};
(async () => {
const res = await fetch(API_BASE, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
console.log(await res.text());
})();import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WanI2V {
public static void main(String[] args) throws Exception {
String apiBase = "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis";
String apiKey = System.getenv("API_KEY");
String json = "{\"model\":\"wan2.7-i2v\",\"input\":{\"prompt\":\"A dynamic graffiti character on a rainy night\",\"media\":[{\"type\":\"first_frame\",\"url\":\"https://example.com/first-frame.png\"}]},\"parameters\":{\"resolution\":\"1080P\",\"duration\":5}}";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(apiBase))
.header("Authorization", "Bearer " + apiKey)
.header("X-DashScope-Async", "enable")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode());
System.out.println(resp.body());
}
}Text-to-Video (t2v)
Below are cURL, Python, Node and Java examples.
curl -X POST "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis" \
-H "Authorization: Bearer $API_KEY" \
-H "X-DashScope-Async: enable" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-t2v",
"input": { "prompt": "A kitten runs on the grass at golden hour" },
"parameters": { "resolution": "1080P", "duration": 5, "ratio": "16:9" }
}'import requests
import os
API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis'
API_KEY = os.getenv('API_KEY')
payload = {
'model': 'wan2.7-t2v',
'input': { 'prompt': 'A kitten runs on the grass at golden hour' },
'parameters': { 'resolution': '1080P', 'duration': 5, 'ratio': '16:9' }
}
headers = {
'Authorization': f'Bearer {API_KEY}',
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
}
resp = requests.post(API_BASE, json=payload, headers=headers)
print(resp.status_code)
print(resp.text)const fetch = require('node-fetch');
const API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis';
const API_KEY = process.env.API_KEY;
const payload = {
model: 'wan2.7-t2v',
input: { prompt: 'A kitten runs on the grass at golden hour' },
parameters: { resolution: '1080P', duration: 5, ratio: '16:9' }
};
(async () => {
const res = await fetch(API_BASE, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
console.log(await res.text());
})();import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WanT2V {
public static void main(String[] args) throws Exception {
String apiBase = "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis";
String apiKey = System.getenv("API_KEY");
String json = "{\"model\":\"wan2.7-t2v\",\"input\":{\"prompt\":\"A kitten runs on the grass at golden hour\"},\"parameters\":{\"resolution\":\"1080P\",\"duration\":5,\"ratio\":\"16:9\"}}";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(apiBase))
.header("Authorization", "Bearer " + apiKey)
.header("X-DashScope-Async", "enable")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode());
System.out.println(resp.body());
}
}Reference-to-Video (r2v)
Use reference_image / reference_video and refer to assets in your prompt with "Image 1" / "Video 1".
Below are cURL, Python, Node and Java examples.
curl -X POST "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis" \
-H "Authorization: Bearer $API_KEY" \
-H "X-DashScope-Async: enable" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-r2v",
"input": {
"prompt": "Image 1 walks through a garden",
"media": [{ "type": "reference_image", "url": "https://example.com/ref.png" }]
},
"parameters": { "resolution": "1080P", "duration": 5 }
}'import requests
import os
API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis'
API_KEY = os.getenv('API_KEY')
payload = {
'model': 'wan2.7-r2v',
'input': {
'prompt': 'Image 1 walks through a garden',
'media': [{ 'type': 'reference_image', 'url': 'https://example.com/ref.png' }]
},
'parameters': { 'resolution': '1080P', 'duration': 5 }
}
headers = {
'Authorization': f'Bearer {API_KEY}',
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
}
resp = requests.post(API_BASE, json=payload, headers=headers)
print(resp.status_code)
print(resp.text)const fetch = require('node-fetch');
const API_BASE = 'https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis';
const API_KEY = process.env.API_KEY;
const payload = {
model: 'wan2.7-r2v',
input: {
prompt: 'Image 1 walks through a garden',
media: [{ type: 'reference_image', url: 'https://example.com/ref.png' }]
},
parameters: { resolution: '1080P', duration: 5 }
};
(async () => {
const res = await fetch(API_BASE, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-DashScope-Async': 'enable',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
console.log(await res.text());
})();import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WanR2V {
public static void main(String[] args) throws Exception {
String apiBase = "https://api.agentsflare.com/alibabacloudapi/v1/services/aigc/video-generation/video-synthesis";
String apiKey = System.getenv("API_KEY");
String json = "{\"model\":\"wan2.7-r2v\",\"input\":{\"prompt\":\"Image 1 walks through a garden\",\"media\":[{\"type\":\"reference_image\",\"url\":\"https://example.com/ref.png\"}]},\"parameters\":{\"resolution\":\"1080P\",\"duration\":5}}";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(apiBase))
.header("Authorization", "Bearer " + apiKey)
.header("X-DashScope-Async", "enable")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode());
System.out.println(resp.body());
}
}Query task
curl -X GET "https://api.agentsflare.com/alibabacloudapi/v1/tasks/<task_id>" \
-H "Authorization: Bearer $API_KEY"