Faceswap V3 Multifaceswap Serverless API

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

POST /v2/faceswap-v3-multifaceswap · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "faceswap-v3-multifaceswap",
 9    source_img="https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg",
10    target_img="https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg",
11    input_faces_index="0,1,2",
12    source_faces_index="0,1,2",
13    face_restore="disable",
14    interpolation="Bilinear",
15    detection_face_order="left-right",
16    facedetection="retinaface_resnet50",
17    detect_gender_input="no",
18    detect_gender_source="no",
19    face_restore_weight=0.75,
20    image_format="jpeg",
21    image_quality=95,
22    base64=False,
23)
24print(result["status"])                      # COMPLETED
25print(result.get("output"))                  # model output (e.g. media URL)
26print(result["metrics"]["inference_time"])   # server compute seconds
27
28# --- Or submit + poll manually (track request_id, control the cadence) ---
29from segmind import SegmindClient, InferenceFailed, InferenceTimeout
30
31client = SegmindClient()                      # reads SEGMIND_API_KEY
32payload = {
33    "source_img": "https://segmind-resources.s3.amazonaws.com/output/8ba04e7c-1041-4009-85be-76c8874e1d30-faceswap-v3-multifaceswap-input.jpg",
34    "target_img": "https://segmind-resources.s3.amazonaws.com/output/3b87e9fb-1d51-42ad-ae1e-1ddbcbd6f0d0-front-view-smiley-young-friends-hugging_23-2148342123.jpg",
35    "input_faces_index": "0,1,2",
36    "source_faces_index": "0,1,2",
37    "face_restore": "disable",
38    "interpolation": "Bilinear",
39    "detection_face_order": "left-right",
40    "facedetection": "retinaface_resnet50",
41    "detect_gender_input": "no",
42    "detect_gender_source": "no",
43    "face_restore_weight": 0.75,
44    "image_format": "jpeg",
45    "image_quality": 95,
46    "base64": False,
47}
48job = client.submit_async("faceswap-v3-multifaceswap", **payload)
49print(job.request_id)                         # available immediately
50try:
51    result = job.wait(timeout=600, interval=1.0)
52except InferenceTimeout as e:
53    print("still running:", e.request_id)
54except InferenceFailed as e:
55    print("failed:", e.detail)

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

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/faceswap-v3-multifaceswap

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

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