Pixu API v1

This article describes how to use the Pixu REST API. We are going to be describing the HTTP method, path, and parameters for every operation. The API will return the response status code, response headers, and a response body.

API Endpoints

POST /api/create_model

https://pixu.ai/pixu/api/create_model

Query Parameters

NameTypeDescription
api_keystringAPI KEY as generated in /accounts page
app_uidstringUnique identifier of your APP if negotiated in contract. Otherwise set to API
name (OPTIONAL)stringName of your model
face_base64stringBase64 encoded image of person's face. Only the cropped face should be provided
heightintDesired height in pixels of the face of generated images. Choose between 192 or 136
baselineintID of predefined trained parameters. Choose between 1 or 2

callback_url

intURL that will be called when the model is trained. Pixu will make GET request to the callback url. Model_UID will be appended at the end.

Example: https://my-site.com/callback_create_model/?model_uid=

Response Fields

NameTypeDescription
modelUidstringUnique identifier of the model being trained

Example

The following example creates a model:

curl -X POST https://pixu.ai/pixu/api/create_model \
                -H "Content-Type: application/json" \
                -d '{"api_key":"my_api_key", \
                    "app_uid":"api", \
                    "name":"My Model", \
                    "face_base64" : "base64 encoded cropped face", \
                    "height" : 192, \ 
                    "baseline" : 1, \
                    "callback_url" : "https://my-site.com/callback_create_model/?model_uid=" \
                }'

This would yield the following response:

{
                "response": {
                    "modelUid": "upose_de2d19bbb30703a45df8d0366ec49099"
                }
            }

When the model is trained Pixu will make this request

curl -X GET https://my-site.com/callback_create_model/?model_uid=upose_de2d19bbb30703a45df8d0366ec49099 

POST /api/create_model_from_url

https://pixu.ai/pixu/api/create_model_from_url

Query Parameters

NameTypeDescription
api_keystringAPI KEY as generated in /accounts page
app_uidstringUnique identifier of your APP if negotiated in contract. Otherwise set to API
name (OPTIONAL)stringName of your model
urlstringURL of photograph of a person. Either face crop or regular photo should be provided. If more than one face is present, extracted face is undeterministic
heightintDesired height in pixels of the face of generated images. Choose between 192 or 136
baselineintID of predefined trained parameters. Choose between 1 or 2

callback_url

intURL that will be called when the model is trained. Pixu will make GET request to the callback url. Model_UID will be appended at the end.

Example: https://my-site.com/callback_create_model/?model_uid=

Response Fields

NameTypeDescription
modelUidstringUnique identifier of the model being trained

Example

The following example creates a model:

curl -X POST https://pixu.ai/pixu/api/create_model_from_url \
                -H "Content-Type: application/json" \
                -d '{"api_key":"my_api_key", \
                    "app_uid":"api", \
                    "name":"My Model", \
                    "url" : "http://images.mysite.com/image1.jpg", \
                    "height" : 192, \ 
                    "baseline" : 2, \
                    "callback_url" : "https://my-site.com/callback_create_model/?model_uid=" \
                }'

This would yield the following response:

{
                "response": {
                    "modelUid": "upose_de2d19bbb30703a45df8d0366ec49099"
                }
            }

When the model is trained Pixu will make this request

curl -X GET https://my-site.com/callback_create_model/?model_uid=upose_de2d19bbb30703a45df8d0366ec49099 

POST /api/txt2img_strict_portrait

https://pixu.ai/pixu/api/txt2img_strict_portrait

Query Parameters

NameTypeDescription
api_keystringAPI KEY as generated in /accounts page
app_uidstringUnique identifier of your APP if negotiated in contract. Otherwise set to API
model_uidstringUnique identifier of the model. If ommited random face will be generated
model_weightfloatUse 1.0 for maximum likeness and lower values for some randomness of the face
positivestringPositive prompt
negativestringNegative prompt
resolutionstringResolution of output images. There are 3 options: 512,512 or 512,768 or 768,512

callback_url

intURL that will be called when images are generated. Pixu will make GET request to the callback url. Request_uid will be appended at the end

Example: https://my-site.com/callback_txt2img/?request_uid=

Response Fields

NameTypeDescription
stringUnique identifier of the model being trained

Example

The following example creates a model:

curl -X POST https://pixu.ai/pixu/api/txt2img_strict_portrait \
                -H "Content-Type: application/json" \
                -d '{
                    "api_key": "my_api_key",
                    "app_uid" : "api",
                    "model_uid" : "upose_61d36be5f3ace3e064f7698c49c7fc5b",
                    "model_weight" : 1.0,
                    "positive" : "woman in the bar",
                    "negative" : "(big hands, un-detailed skin, semi-realistic)",
                    "resolution" : "512,768",
                    "callback_url" : "https://my-site.com/callback_txt2img/?request_uid="  
                }'

This would yield the following response:

{
                "response": "9d788755c7f5c894c7aca0519b1e46d04b538bdf"
            }

When the model is trained Pixu will make this request

curl -X GET https://my-site.com/callback_txt2img/?request_uid=9d788755c7f5c894c7aca0519b1e46d04b538bdf 

POST /api/txt2img_composition

https://pixu.ai/pixu/api/txt2img_composition

Query Parameters

NameTypeDescription
api_keystringAPI KEY as generated in /accounts page
app_uidstringUnique identifier of your APP if negotiated in contract. Otherwise set to API
comp_uidstringUnique identifier of the composition. If ommited, random composition will be used
model_uidstringUnique identifier of the model. If ommited random face will be generated
model_weightfloatUse 0.8-0.9 for best results
positivestringPositive prompt
negativestringNegative prompt
resolutionstringResolution of output images. There are 3 options: 512,512 or 512,768 or 768,512

callback_url

intURL that will be called when images are generated. Pixu will make GET request to the callback url. Request_uid will be appended at the end

Example: https://my-site.com/callback_txt2img/?request_uid=

Response Fields

NameTypeDescription
stringUnique identifier of the model being trained

Example

The following example creates a model:

curl -X POST https://pixu.ai/pixu/api/txt2img_composition \
                -H "Content-Type: application/json" \
                -d '{
                    "api_key": "my_api_key",
                    "app_uid" : "api",
                    "comp_uid" : "53e7e0eb241903ed48829fbe3b43262a",
                    "model_uid" : "upose_61d36be5f3ace3e064f7698c49c7fc5b",
                    "model_weight" : 0.8,
                    "positive" : "woman in the bar",
                    "negative" : "(big hands, un-detailed skin, semi-realistic)",
                    "resolution" : "512,768",
                    "callback_url" : "https://my-site.com/callback_txt2img/?request_uid="  
                }'

This would yield the following response:

{
                "response": "9d788755c7f5c894c7aca0519b1e46d04b538bdf"
            }

When the model is trained Pixu will make this request

curl -X GET https://my-site.com/callback_txt2img/?request_uid=9d788755c7f5c894c7aca0519b1e46d04b538bdf