Faceswap V3 Multifaceswap Serverless API

Faceswap V3 Multifaceswap enables realistic face swapping in images, preserving lighting and expressions for professional results.

~6.59s
~$0.008
 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

POSThttps://api.segmind.com/v1/faceswap-v3-multifaceswap

Parameters

source_imgrequired
string (uri)

URL for your face image. Use high-resolution close-up shots for best results.

Default: "https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg"
target_imgrequired
string (uri)

URL of face to swap with. Choose a well-lit image for clarity.

Default: "https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg"
base64optional
boolean

Toggle base64 encoding of output. 'False' for direct download, enable for embedding.

Default: false
detect_gender_inputoptional
string

Detect gender of target face. 'No' by default, specify 'female' or 'male'.

Default: "no"
Allowed values :
"no""female""male"
detect_gender_sourceoptional
string

Detect gender of input face. Use 'no' or specify 'female'/'male'.

Default: "no"
Allowed values :
"no""female""male"
detection_face_orderoptional
string

Face detection order. Use 'large-small' for prominence, 'top-bottom' for order.

Default: "large-small"
Allowed values :
"large-small""small-large""top-bottom""bottom-top""left-right""right-left"
face_restoreoptional
string

Select face restore model. use 'disable' while swapping multiple faces at once

Default: "disable"
Allowed values :
"disable""codeformer-v0.1.0.pth""GFPGANv1.4.pth""GFPGANv1.3.pth"
face_restore_weightoptional
number

Adjust face restore weight. '0.75' for balance, higher for smoothness.

Default: 0.75Range: 0 - 1
facedetectionoptional
string

Select face detection model. 'Retinaface_resnet50' for accuracy, 'YOLOv5n' for speed.

Default: "retinaface_resnet50"
Allowed values :
"retinaface_resnet50""retinaface_mobile0.25""YOLOv5l""YOLOv5n"
image_formatoptional
string

Choose output image format. 'JPEG' for most use, 'PNG' for transparency.

Default: "jpeg"
Allowed values :
"jpeg""png""webp"
image_qualityoptional
integer

Set output image quality. '95' for high detail, reduce to save space.

Default: 95Range: 10 - 100
input_faces_indexoptional
string

Select index of detected input face. Use '0' for default, '0,1,2' for multiple.

Default: "0"
interpolationoptional
string

Choose interpolation method. 'Bilinear' for most scenarios, 'Lanczos' for detailed.

Default: "Bilinear"
Allowed values :
"Nearest""Bilinear""Bicubic""Lanczos"
source_faces_indexoptional
string

Select index of source face. '0' for first, '0,1' for multiple selections.

Default: "0"

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out