全部產品
Search
文件中心

Alibaba Cloud Model Studio:EMO 視頻產生 API參考

更新時間:Dec 27, 2025

EMO模型可基於人物肖像圖片和人聲音頻,產生人臉動態視頻。

重要

本文檔僅適用於“中國(北京)”地區。如需使用模型,需使用“中國(北京)”地區的API Key

效果樣本

輸入樣本

輸出樣本

人物肖像:

上春山

人聲音頻:

使用動作風格強度:參數 style_level 設定為 'active'

更多效果樣本請參見模型效果樣本

說明

請確保上傳的圖片、音頻檔案來源符合相關法律法規,且已獲得相應內容的使用許可。

前提條件

HTTP調用

步驟1:建立任務擷取任務ID

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis
說明
  • 建立任務後,系統將立即返回一個 task_id,用於“步驟2”查詢任務結果。task_id 自建立起有效期間為24小時

請求參數

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "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"
        }
    }'
import requests
import os

# 1. 從環境變數擷取 API Key
api_key = os.getenv("DASHSCOPE_API_KEY")

# 2. 準備請求資訊
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. 發送 POST 請求
#    使用 'json' 參數,requests會自動處理JSON序列化和'Content-Type'頭
response = requests.post(url, headers=headers, json=payload)

# 4. 列印伺服器返回的原始JSON響應
#    如果請求成功,會列印任務ID等資訊。
#    如果請求失敗,會列印伺服器返回的錯誤資訊。
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;
/**
 * 要求:
 * - Java 8 或更高版本。
 * - 運行時需要設定環境變數 DASHSCOPE_API_KEY。
 **/
public class DashScopeApiDemo {

    public static void main(String[] args) throws IOException {
        // 1. 從環境變數擷取 API Key
        String apiKey = System.getenv("DASHSCOPE_API_KEY");
        // 2. 準備請求資訊
        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. 發送 POST 請求
        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);
        // 擷取輸出資料流並寫入請求體資料
        try (OutputStream os = connection.getOutputStream()) {
            byte[] input = payload.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }
        // 4. 擷取並列印伺服器響應
        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();
    }
}
// 需要安裝node-fetch包
// npm install node-fetch@2

// 匯入 node-fetch 庫
const fetch = require('node-fetch');
// 1. 從環境變數擷取 API Key
const apiKey = process.env.DASHSCOPE_API_KEY;
// 2. 準備請求資訊
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' // 使用 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. 發送 POST 請求並處理響應
fetch(url, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(payload) // 必須將 JS 對象轉換為 JSON 字串
})
.then(response => response.json()) // 將響應體解析為 JSON
.then(data => {
    // 4. 列印伺服器返回的 JSON 資料
    console.log(data);
});
要求標頭(Headers)

X-DashScope-Async string (必選)

非同步處理配置參數。HTTP請求只支援非同步,必須設定為enable

重要

缺少此要求標頭將報錯:“current user api does not support synchronous calls”。

Authorization string(必選)

請求身份認證。介面使用阿里雲百鍊API Key進行身份認證。樣本值:Bearer sk-xxxx。

Content-Type string (必選)

請求內容類型。此參數必須設定為application/json

請求體(Request Body)

model string (必選)

模型名稱。樣本值:emo-v1。

input object (必選)

輸入的基本資料。

屬性

image_url string (必選)

使用者上傳的圖片 URL。模型將根據EMO映像檢測API返回的 ext_bbox 參數,對原始圖片進行裁剪。裁剪後地區的寬高比直接決定了輸出視頻的畫幅比例與解析度。

  • 若 ext_bbox 寬高比為1:1,則產生512×512的頭像視頻;若為3:4,則產生512×704的半身像視頻。

  • 映像要求最小邊長 ≥ 400像素,最大邊長 ≤ 7000像素。

  • 格式支援:jpg,jpeg,png,bmp,webp。

  • 樣本值:https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250911/yhdvfg/emo.png。

  • 上傳檔案支援HTTP或HTTPS連結方式,不支援本地連結方式。

audio_url string (必選)

