文档
文生视频结果接口

获取文生视频结果

1. 接口地址

https://www.hidreamai.com/api-pub/gw/v3/video/txt2video/async/results

 

2. 请求方式

GET

 

3. 请求参数

Header

参数类型是否必填说明
Authorizationstring客户授权Token

Query Params

参数类型是否必填说明
task_idstring提交任务时返回的任务task_id
request_idstring请求的ID,默认为""

curl示例

curl -H 'Authorization: Bearer {USER_Authorization}' -X GET 
-v 'https://www.hidreamai.com/api-pub/gw/v3/video/txt2video/async/results?task_id=97004e6a-5d2b-11ee-abe3-3a8d18c35977&request_id=425d6094-3a73-11ee-85e2-0a4fb61b1c34'

Python示例

import requests
 
USER_Authorization = <token>
task_id = "6fd16a7c-d6b1-11ee-af0a-52cbc25497eb"  # <task_id>
 
# 请求头
headers = {
    'Authorization': f'Bearer {USER_Authorization}'
}
 
# 请求参数
params = {
    'task_id': task_id,
    'request_id': ''
}
 
# 发送GET请求
url = 'https://www.hidreamai.com/api-pub/gw/v3/video/txt2video/async/results'
response = requests.get(url, headers=headers, params=params)
 
# 处理响应
if response.status_code == 200:
    if response.json()['code'] == 0:
        results = response.json()['result']['sub_task_results']
        for result in results:
            print(f"task_status: {result['task_status']}, task_completion: {result['task_completion']}, video_url: {result['video']}")
    else:
        print(response.json()['message'])
else:
    print(response.status_code)
 

 

4. 返回参数

参数类型说明
codeint返回状态码
messagestring返回状态信息
request_idstring本次请求的ID
resultdict返回结果

其中返回结果 result字段具体为:

参数类型说明
task_idstring任务的task_id
sub_task_resultslist各个子任务的生成结果

其中sub_task_result字段具体为

参数类型说明
sub_task_idstring子任务的task_id
task_statusint子任务的状态,0: 等待中,1: 完成,2: 处理中,3: 失败,4:未通过审核
task_completionfloat子任务的进度,取值范围为0-1的小数点后保留2位的小数
videostring生成的视频的url, eg.'https://media.hidreamai.com/63c3bc8f-4990-41eb-8c3d-46247735e9b6.mp4 (opens in a new tab)'

示例:

{
    "code": 0,
    "message": "Success",
    "request_id": "425d6094-3a73-11ee-85e2-0a4fb61b1c34",
    "result": {
        "sub_task_results": [
            {
                "video": "https://media.hidreamai.com/63c3bc8f-4990-41eb-8c3d-46247735e9b6.mp4",
                "sub_task_id": "94ecd4e4-7d90-4daa-8edb-f3ee02fafa19",
                "task_completion": 1,
                "task_status": 1
            }
        ],
        "task_id": "97004e6a-5d2b-11ee-abe3-3a8d18c35977"
    }
}