API For Face Swap Video
June 18, 2024About 2 min
API For Face Swap Video
AI Face Swap Video
The AI Face Swap API offers powerful functionality to intelligently detect faces within photos and seamlessly replace them with other faces of your choice. This advanced technology empowers users with unparalleled creative freedom, allowing effortless face swapping across a diverse range of photos.
Credits Consumption
Calculate based on the duration of the video, consuming credits per second. If face_enhance function is turned on,
Standard response
If the request is successful, the API will return OK (HTTP status code 200) and a JSON object, otherwise, it will return an HTTP status code that indicates the error and a JSON object that contains the error details.
Parameter | Description |
---|---|
code | The business code, 100000 indicates success, 300102 indicates progressing otherwise indicates error. In most cases, the error code will be equal to the HTTP status code (e.g. 400, 401, 404, 500, etc). Or else, it will be a custom error code defined by the API.. |
message | Description of the returned information |
result | The response data object only available when the request is successful . The data object will be different for each API. |
Considerations
- Before using the API, make sure you have obtained the API key. Refer to the link below for instructions on how to obtain it. API For API Key Settings
- All generated images will be automatically deleted after 24 hours. Please make sure to save the images you need to your local storage in a timely manner.
Header Attributes
Parameter | Description |
---|---|
Authorization | Your API Key used for request authorization. |
Create Job
Request Url
--request POST https://developer.remaker.ai/api/remaker/v2/face-swap-video/create-job
Body Attributes
Parameter | Type | Required | Description |
---|---|---|---|
swap_image | file[binary] | true | pictures with faces |
target_video_url | string | true | An accessible video URL. The video should be less than thirty minutes in length and smaller than 500MB. |
face_enhance | bool | false | (6credits/s)The face enhancement option will return a clearer face when turned on. |
Demo
import requests
url = "https://developer.remaker.ai/api/remaker/v2/face-swap-video/create-job"
payload = {'target_video_url': 'https://image.remaker.ai/test/face-swap-video/10s.mp4'}
files=[
('swap_image',('images.jpg',open('images.jpg','rb'),'image/jpeg'))
]
headers = {
'Authorization': 'your api key'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Response
{
"code": 100000,
"result": {
"job_id": "b46dc098-76ce-4b8d-adfc-ccb40bd1c696"
},
"message": {
"en": "Request Success."
}
}
Fetch Job
Request Url
--request GET https://developer.remaker.ai/api/remaker/v2/face-swap-video/{job_id}
Body Attributes
Parameter | Description |
---|---|
job_id | job_id returned by create task |
import requests
url = "https://developer.remaker.ai/api/remaker/v2/face-swap-video/{your jon_id}"
payload = {}
headers = {
'Authorization': 'your api key'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Response
progress
{
"code": 300102,
"result": {
"output": [],
"progress": 10,
"thumbnail_path": "https://image.remaker.ai/datarm30/api/face-video/thumbnail/2024-12-11/0b1448a3-a3b3-49cc-bee6-ea36b1e71678.png"
},
"message": {
"en": "Image generation in progress."
}
}
Success
{
"code": 100000,
"result": {
"output": [
"https://image.remaker.ai/datarm30/video-face-swap/2024-12-11/c6912543-e495-427b-9a19-5919af108bc3.mp4"
],
"need_credits": 362,
"thumbnail_path": "https://image.remaker.ai/datarm30/face-video/output/2024-12-11/899c54ff-22d0-488b-a869-c459837b00fd.png",
"progress": 100
},
"message": {
"en": "Request Success."
}
}