Generate Images
Action
GenerateImages
Introduction
This interface is used to generates images.
Request
Parameter Name | Type | Description | Required |
---|---|---|---|
Action | String | The corresponding API instruction name | β |
PublicKey | String | User's public key, which can be obtained from the PICPIK User Center (opens in a new tab) | β |
Signature | String | User's signature generated based on the public key and API instruction, see Signature for details | β |
request_uuid | String | Request UUID, randomly generated by using the UUID generation method. This parameter can be utilized to manage the requests of your business and clients. |
Parameter Name | Type | Description | Required |
---|---|---|---|
MainModel | Model | Main model for generating images | β |
SubModelList | []Model | The submodel list for generating images includes LoRA, Embedding, and HyperNetwork. | |
PositivePrompts | []String | Content description of what you want to appear in the image. | |
NegativePrompts | []String | Content description of what you do not want to appear in the image. | |
TranslatePrompts | Bool | Translate other languages to English, see support language list here. Default value: true | |
Seed | Int | The number of a seed (-1~2147483647), -1 represents a ramdom seed. Default value: -1 | |
Width | Int | Image width (64~2560). Default value: 1024 | |
Height | Int | Image height (64~2560). Default value: 1024 | |
BatchSize | Int | Batch size for generating images (1~16). Default value: 1 | |
UseMainModelVAE | Bool | Whether to use the codec that comes with the main model. Default value: false |
Parameter Name | Type | Description | Required |
---|---|---|---|
ControlNetList | []ControlNet | The ControlNet models (up to three) and parameters list. | |
Image2Image | Image2Image | Parameters related to a reference image when generating from it. | |
Tileable | Bool | Wether to generate tileable images or not. It is mostly used to create textures or patterns that can be tiled together. Default value: false | |
ImageAndMaskList | []Base64 | A list of reference images and masks encoded in Base64. |
Intro to Complex Data Types
Model
Field Name | Type | Description | Required |
---|---|---|---|
Name | String | Model name | |
ModelCode | String | Model code | β |
IsOfficial | Bool | Is official model or not | |
TriggerWordList | []String | Trigger word list, only available with LoRA model | |
InferenceParams | InferenceParams | Inference parameters |
ControlNet
Parameter Name | Type | Description | Required |
---|---|---|---|
ImageIndex | Int | The index of an image in ImageAndMaskList, starting from 0. | β |
MaskIndex | Int | The index of a mask image in ImageAndMaskList, starting from 0. A mask can be drawn independently or obtained through the Remove-Background or Content Extraction APIs. | |
InvertMask | Bool | Wether to invert the mask. Default: false | |
PreProcessor | PreProcessor | The model and configuration information of a pre-rocessor. | β |
ControlModel | ControlModel | The model and configuration information of the ControlNet. | β |
Image2Image
Parameter Name | Type | Description | Required |
---|---|---|---|
ImageIndex | Int | The index of an image in ImageAndMaskList or ImageList , starting from 0. | β |
ReferStrength | Float | The reference strength of this image (0~1). Default value: 0.5 |
PreProcessor
Parameter Name | Type | Description | Required |
---|---|---|---|
ModelCode | String | The model code of a ControlNet pre-processor. | β |
InferenceParams | InferenceParams | Inference parameters of a pre-processor |
ControlModel
Parameter Name | Type | Description | Required |
---|---|---|---|
ModelCode | String | ControlNet model code | β |
InferenceParams | InferenceParams | Inference parameters of a ControlNet model |
InferenceParams
Note: Specific parameters are only valid for a particular model data type (parent) and are not generic.
Parameter Name | Type | Valid Parent Type | Description | Default | Range | Step | Required |
---|---|---|---|---|---|---|---|
LoraWeight | Float | Model | The influence weight when inferencing. Only available with the LoRA model. | 1 | -1ο½2 | 0.01 | |
Resolution | Int | PreProcessor | The resolution of images generated by the pre-processor. | 512 | 64~2048 | 64 | |
ControlWeight | Float | ControlModel | The influence weight of a ControlNet model when inferencing. | 1 | 0~2 | 0.01 | |
StartingStep | Float | ControlModel | Timing (ratio) of a ControlNet model to start intervening in the inference process. | 0 | 0~1 | 0.01 | |
EndingStep | Float | ControlModel | Timing (ratio) of a ControlNet model to stop intervening in the inference process. | 1 | 0~1 | 0.01 |
Parameters-Passing Tip
π‘
A Model
in the MainModels
list retuned by the ListModels
interface can be assigned to the MainModel
parameter of this interface directly, as demonstrated in Python:
# Assume a variable "sdModels" as the JSON data returned by the interface "ListModels"
{
"MainModel": sdModels["MainModels"]["PICPIK General"],
}
Parameters that require model data, such as SubModelList
and ControlNetList
, can also be set by utilizing this tip.
Simple Request Example
{
"Action": "GenerateImages",
"PublicKey": "ALLaXAM4cNdHXPDJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
"Signature": "83f3ce02e110bbb25cecb5092637934a95e3bdc8",
"request_uuid": "432c57d3-102b-4817-9e98-28054b33db8e",
"MainModel": {
"ModelCode": "PICPIK Anime"
},
"PositivePrompts": [
"a cat on the sofa"
]
}
Advanced Request Example
{
"Action": "GenerateImages",
"PublicKey": "ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
"Signature": "59734dfd3985e96d452a2072533f47c766d52c19",
"request_uuid": "9e3f5da5-8020-463c-af54-a24912f4eb0e",
"MainModel": {
"ModelCode": "PICPIK General"
},
"SubModelList": [
{
"InferenceParams": {
"LoraWeight": 1
},
"ModelCode": "lora_model1_20230825_165436"
}
],
"NegativePrompts": [],
"PositivePrompts": [
"δΈεͺη«ε¨ζ²εδΈ"
],
"TranslatePrompts": true,
"Width": 512,
"Height": 512,
"BatchSize": 1,
"Seed": -1,
"Image2Image": {
"ImageIndex": 0,
"ReferStrength": 0.5
},
"ControlNetList": [
{
"ImageIndex": 1,
"MaskIndex": 2,
"InvertMask": false,
"PreProcessor": {
"InferenceParams": {
"Resolution": 512
},
"ModelCode": "mlsd"
},
"ControlModel": {
"InferenceParams": {
"ControlWeight": 1,
"EndingStep": 1,
"StartingStep": 0
},
"ModelCode": "control_v11p_sd15_mlsd"
}
}
],
"Tileable": false,
"UseMainModelVAE": false,
"ImageAndMaskList": ["data:image/png;base64,xxx","data:image/png;base64,xxx","data:image/png;base64,xxx"]
}
Response
Field Name | Type | Description | Required |
---|---|---|---|
RetCode | Int | Return status code: 0 indicates a successful return, while non-zero indicates a failure | β |
Action | String | Instruction name | β |
Message | String | The error message is returned when RetCode is non-zero, providing a detailed description | |
request_uuid | String | Returns the UUID that was included in the request |
Parameter Name | Type | Description | Required |
---|---|---|---|
TaskUID | String | Task UID, used to query task details and get results | β |
Response Example
{
"Action": "GenerateImages",
"RetCode": 0,
"Message": "",
"request_uuid": "432c57d3-102b-4817-9e98-28054b33db8e",
"TaskUID": "ckt3uqlrh4miq8mr9lgg"
}