Consistent_identitiesGenerate

Step 3) New swap

POST
/api/consistent_identities/generate

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',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')

Authorization

token_auth_2
headerAuthorizationBearer <token>

Request Body

application/json
  1. body
id_image?string
id_face?integer
identity_name?string
description_type?string
options?string
flag_sync?boolean
id_generation?integer
prompt?string

Response Body

Success

application/json
  1. response
image_id?string
faces?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" \  -H "Content-Type: application/json" \  -d '{}'
{  "image_id": "string",  "faces": [    "string"  ],  "coordinates_list": [    "string"  ],  "thumbnails": [    "string"  ],  "blurred_faces_list": [    "string"  ],  "face_description_list": [    "string"  ]}