Faceswap V3 Multifaceswap Serverless API
Faceswap V3 Multifaceswap enables realistic face swapping in images, preserving lighting and expressions for professional results.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v3-multifaceswap"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg",
12 "target_img": "https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg",
13 "input_faces_index": "0,1,2",
14 "source_faces_index": "0,1,2",
15 "face_restore": "disable",
16 "interpolation": "Bilinear",
17 "detection_face_order": "left-right",
18 "facedetection": "retinaface_resnet50",
19 "detect_gender_input": "no",
20 "detect_gender_source": "no",
21 "face_restore_weight": 0.75,
22 "image_format": "jpeg",
23 "image_quality": 95,
24 "base64": false
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v3-multifaceswap"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_img": "https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg",
12 "target_img": "https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg",
13 "input_faces_index": "0,1,2",
14 "source_faces_index": "0,1,2",
15 "face_restore": "disable",
16 "interpolation": "Bilinear",
17 "detection_face_order": "left-right",
18 "facedetection": "retinaface_resnet50",
19 "detect_gender_input": "no",
20 "detect_gender_source": "no",
21 "face_restore_weight": 0.75,
22 "image_format": "jpeg",
23 "image_quality": 95,
24 "base64": false
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text)API Endpoint
https://api.segmind.com/v1/faceswap-v3-multifaceswapParameters
source_imgrequiredstring (uri)URL for your face image. Use high-resolution close-up shots for best results.
"https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg"target_imgrequiredstring (uri)URL of face to swap with. Choose a well-lit image for clarity.
"https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg"base64optionalbooleanToggle base64 encoding of output. 'False' for direct download, enable for embedding.
falsedetect_gender_inputoptionalstringDetect gender of target face. 'No' by default, specify 'female' or 'male'.
"no""no""female""male"detect_gender_sourceoptionalstringDetect gender of input face. Use 'no' or specify 'female'/'male'.
"no""no""female""male"detection_face_orderoptionalstringFace detection order. Use 'large-small' for prominence, 'top-bottom' for order.
"large-small""large-small""small-large""top-bottom""bottom-top""left-right""right-left"face_restoreoptionalstringSelect face restore model. use 'disable' while swapping multiple faces at once
"disable""disable""codeformer-v0.1.0.pth""GFPGANv1.4.pth""GFPGANv1.3.pth"face_restore_weightoptionalnumberAdjust face restore weight. '0.75' for balance, higher for smoothness.
0.75Range: 0 - 1facedetectionoptionalstringSelect face detection model. 'Retinaface_resnet50' for accuracy, 'YOLOv5n' for speed.
"retinaface_resnet50""retinaface_resnet50""retinaface_mobile0.25""YOLOv5l""YOLOv5n"image_formatoptionalstringChoose output image format. 'JPEG' for most use, 'PNG' for transparency.
"jpeg""jpeg""png""webp"image_qualityoptionalintegerSet output image quality. '95' for high detail, reduce to save space.
95Range: 10 - 100input_faces_indexoptionalstringSelect index of detected input face. Use '0' for default, '0,1,2' for multiple.
"0"interpolationoptionalstringChoose interpolation method. 'Bilinear' for most scenarios, 'Lanczos' for detailed.
"Bilinear""Nearest""Bilinear""Bicubic""Lanczos"source_faces_indexoptionalstringSelect index of source face. '0' for first, '0,1' for multiple selections.
"0"Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out