任务:换脸(swap_face)
概览
- 接口:
POST /mj/insight-face/swap - 说明:提交两张图片(源人脸与目标图片)进行人脸融合/换脸处理。
- 内容类型:
application/json
认证
- 使用 HTTP Bearer Token,示例:
Authorization: Bearer sk-xxxxx
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| sourceBase64 | string | 是 | 源人脸图片(base64 编码) |
| targetBase64 | string | 是 | 目标图片(base64 编码) |
| accountFilter | object | 否 | 账号过滤信息,例如 instanceId(可选) |
| notifyHook | string | 否 | 回调地址;为空时使用全局 notifyHook |
| state | string | 否 | 自定义参数,透传回调或任务状态 |
默认字段顺序:sourceBase64, targetBase64, accountFilter, notifyHook, state。
请求示例
json
{
"sourceBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgA...",
"targetBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgA...",
"accountFilter": { "instanceId": "instance-123" },
"notifyHook": "https://example.com/callback",
"state": "swap-001"
}curl
bash
curl -X POST "https://api.gpt.ge/mj/insight-face/swap" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{"sourceBase64":"data:image/jpeg;base64,/9j/4AAQSkZJRgA...","targetBase64":"data:image/jpeg;base64,/9j/4AAQSkZJRgA...","accountFilter":{"instanceId":"instance-123"},"notifyHook":"https://example.com/callback","state":"swap-001"}'JavaScript (fetch)
javascript
fetch('https://api.gpt.ge/mj/insight-face/swap', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx' },
body: JSON.stringify({ sourceBase64: 'data:image/jpeg;base64,/9j/4AAQSkZJRgA...', targetBase64: 'data:image/jpeg;base64,/9j/4AAQSkZJRgA...', accountFilter: { instanceId: 'instance-123' }, notifyHook: 'https://example.com/callback', state: 'swap-001' })
}).then(r => r.json()).then(console.log)Python (requests)
python
import requests
payload = {
'sourceBase64': 'data:image/jpeg;base64,/9j/4AAQSkZJRgA...',
'targetBase64': 'data:image/jpeg;base64,/9j/4AAQSkZJRgA...',
'accountFilter': { 'instanceId': 'instance-123' },
'notifyHook': 'https://example.com/callback',
'state': 'swap-001'
}
resp = requests.post('https://api.gpt.ge/mj/insight-face/swap', headers={'Content-Type':'application/json','Authorization':'Bearer sk-xxxx'}, json=payload)
print(resp.json())返回示例(200)
json
{
"code": 1,
"description": "success",
"properties": null,
"result": "1725015179182153"
}