文档
模特图生成请求接口

提交模特图任务

1. 接口地址

https://hidreamai.com/api-pub/ec/v3/image/model/async

2. 请求方式

POST

3. 请求参数

Header

参数类型是否必填说明
Authorizationstring客户授权Token
Content-Typestring使用json传参

Body

参数类型是否必填说明
imagestring模特图片,支持图片url和图片base64两种格式数据。base64数据需去除base64数据需去除·data:image/*;base64,·格式前缀, 最大分辨率支持4K
maskstring自定义处理图片mask, 参考模特图智能抠图接口
templatedict使用模版生图,与prompt 方式生图二选一
promptstring使用prompt模式生图,prompt字符串长度最大500
image_countint生图数量,默认1,取值范围le=4, ge=1
notify_urlstring任务完成回调通知接口(需公网能访问),请求参数与task result 一致

其中template字段详细参数为

参数类型是否必填说明
human_template_idstring模版类型模版ID
custom_human_templatebool是否为自定义模版,默认为False, 后续版本将支持True
scene_template_idstring模特场景模版ID

curl示例

curl -H 'Authorization: Bearer {USER_Authorization}' -H 'Content-Type: application/json' -X POST -d '{
    "image": "https://img0.baidu.com/it/u=3162963441,624224718&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=800",
    "prompt": "一位中年男性,黑色短发,逼真的眼睛细节,自然的皮肤纹理,锐利的眼神,商务西装,走在背景是高楼大厦的室外",
}' -v 'https://hidreamai.com/api-pub/ec/v3/image/vton/async'

Python示例

import requests
 
USER_Authorization = <token>
 
 
# 请求头
headers = {
    'Authorization': f'Bearer {USER_Authorization}',
    'Content-Type': 'application/json',
}
 
# 请求体参数
data = {
    "image": "https://img0.baidu.com/it/u=3162963441,624224718&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=800",
    "template": {
        "human_template_id": "xxx",
        "scene_template_id": "xx"
    }
}
 
# 发送POST请求
url = 'https://hidreamai.com/api-pub/ec/v3/image/model/async'
response = requests.post(url, headers=headers, json=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. 返回参数

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

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

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

示例:

{
    "code": 0,
    "message": "请求成功",
    "request_id": "96cf0c6a-5d2b-11ee-abe3-3a8d18c35977",
    "result": {
        "sub_task_ids": [
            "94ecd4e4-7d90-4daa-8edb-f3ee02fafa19"
        ],
        "task_id": "97004e6a-5d2b-11ee-abe3-3a8d18c35963"
    }
}