Consistent_identitiesGenerateV2
Swap generate v2 - one face head swap
POST
Only for enterprise customers This endpoint initiate a new face swap.
Example:
import requestsimport jsonurl_api = 'https://api.piktid.com/api'identity_id = "" # Identity to swap identifier, from the response of the endpoint /consistent_identities/upload_faceimage_id = "" # Target image identifier, from the response of the endpoint /consistent_identities/upload_targetface_id = 0 # Index of the face. 0: if the target image has only one face detected.options = {'flag_replace_and_download': True,'watermark_url':'watermark url','prompt_strength':0.55, # from 0.0 to 1.0, default: 0.55}response = requests.post(url_api+'/consistent_identities/generate/v2',headers={'Authorization': 'Bearer '+TOKEN},json={"identity_name": identity_id, # IDENTITY_ID"id_image": image_id, # IMAGE_ID"id_face": face_id, # FACE_ID"options": json.dumps(options),},)response_json = json.loads(response.text)This function is asynchronous. To retrieve the result, continuously poll (for example every 3 seconds) the endpoint /consistent_identities/notification/read.
response_n = requests.post(url_api+'/consistent_identities/notification/read',headers={'Authorization': 'Bearer '+TOKEN},json={'name_list':'swap'},)response_notifications_json = json.loads(response_n.text)swap_image_link = response_notifications_json.get('notifications_list',[])[0].get('data',{}).get('links',[])[0].get('l')token_auth_2header
AuthorizationBearer <token>application/json- body
id_image?stringid_face?integeridentity_name?stringdescription_type?stringoptions?stringflag_sync?booleanid_generation?integerprompt?stringSuccess
application/json- response
image_id?stringfaces?array<string>coordinates_list?array<string>thumbnails?array<string>blurred_faces_list?array<string>face_description_list?array<string>curl -X POST "https://example.com/api/consistent_identities/generate/v2" \ -H "Content-Type: application/json" \ -d '{}'{ "image_id": "string", "faces": [ "string" ], "coordinates_list": [ "string" ], "thumbnails": [ "string" ], "blurred_faces_list": [ "string" ], "face_description_list": [ "string" ]}