使用者上傳的音頻檔案 URL, 用於EMO模型推理的輸入。

  • 需包含清晰人聲,並儘可能去除環境噪音、背景音樂等幹擾。

  • 檔案大小 ≤ 15 MB,時間長度 ≤ 60 s。

  • 格式支援:wav、mp3。

  • 樣本值:https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250825/aejgyj/input_audio.mp3。

  • 上傳檔案支援HTTP或HTTPS連結方式,不支援本地連結方式。

face_bbox array (必選)

圖片中人臉地區bbox的像素座標,應輸入EMO映像檢測API出參中同名欄位的值。座標格式[x1,y1,x2,y2],分別對應左上和右下兩個點的座標。樣本值:[302,286,610,593]。

映像左上方為座標原點(0,0),x軸向右為正,y軸向下為正。

ext_bbox array (必選)

圖片中動態地區bbox的像素座標,應輸入EMO映像檢測API出參中同名欄位的值。該地區的寬高比為1:1或3:4。座標格式[x1,y1,x2,y2],分別對應左上和右下兩個點的座標。樣本值:[71,9,840,778]。

parameters object(可選)

屬性

style_level string (可選)預設值:normal

可選擇動作風格強度控制人物的運動姿態和幅度,當前支援3種:normal、calm、active,分別對應人物動作風格適中、平靜、活潑。預設為normal。

響應參數

響應成功樣本

{
    "output": {
        "task_id": "a8532587-fa8c-4ef8-82be-xxxxxx", 
        "task_status": "PENDING"
    },
    "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51"
}

響應異常樣本

