Skip to content

Midjourney 换脸 API 文档

接口地址

https://www.dmxapi.cn/mj/insight-face/swap

参数说明

参数名称参数含义是否必选参数类型备注
mode调用模式,默认 RELAXstringRELAX: 慢速模式, FAST: 快速模式
notifyhook回调地址,为空时不进行回调通知string
sourceBase64人脸源图片 base64string示例值(data:image/png;base64,xxx1)
targetBase64目标图片 base64string示例值(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,获得结果
}

一个 Key 用全球大模型