Midjourney 换脸 API 文档
接口地址
https://www.dmxapi.cn/mj/insight-face/swap
参数说明
参数名称 | 参数含义 | 是否必选 | 参数类型 | 备注 |
---|---|---|---|---|
mode | 调用模式,默认 RELAX | 否 | string | RELAX: 慢速模式, FAST: 快速模式 |
notifyhook | 回调地址,为空时不进行回调通知 | 否 | string | |
sourceBase64 | 人脸源图片 base64 | 是 | string | 示例值(data:image/png;base64,xxx1) |
targetBase64 | 目标图片 base64 | 是 | string | 示例值(data:image/png;base64,xxx2) |
state | 自定义参数 | 否 | string |
示例代码
python
import json
import requests
url = "https://www.dmxapi.cn/mj/insight-face/swap"
API_KEY = "sk-********************************" #更换成你的 DMXAPI 令牌
payload = json.dumps(
{
"sourceBase64": "data:image/png;base64,xxx1",
"targetBase64": "data:image/png;base64,xxx2",
"notifyHook": "string",
"state": "string",
}
)
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
返回示例
json
{
"code": 1,
"description": "提交成功",
"result": 1756141991905216 # 去第二步任务查询API,获得结果
}