请先获取 API Key 并设置为环境变量。
鉴权
string
header
必填
千问云 API Key。详见获取 API Key。
Header 参数
enum<string>
必填
固定设置为 enable,表示使用异步方式提交任务。
enable
提交FaceChain人物写真生成任务
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/album/gen_potrait' \
--header 'X-DashScope-Async: enable' \
--header 'Authorization: Bearer $DASHSCOPE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "facechain-generation",
"parameters": {
"style": "f_idcard_female",
"size": "768*1024",
"n": 4
},
"resources": [
{
"resource_id": "women_model",
"resource_type": "facelora"
}
]
}'{
"request_id": "0b6a411a-56e6-9028-84eb-6852183248d8",
"output": {
"task_id": "7eb1032e-09a1-4df5-96ed-14091859ad57",
"task_status": "PENDING"
}
}千问云 API Key。详见获取 API Key。
固定设置为 enable,表示使用异步方式提交任务。
模型名称。此处固定为 facechain-generation。
生成参数。
显示子属性
输出图像的预设风格或自定义模板模式。
预设风格(需要 LoRA 资源):
f_idcard_male — 证件照男f_business_male — 商务写真男f_idcard_female — 证件照女f_business_female — 商务写真女m_springflower_female — 春日花园f_summersport_female — 夏日运动f_autumnleaf_female — 秋日印象m_winterchinese_female — 冬日国风f_hongkongvintage_female — 港风复古f_lightportray_female — 轻写真自定义模板模式:
portrait_url_template — 自定义模板 + LoRA(需传入 input.template_url 和 LoRA 资源)train_free_portrait_url_template — 自定义模板免训练(需传入 input.template_url 和 input.user_urls,无需 LoRA 资源)生成图像的分辨率。目前支持 768*1024。使用自定义模板模式或免训练模式时不需要该参数。
生成图片数量。取值范围 1~4,默认值为 4。
免训练写真生成时是否对输入用户图进行自动美颜处理。默认为 true(自动美颜),可设置为 false(不美颜,用户可自行前后处理)。
自定义模板模式下的输入数据。
显示子属性
用户自定义模板的 URL 链接。当 parameters.style 为 portrait_url_template 或 train_free_portrait_url_template 时为必填。
一组包含用户正脸单人照的 URL 链接。当 parameters.style 为 train_free_portrait_url_template 时为必填。至少 1 张,最多 5 张,需通过人物图像检测 API(facechain-facedetect)验证通过。
[
"https://example.com/face.jpg"
]curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/album/gen_potrait' \
--header 'X-DashScope-Async: enable' \
--header 'Authorization: Bearer $DASHSCOPE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "facechain-generation",
"parameters": {
"style": "f_idcard_female",
"size": "768*1024",
"n": 4
},
"resources": [
{
"resource_id": "women_model",
"resource_type": "facelora"
}
]
}'{
"request_id": "0b6a411a-56e6-9028-84eb-6852183248d8",
"output": {
"task_id": "7eb1032e-09a1-4df5-96ed-14091859ad57",
"task_status": "PENDING"
}
}