Faceswap
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training
~36.89s
~$0.023
1import requests
2import json
3
4url = "https://api.segmind.com/v1/sd2.1-faceswapper"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "input_face_image": "https://www.segmind.com/elon.jpg",
12 "target_face_image": "https://www.segmind.com/burn.gif",
13 "file_type": "gif",
14 "face_restore": true
15}
16
17response = requests.post(url, headers=headers, json=data)
18
19if response.status_code == 200:
20 result = response.json()
21 print(json.dumps(result, indent=2))
22else:
23 print(f"Error: {response.status_code}")
24 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/sd2.1-faceswapper"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "input_face_image": "https://www.segmind.com/elon.jpg",
12 "target_face_image": "https://www.segmind.com/burn.gif",
13 "file_type": "gif",
14 "face_restore": true
15}
16
17response = requests.post(url, headers=headers, json=data)
18
19if response.status_code == 200:
20 result = response.json()
21 print(json.dumps(result, indent=2))
22else:
23 print(f"Error: {response.status_code}")
24 print(response.text)API Endpoint
POST
https://api.segmind.com/v1/sd2.1-faceswapperParameters
input_face_imagerequiredstring (uri)Your face goes here. A closeup shot would be ideal.
target_face_imagerequiredstring (uri)The face you want to swap with. Can be a gif too.
face_restoreoptionalbooleanRun result frames through codeformer face restoration
Default:
truefile_typeoptionalstringFile type of the face you want to swap with.
Default:
"png"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