换脸(FaceSwap)接口
POST v1/mj/insight-face/swap提交FaceSwap任务,进行换脸操作。
请求参数
Authorization
在 Header 添加参数 Authorization,其值为在 Bearer 之后拼接 Token。
Authorization: Bearer ******************Body 参数
Content-Type: application/json
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | string | 必需 | 运行模式或生成模式。 |
| sourceBase64 | string | 必需 | 原图 |
| targetBase64 | string | 必需 | 目标图片 |
| prompt | string | 必需 | 提示词,用于指导生成的内容。 |
| base64Array | array[string] | 可选 | 垫图 Base64 数组。通常用于图生图(Image-to-Image)任务,提供一张或多张图片的 Base64 编码。 |
| accountFilter | object | 可选 | 账号筛选条件。用于指定由哪个或哪类账号来执行此任务。 |
| └─ channelId | string | 可选 | 渠道 ID。 |
| └─ instanceId | string | 可选 | 账号实例 ID。 |
| └─ modes | array[string] | 可选 | 账号模式列表。 |
| └─ remark | string | 可选 | 备注信息。 |
| └─ remix | boolean | 可选 | 账号是否开启 Remix 模式。 |
| └─ remixAutoConsidered | boolean | 可选 | 逻辑说明:在账号过滤时,如果设置了此选项,"Remix 自动提交" 将被视为账号的 remix 属性为 false。 |
| notifyHook | string | 可选 | 回调地址。如果为空,则使用系统配置的全局 notifyHook。 |
| state | string | 可选 | 自定义参数,通常用于在回调时透传数据,保持请求与回调的上下文关联。 |
请求示例 (JSON)
{
"mode": "RELAX",
"sourceBase64": "data:image/png;base64,xxx1",
"targetBase64": "data:image/png;base64,xxx2"
}返回响应
200 成功
Content-Type: application/json
响应参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| code | integer | 必需 | 状态码。用于标识请求的处理结果 |
| description | string | 必需 | 描述信息。对状态码的文字说明或具体的错误提示 |
| result | integer | 必需 | 结果标识。可能用于表示操作影响的行数、特定的结果状态或分页总数等数值型结果。 |
响应示例
{
"code": 0,
"description": "string",
"result": "string"
}示例代码
python
import http.client
import json
conn = http.client.HTTPSConnection("nxaiapp.com")
payload = json.dumps({
"mode": "RELAX",
"sourceBase64": "data:image/png;base64,xxx1",
"targetBase64": "data:image/png;base64,xxx2"
})
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/mj/insight-face/swap", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))