Segmind Faceswap v4
Segmind FaceSwap v4 enables fast and precise face or head swapping between images with customizable options for style, output format, and image quality. Designed for creators and designers, it ensures natural-looking results with reproducibility through seed control for consistent outputs.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v4"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_image": "https://segmind-resources.s3.amazonaws.com/input/b872c581-a20a-4fda-98aa-b78d2e221ccb-v4-source-img.jpg",
12 "target_image": "https://segmind-resources.s3.amazonaws.com/output/7401f2ea-5652-4f2a-93d9-a587f1ccb62f-fs-v4-target.png",
13 "model_type": "speed",
14 "swap_type": "head",
15 "style_type": "normal",
16 "seed": 4208875,
17 "image_format": "png",
18 "image_quality": 90,
19 "hardware": "fast",
20 "base64": false
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/faceswap-v4"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "source_image": "https://segmind-resources.s3.amazonaws.com/input/b872c581-a20a-4fda-98aa-b78d2e221ccb-v4-source-img.jpg",
12 "target_image": "https://segmind-resources.s3.amazonaws.com/output/7401f2ea-5652-4f2a-93d9-a587f1ccb62f-fs-v4-target.png",
13 "model_type": "speed",
14 "swap_type": "head",
15 "style_type": "normal",
16 "seed": 4208875,
17 "image_format": "png",
18 "image_quality": 90,
19 "hardware": "fast",
20 "base64": false
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26 result = response.json()
27 print(json.dumps(result, indent=2))
28else:
29 print(f"Error: {response.status_code}")
30 print(response.text)API Endpoint
https://api.segmind.com/v1/faceswap-v4Parameters
source_imagerequiredstring (uri)The image URL of the source image
target_imagerequiredstring (uri)The image on which the face swap will be applied, url
base64optionalbooleanOutput as base64
falsehardwareoptionalstringThe hardware to use. Does not affect quality, only latency and cost
"fast""fast""cost"image_formatoptionalstringThe output image format
"png""jpeg""png""webp"image_qualityoptionalintegerThe quality of the output image
90Range: 10 - 100model_typeoptionalstringThe inference steps to use for face swapping. Speed = 8 steps, quality = 30 steps
"speed""speed""quality"seedoptionalintegerRandom seed for reproducibility
42style_typeoptionalstringThe style to apply during face swapping. normal: source style, style: match style of target image
"normal""normal""style"swap_typeoptionalstringDetermines whether to swap the entire head or just the face
"head""head""face"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