Process the input image using the EMO image detection API to obtain the coordinate values for the face area (face_bbox) and dynamic area (ext_bbox). These values are used as request parameters.
HTTP
Step 1: Create a task and get a task ID
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
Note
After you create the task, the system immediately returns a task_id. You can use this ID in Step 2 to query the task result. The task_id is valid for 24 hours after it is created.
import requests
import os
# 1. Get the API key from an environment variable.
api_key = os.getenv("DASHSCOPE_API_KEY")
# 2. Prepare the request.
url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis'
headers = {
'X-DashScope-Async': 'enable',
'Authorization': f'Bearer {api_key}',
}
payload = {
"model": "emo-v1",
"input": {
"image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251225/onmomb/emo.png",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/aejgyj/input_audio.mp3",
"face_bbox": [302, 286, 610, 593],
"ext_bbox": [71, 9, 840, 778]
},
"parameters": {
"style_level": "normal"
}
}
# 3. Send the POST request.
# Using the 'json' parameter, requests automatically handles JSON serialization and the 'Content-Type' header.
response = requests.post(url, headers=headers, json=payload)
# 4. Print the original JSON response from the server.
# If the request is successful, the task ID and other information are printed.
# If the request fails, the error message from the server is printed.
print(response.json())
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
/**
* Requirements:
* - Java 8 or later.
* - The DASHSCOPE_API_KEY environment variable must be set at runtime.
**/
public class DashScopeApiDemo {
public static void main(String[] args) throws IOException {
// 1. Get the API key from an environment variable.
String apiKey = System.getenv("DASHSCOPE_API_KEY");
// 2. Prepare the request.
String urlString = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis";
String payload = "{"
+ "\"model\": \"emo-v1\","
+ "\"input\": {"
+ "\"image_url\": \"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251225/onmomb/emo.png\","
+ "\"audio_url\": \"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/aejgyj/input_audio.mp3\","
+ "\"face_bbox\": [302, 286, 610, 593],"
+ "\"ext_bbox\": [71, 9, 840, 778]"
+ "},"
+ "\"parameters\": {"
+ "\"style_level\": \"normal\""
+ "}"
+ "}";
// 3. Send the POST request.
URL url = new URL(urlString);
// noinspection StartSSRFNetHookCheckingInspection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Bearer " + apiKey);
connection.setRequestProperty("X-DashScope-Async", "enable");
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
// Get the output stream and write the request body data.
try (OutputStream os = connection.getOutputStream()) {
byte[] input = payload.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// 4. Get and print the server response.
int statusCode = connection.getResponseCode();
System.out.println("Status Code: " + statusCode);
// Select the input stream (normal or error stream) based on the status code.
InputStream inputStream = (statusCode >= 200 && statusCode < 300)
? connection.getInputStream()
: connection.getErrorStream();
String responseBody;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
responseBody = reader.lines().collect(Collectors.joining("\n"));
}
System.out.println("Response Body: " + responseBody);
connection.disconnect();
}
}
// The node-fetch package is required.
// npm install node-fetch@2
// Import the node-fetch library.
const fetch = require('node-fetch');
// 1. Get the API key from an environment variable.
const apiKey = process.env.DASHSCOPE_API_KEY;
// 2. Prepare the request.
const url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis';
const headers = {
'X-DashScope-Async': 'enable',
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json' // This must be specified when using fetch.
};
const payload = {
"model": "emo-v1",
"input": {
"image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20251225/onmomb/emo.png",
"audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/aejgyj/input_audio.mp3",
"face_bbox": [302, 286, 610, 593],
"ext_bbox": [71, 9, 840, 778]
},
"parameters": {
"style_level": "normal"
}
};
// 3. Send a POST request and process the response.
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload) // The JavaScript object must be converted to a JSON string.
})
.then(response => response.json()) // Parse the response body as JSON.
.then(data => {
// 4. Print the JSON data returned by the server.
console.log(data);
});
Headers
X-DashScope-Asyncstring(Required)
The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to enable.
Important
If this request header is missing, the error message "current user api does not support synchronous calls" is returned.
Authorization string (Required)
This header is used for identity authentication. The API authenticates requests using a Model Studio API key. Example: Bearer sk-xxxx.
Content-Typestring(Required)
The content type of the request. Set this parameter to application/json.
Request Body
modelstring(Required)
The model name. Example: emo-v1.
inputobject(Required)
Specifies the basic input information.
Properties
image_urlstring(Required)
The URL of the uploaded image. The model crops the original image based on the ext_bbox parameter returned by the EMO image detection API. The aspect ratio of the cropped area directly determines the aspect ratio and resolution of the output video.
If the aspect ratio of `ext_bbox` is 1:1, a 512 × 512 profile picture video is generated. If the aspect ratio is 3:4, a 512 × 704 half-body portrait video is generated.
The minimum side length of the image must be at least 400 pixels. The maximum side length cannot exceed 7,000 pixels.
You can upload files using HTTP or HTTPS links. Local file paths are not supported.
face_bboxarray(Required)
The pixel coordinates of the bounding box (bbox) for the face area in the image. You can obtain this value from the `face_bbox` field in the response of the EMO image detection API. The coordinate format is `[x1, y1, x2, y2]`, which represents the coordinates of the top-left and bottom-right points. Example: `[302,286,610,593]`.
The top-left corner of the image is the origin (0,0). The x-axis extends to the right, and the y-axis extends downward.
ext_bboxarray(Required)
The pixel coordinates of the bounding box (bbox) for the dynamic area. You can obtain this value from the `ext_bbox` field in the response of the EMO image detection API. The aspect ratio of this area is 1:1 or 3:4. The coordinate format is `[x1, y1, x2, y2]`, which represents the coordinates of the top-left and bottom-right points. Example: `[71, 9, 840, 778]`.
parametersobject (Optional)
Properties
style_levelstring (Optional) Default value: normal
Controls the character's motion and amplitude. Three styles are supported: `normal` for moderate motion, `calm` for calm motion, and `active` for active motion. The default value is `normal`.
The ID of the submitted asynchronous task. The actual task result must be retrieved using the asynchronous task query API. Example: a8532587-fa8c-4ef8-82be-xxxxxx.
task_statusstring
The status of the task after it is submitted. Example: "PENDING".
request_idstring
The unique request ID. You can use this ID to trace and troubleshoot issues.
codestring
The error code returned when the request fails. For more information, see Error codes.
message string
The detailed error message returned when the request fails. For more information, see Error codes.
Step 2: Query the result based on the task ID
Use the task_id from the previous step to poll for the task status and result. Replace {task_id} in the URL with your actual task ID.
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Note
`task_id` validity: The ID is valid for 24 hours after it is created. After this period, you can no longer query the result. The API returns a task status of UNKNOWN.
Task status flow: A task that is processed normally transitions through the following statuses: `PENDING`, `RUNNING`, and `SUCCEEDED` or `FAILED`.
Result retrieval: Video generation takes several minutes. The query API has a default limit of 20 QPS. Use a polling mechanism with a reasonable query interval, such as 15 seconds, to retrieve the result.
video_url validity: After the task succeeds, the URL is valid for 24 hours. You must download the video and transfer it to permanent storage immediately after you retrieve the link (such as Object Storage Service (OSS)).
Request parameters
curl -X GET \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
import requests
import os
# 1. Get the API key from the environment variable.
api_key = os.getenv("DASHSCOPE_API_KEY")
# 2. Replace this with the actual ID of the task you want to query.
task_id = "a8532587-fa8c-4ef8-82be-xxxxxx"
# 3. Prepare the request information.
# Use an f-string to append the task_id to the URL.
url = f"https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}"
headers = {
'Authorization': f'Bearer {api_key}'
}
# 4. Send a GET request.
response = requests.get(url, headers=headers)
# 5. Print the JSON response from the server.
# This displays the task status (such as "RUNNING", "SUCCEEDED", or "FAILED") and the result.
print(response.json())
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
/**
* Requirements:
* - Java 8 or later.
* - The DASHSCOPE_API_KEY environment variable must be set at runtime.
**/
public class TaskStatusChecker {
public static void main(String[] args) throws IOException {
// 1. Get the API key from the environment variable.
String apiKey = System.getenv("DASHSCOPE_API_KEY");
// 2. Replace this with the actual ID of the task you want to query.
String taskId = "a8532587-fa8c-4ef8-82be-xxxxxx"; // Replace this with your task ID.
// 3. Prepare the request information (dynamically construct the URL).
String urlString = "https://dashscope.aliyuncs.com/api/v1/tasks/" + taskId;
// 4. Create a connection and send a GET request.
URL url = new URL(urlString);
// noinspection StartSSRFNetHookCheckingInspection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
// Set the request headers.
connection.setRequestProperty("Authorization", "Bearer " + apiKey);
// 5. Get and print the server response.
int statusCode = connection.getResponseCode();
System.out.println("Status Code: " + statusCode);
InputStream inputStream = (statusCode >= 200 && statusCode < 300)
? connection.getInputStream()
: connection.getErrorStream();
String responseBody;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
responseBody = reader.lines().collect(Collectors.joining("\n"));
}
System.out.println("Response Body: " + responseBody);
connection.disconnect();
}
}
// The node-fetch package is required.
// npm install node-fetch@2
// Import the node-fetch library.
const fetch = require('node-fetch');
// 1. Get the API key from the environment variable.
const apiKey = process.env.DASHSCOPE_API_KEY;
// 2. Replace this with the actual ID of the task you want to query.
const taskId = "a8532587-fa8c-4ef8-82be-xxxxxx"; // <-- Replace this with your task ID.
// 3. Prepare the request information.
// Use a template literal to append the taskId to the URL. This is similar to an f-string in Python.
const url = `https://dashscope.aliyuncs.com/api/v1/tasks/${taskId}`;
const headers = {
'Authorization': `Bearer ${apiKey}`
};
// 4. Send a GET request.
// The default request method for fetch is GET, so you can omit method: 'GET'.
fetch(url, {
headers: headers
})
.then(response => response.json()) // Parse the response body as JSON.
.then(data => {
// 5. Print the JSON response from the server.
// This displays the task status (such as "RUNNING" or "SUCCEEDED") and the result.
console.log(data);
});
Headers
Authorization string (Required)
Used for request identity authentication. The API uses Model Studio API key for authentication. Example: Bearer sk-xxxx.
URL path parameters
task_idstring(Required)
The `task_id` of the task to query. Example: a8532587-fa8c-4ef8-82be-xxxxxx.
{
"output": {
"task_id": "a8532587-fa8c-4ef8-82be-xxxxxx",
"task_status": "FAILED",
"code": "InvalidURL",
"message": "Required URL is missing or invalid, please check the request URL."
},
"request_id": "4d687387-580a-4b49-a1f8-4691289e09a3"
}
request_idstring
The unique request ID. You can use this ID to trace and troubleshoot issues.
output object
Contains the task output information.
Properties
task_id string
The `task_id` of the queried task. Example: a8532587-fa8c-4ef8-82be-xxxxxx.
task_statusstring
The task status.
Enumeration
PENDING
RUNNING
SUCCEEDED
FAILED
CANCELED
UNKNOWN: The task does not exist or its status cannot be determined.
submit_timestring
The time when the task was submitted. The time zone is UTC+8. Example: 2025-09-11 14:33:38.716.
scheduled_timestring
The time when the task was scheduled to start. The time zone is UTC+8. Example: 2025-09-11 14:33:53.089.
end_timestring
The time when the task finished. The time zone is UTC+8. Example: 2025-09-11 14:35:51.541.
resultsobject
The task execution result.
Properties
video_urlstring
The URL of the video result that is generated by the platform. The `video_url` is valid for 24 hours after the task is completed. You must download and save the video file promptly. Example: http://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxxx.
codestring
The error code returned when the request fails. For more information, see Error codes.
message string
The detailed error message returned when the request fails. For more information, see Error codes.
usageobject
Properties
video_durationfloat
The duration of the video generated by this request, in seconds. Example: 13.93.
video_ratiostring
The aspect ratio of the video generated by this request. The value is 1:1 or 3:4.
Billing and rate limits
Model name
Unit price
Task submission QPS limit
Concurrent tasks
emo-v1
Pay-as-you-go. You are charged based on the actual duration of the output video: