Stable Diffusion Faceswap API Guide

A guide for developers and hobbyists for accessing the Stable Diffusion Faceswap API.

Stable Diffusion Faceswap API Guide

Overview: Welcome to the in-depth guide that unveils the potential of the Image-to-Image Faceswap API, provided by Segmind. This API offers developers and hobbyists a remarkable tool for generating captivating GIFs, allowing for face swapping and intricate visual manipulations. Its applications span across diverse fields, from the realms of entertainment to the dynamic landscape of advertising.

Prepare to embark on a comprehensive journey that delves into the intricacies of harnessing the Segmind Image-to-Image Faceswap API. This guide is thoughtfully curated to serve as your compass in seamlessly integrating this state-of-the-art technology into your projects. Whether you're a seasoned developer or a passionate hobbyist, the insights within these pages are tailored to empower your creative endeavors.

Ways to explore the API:

  1. Code: Dive deep into the API and unlock its capabilities.
  2. Playground: Uncomplicated and beginner-friendly approach to exploring the API.

Getting started:

1. Generating Authentication keys

  • Upon confirmation, the API authentication keys will be issued. Remember to store the key in a secure location before advancing to the subsequent step.

2. Swapping faces

To initiate image creation using the Faceswap API from Segmind, follow this step-by-step workflow:

  1. POST Generate API: Utilize this API to submit a request for image generation.

Commence the process by initiating a request for image generation, as demonstrated below

POST Generate API request:

curl -X POST \
     -H "x-api-key: YOUR API-KEY" \
     -H "Content-Type: application/json" \
     -d '{"input_face_image":"toB64('/elon.jpg')","target_face_image":"toB64('/burn.gif')","file_type":"gif","face_restore":true}' \
import requests
from base64 import b64encode

def toB64(imgUrl):
    return str(b64encode(requests.get(imgUrl).content))[2:-1]

api_key = "YOUR API-KEY"
url = ""

# Request payload
data = {
  "input_face_image": toB64('/elon.jpg'),
  "target_face_image": toB64('/burn.gif'),
  "file_type": "gif",
  "face_restore": True

response =, json=data, headers={'x-api-key': api_key})

Upon executing this code, you will tend to receive a status code

<Response [200]>

The different HTTP status codes that may be encountered include:

  • 200 - OK Image: Generated
  • 401 - Unauthorized: User authentication failed
  • 404 - Not Found: The requested URL does not exist
  • 405 - Method Not Allowed: The requested HTTP method is not allowed
  • 406 - Not Acceptable: Not enough credits
  • 500 - Server Error: The server had some issues with processing

Model Attributes: Dive into the essential attributes of this model, enabling image-to-image transformations with precision:

  • input_face_image: For optimal results, provide a close-up shot of the face you intend to use as the basis for your transformations.
  • target_face_image: Define the face you wish to swap with, whether it's an image or a GIF.
  • file_type: Specify the file type of the target face image for seamless integration.
  • face_restore: When activated, this boolean option engages the Codeformer face restoration model, enhancing the output by refining the resulting frames. It's a valuable tool for elevating the quality of your transformations.

Faceswap Playground:

For those who favor a code-free approach yet seek access to rapid prototyping our playground is your best solution.

Within seconds, experience the transformation by simply uploading your input image and choosing your target face, be it an image or a GIF. The magic unfolds right before your eyes.

Create your customized output image in mere seconds. Upload your preferred input image, preferably a close-up shot, and select a target image or GIF. Then, with a single click on the "Generate" button, your output image will swiftly materialize before your eyes

Welcome to our gallery showcasing images transformed by the Segmind Faceswap API. Explore this collection and draw inspiration for crafting your own distinctive visual creations



After :







In Summary:

Unlock the full potential of the Segmind Faceswap API and take your image generation to the next level. Businesses and developers can now access a streamlined and highly effective solution that eliminates the technical intricacies of image generation.

With auto-scaling APIs, you can dedicate your efforts to crafting compelling visuals without the burden of complex management. Sign up today at Segmind,  and start creating your unique and captivating visuals with the Faceswap API. Refine your drafts with each endeavor, and witness the transformative power of this remarkable tool that enables face swapping and intricate visual manipulations. Don't miss out on this opportunity to elevate your image-generation capabilities.