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.

~32.22s
$0.0015 - $0.0072 per generation
 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

POSThttps://api.segmind.com/v1/faceswap-v4

Parameters

source_imagerequired
string (uri)

The image URL of the source image

target_imagerequired
string (uri)

The image on which the face swap will be applied, url

base64optional
boolean

Output as base64

Default: false
hardwareoptional
string

The hardware to use. Does not affect quality, only latency and cost

Default: "fast"
Allowed values :
"fast""cost"
image_formatoptional
string

The output image format

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

The quality of the output image

Default: 90Range: 10 - 100
model_typeoptional
string

The inference steps to use for face swapping. Speed = 8 steps, quality = 30 steps

Default: "speed"
Allowed values :
"speed""quality"
seedoptional
integer

Random seed for reproducibility

Default: 42
style_typeoptional
string

The style to apply during face swapping. normal: source style, style: match style of target image

Default: "normal"
Allowed values :
"normal""style"
swap_typeoptional
string

Determines whether to swap the entire head or just the face

Default: "head"
Allowed values :
"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.

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