Docs
FaceSwap API

Face Swap API

Documentation on our cost-friendly, state-of-the-art Face Swap API (alpha test)!

GoAPI now offers Faceswap API for you to integrate into your app!


Example


an example showing using FaceSwap API to change Ironman's  face to another celebrity's face



Pricing

This API is will be pay-as-you-go for all users, see details: Face Swap API | PPU Quota | Endpoint Usage!



Async API

Each image must contain only one face.
This is an async request, you will need to fetch the result after submit this task.
If you are experiencing server errors when using this endpoint, please switch to a different available domain(s) shown here.

POST

https://api.goapi.xyz/api/face_swap/v1/async

Move the face from the swap image on to the target image.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️Your GoAPI Key used for request authorization
Body
NameTypeRequiredDescription
target_imagestring✔️URL(jpg,jpeg,png,webp) or Base64 string for the image whose face will be swapped with the swap_image face
swap_imagestring✔️URL(jpg,jpeg,png,webp) or Base64 string for the image whose face will be swapped with
result_typestringdecide what format the api returns. Can be `url` or `base64`, default is base64

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Request Example


curl --location 'https://api.goapi.xyz/api/face_swap/v1/async' \
--header 'X-API-Key: {YOUR-GOAPI-KEY}' \
--header 'Content-Type: application/json' \
--data '{
    "target_image": "https://hips.hearstapps.com/hmg-prod/doc-images/ariana_grande_photo_jon_kopaloff_getty_images_465687098.jpg",
    "swap_image": "https://imageio.forbes.com/specials-images/imageserve/6474d985fece284f32569957/0x0.jpg?format=jpg&width=1200",
    "result_type": "url"
}'

Response Example


You need task_id later in fetch api to get the final result.
{
    "code": 200,
    "data": {
        "task_id": "bfc30d05-006d-462f-a58e-8edf6e7021db"
    },
    "message": "success"
}

Error Message

Messagepossible root cause
invalid requestinput image is not an url or valid Base64 image string.
Url not ends in jpg,jpeg,png or webp
invalid request, no face found in the imagefailed to find a face in the input image
task not foundno such task_id
internal errorgoapi internal error
unknown generation error, please contact us for helpunknown error


Fetch API

Use this Fetch endpoint with the async endpoint.

POST

https://api.goapi.xyz/api/face_swap/v1/fetch

fetch the Face Swap result with a given task_id.

Parameters:

Header
NameTypeRequiredDescription
X-API-Keystring✔️Your GoAPI Key used for request authorization
Body
NameTypeRequiredDescription
task_idstring✔️the task_id that the async endpoint returns

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Request Example


curl --location 'https://api.goapi.xyz/api/face_swap/v1/fetch' \
--header 'X-API-Key: {YOUR-GOAPI-KEY}' \
--header 'Content-Type: application/json' \
--data '{
    "task_id": "bfc30d05-006d-462f-a58e-8edf6e7021db"
}'

Response Example


status reflects the actual progress of the task.
{
    "code": 200,
    "data": {
        "status": "success",
        "image": "https://img.midjourneyapi.xyz/temp/bf055b3b-37ee-4f94-a60c-43fe18916a6b",
        "used_credits": 7
    },
    "message": "success"
}

Status List

Statusdescription
pendingthe task is in wait queue of GoAPI
startingthe task is beginning to procceed
processingrendering the task
successtask finished
failedtask failed
retrythis usually happens if your image url is hard to download