提交风格化任务

1. 接口地址

https://www.hidreamai.com/api-pub/gw/v2/video/video_edit/async

 

2. 请求方式

POST

 

3. 请求参数

Header

参数 类型 是否必填 说明
Authorization string 客户授权Token
Content-Type string 使用json传参
API-User-ID string 用户唯一标识

Body

参数 类型 是否必填 说明
prompt/style string prompt和style选填一项,表示生成视频的描述(风格)
video_name string 视频的base64编码或者URL
request_id string 请求的ID,默认为""
notify_url string 任务完成回调通知接口(需公网能访问),请求体包含main_task_id(任务的task_id)、sub_task_results

其中,style目前支持

style 对应中文
barbie_doll 芭比
ink_wash 水墨
van_goph 梵高
hayao_miyazaki 宫崎骏
cyber_punk 赛博朋克
cartoon 卡通
anime 动漫
vector_art 矢量艺术
abstract 抽象
watercolor 水彩

curl示例

curl -H 'Authorization: Bearer {USER_Authorization}' -H 'Content-Type: application/json' -X POST -d '{
    "prompt": "a pig is eating",
    "video_name": video_base64/video_url,
    "style": "ink_wash",
    "request_id": "b146d886-5c57-11ee-bf2b-f6f8d60dadec",
    "notify_url": "https://{replace me}/api/callback"
}' -v 'https://www.hidreamai.com/api-pub/gw/v2/video/video_edit/async'

Python示例

import requests
import json
import uuid

USER_Authorization = <token>  # 获取方式详见接口文档https://www.hidreamai.com/docs/pixeling/user/token.html


# 请求头
headers = {
    'Authorization': f'Bearer {USER_Authorization}',
    'Content-Type': 'application/json',
    'API-User-ID': ''  # 可选的用户唯一标识
}

# 请求体参数
data = {
    "style": "ink_wash",  # 必要参数
    "video_name": "https://media.hidreamai.com/42c6c363-c20e-47a5-aa92-18c17c798793.mp4",  # 必要参数
    "request_id": str(uuid.uuid4())
}

# 发送POST请求
url = 'https://www.hidreamai.com/api-pub/gw/v2/video/video_edit/async'
response = requests.post(url, headers=headers, data=json.dumps(data))

# 处理响应
if response.status_code == 200:
    if response.json()['code'] == 0:
        task_id = response.json()['result']['task_id']
        print(task_id)
    else:
        print(response.json()['message'])
else:
    print(response.status_code)

 

4. 返回参数

参数 类型 说明
code int 返回状态码
message string 返回状态信息
request_id string 本次请求的ID
result dict 返回结果

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

参数 类型 说明
task_id string 返回任务ID
sub_task_ids list 返回子任务ID的列表,子任务定义为生成单张图片的任务

示例:

{
    "code": 0,
    "message": "请求成功",
    "request_id": "b146d886-5c57-11ee-bf2b-f6f8d60dadec",
    "result": {
        "sub_task_ids": [
            "d832ac2b-4591-4fc3-8995-adf81a87ce53"
        ],
        "task_id": "b1781982-5c57-11ee-bf2b-f6f8d60dadec"
    }
}

results matching ""

    No results matching ""

    results matching ""

      No results matching ""