{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

output object

任務輸出資訊。

屬性

task_id string

提交非同步任務的任務ID,實際任務結果需要通過非同步任務查詢介面擷取。樣本值:a8532587-fa8c-4ef8-82be-xxxxxx。

task_status string

提交非同步任務後的任務狀態。樣本值:“PENDING”。

request_id string

請求唯一標識。可用於請求明細溯源和問題排查。

code string

請求失敗時返回的錯誤碼,詳情請參見狀態代碼說明

message string

請求失敗時返回的詳細錯誤資訊,詳情請參見狀態代碼說明

步驟2:根據任務ID查詢結果

使用上一步擷取的 task_id,輪詢任務狀態和結果。請將 URL 中的{task_id} 替換為您的實際任務ID。

GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
說明
  • task_id 有效期間:自建立起有效期間24小時,逾時後將無法查詢結果,介面將返回任務狀態為UNKNOWN

  • 任務狀態流轉:一般正常處理的任務流轉狀態為 PENDING(排隊中)→ RUNNING(處理中)→ SUCCEEDED(成功)/ FAILED(失敗)。

  • 任務結果擷取:視頻產生過程約需數分鐘,查詢介面預設QPS為20。建議採用輪詢機制,並設定合理的查詢間隔(如 15 秒)來擷取結果。

  • video_url 有效期間:自任務成功時刻起有效期間為 24 小時。建議在擷取連結後立即下載並轉存至永久儲存(如阿里雲 OSS)。

請求參數

curl -X GET \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
import requests
import os

# 1. 從環境變數擷取 API Key
api_key = os.getenv("DASHSCOPE_API_KEY")

# 2. 請替換為您真實需要查詢的任務 ID
task_id = "a8532587-fa8c-4ef8-82be-xxxxxx"

# 3. 準備請求資訊
# 使用 f-string 將 task_id 拼接到 URL 中
url = f"https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}"

headers = {
    'Authorization': f'Bearer {api_key}'
}

# 4. 發送 GET 請求
response = requests.get(url, headers=headers)

# 5. 列印伺服器返回的 JSON 響應
# 這將顯示任務的狀態(如 "RUNNING", "SUCCEEDED", "FAILED")和結果
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;
/**
 * 要求:
 * - Java 8 或更高版本。
 * - 運行時需要設定環境變數 DASHSCOPE_API_KEY。
 **/
public class TaskStatusChecker {

    public static void main(String[] args) throws IOException {
        // 1. 從環境變數擷取 API Key
        String apiKey = System.getenv("DASHSCOPE_API_KEY");
        // 2. 請替換為您真實需要查詢的任務 ID
        String taskId = "a8532587-fa8c-4ef8-82be-xxxxxx"; // 替換為你的任務ID
        // 3. 準備請求資訊 (動態拼接 URL)
        String urlString = "https://dashscope.aliyuncs.com/api/v1/tasks/" + taskId;
        // 4. 建立串連並發送 GET 請求
        URL url = new URL(urlString);
        // noinspection StartSSRFNetHookCheckingInspection
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        // 佈建要求頭
        connection.setRequestProperty("Authorization", "Bearer " + apiKey);
        // 5. 擷取並列印伺服器響應
        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();
    }
}
// 需要安裝node-fetch包
// npm install node-fetch@2

// 匯入 node-fetch 庫
const fetch = require('node-fetch');
// 1. 從環境變數擷取 API Key
const apiKey = process.env.DASHSCOPE_API_KEY;
// 2. 請替換為您真實需要查詢的任務 ID
const taskId = "a8532587-fa8c-4ef8-82be-xxxxxx"; // <-- 在這裡替換您的任務 ID
// 3. 準備請求資訊
// 使用模板字串將 taskId 拼接到 URL 中,這等同於 Python 的 f-string
const url = `https://dashscope.aliyuncs.com/api/v1/tasks/${taskId}`;

const headers = {
    'Authorization': `Bearer ${apiKey}`
};

// 4. 發送 GET 請求
// fetch 預設的要求方法就是 GET,所以可以省略 method: 'GET'
fetch(url, {
    headers: headers
})
.then(response => response.json()) // 將響應體解析為 JSON
.then(data => {
    // 5. 列印伺服器返回的 JSON 響應
    // 這將顯示任務的狀態(如 "RUNNING", "SUCCEEDED")和結果
    console.log(data);
});

要求標頭(Headers)

Authorization string(必選)

請求身份認證。介面使用阿里雲百鍊API Key進行身份認證。樣本值:Bearer sk-xxxx。

URL路徑參數(Path parameters)

task_id string (必選)

需要查詢任務的task_id。樣本值:a8532587-fa8c-4ef8-82be-xxxxxx。

響應參數

響應成功樣本

{
    "request_id": "8190395f-ca1b-4703-9656-xxxxxx",
    "output": {
        "task_id": "a8532587-fa8c-4ef8-82be-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-09-11 14:33:38.716",
        "scheduled_time": "2025-09-11 14:33:53.089",
        "end_time": "2025-09-11 14:35:51.541",
        "results": {
            "video_url": "http://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxxx"
        }
    },
    "usage": {
        "video_duration": 13.93,
        "video_ratio": "1:1"
    }
}

響應異常樣本

{
    "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_id string

請求唯一標識。可用於請求明細溯源和問題排查。

output object

任務輸出資訊。

屬性

task_id string

查詢任務的 task_id。樣本值:a8532587-fa8c-4ef8-82be-xxxxxx。

task_status string

任務狀態。

枚舉值

  • PENDING:任務排隊中

  • RUNNING:任務處理中

  • SUCCEEDED:任務執行成功

  • FAILED:任務執行失敗

  • CANCELED:任務已取消

  • UNKNOWN:任務不存在或狀態未知

submit_time string

任務提交時間,時區為UTC+8,樣本值:2025-09-11 14:33:38.716。

scheduled_time string

任務被安排計劃開始執行的時間,時區為UTC+8,樣本值:2025-09-11 14:33:53.089。

end_time string

任務執行結束時間,時區為UTC+8,樣本值:2025-09-11 14:35:51.541。

results object

任務執行結果。

屬性

video_url string

平台輸出的視頻結果,video_url有效期間為任務完成後24小時,請及時下載並儲存視頻檔案。樣本值:http://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.mp4?Expires=xxxx。

code string

請求失敗時返回的錯誤碼,詳情請參見狀態代碼說明

message string

請求失敗時返回的詳細錯誤資訊,詳情請參見狀態代碼說明

usage object

屬性

video_duration float

本次請求產生視頻時間長度,單位:秒,樣本值:13.93。

video_ratio string

本次請求產生視頻的畫幅比例,該值為1:1或3:4。

計費與限流

模型名稱

單價

任務下發介面QPS限制

同時處理中任務數量

emo-v1

後付費,按照輸出視頻的實際時間長度計費:

  • 產生1:1畫幅比例視頻:$0.011469/秒

  • 產生3:4畫幅比例視頻:$0.022937/秒

5

1

(超出任務將排隊)

狀態代碼說明

大模型服務平台通用狀態代碼請查閱:錯誤資訊