API Reference
Generate Images

Generate Images

Action GenerateImages

Introduction

This interface is used to generates images.

Request

Parameter NameTypeDescriptionRequired
ActionStringThe corresponding API instruction name
PublicKeyStringUser's public key, which can be obtained from the PICPIK User Center (opens in a new tab)
SignatureStringUser's signature generated based on the public key and API instruction, see Signature for details
request_uuidStringRequest UUID, randomly generated by using the UUID generation method. This parameter can be utilized to manage the requests of your business and clients.
Parameter NameTypeDescriptionRequired
MainModelModelMain model for generating images
SubModelList[]ModelThe submodel list for generating images includes LoRA, Embedding, and HyperNetwork.
PositivePrompts[]StringContent description of what you want to appear in the image.
NegativePrompts[]StringContent description of what you do not want to appear in the image.
TranslatePromptsBoolTranslate other languages to English. Default value: true
ControlNetList[]ControlNetThe ControlNet models (up to three) and parameters list.
Image2ImageImage2ImageParameters related to a reference image when generating from it.
SeedIntThe number of a seed (-1~2147483647), -1 represents a ramdom seed. Default value: -1
TileableBoolWether to generate tileable images or not. It is mostly used to create textures or patterns that can be tiled together. Default value: false
WidthIntImage width (64~2560). Default value: 1024
HeightIntImage height (64~2560). Default value: 1024
BatchSizeIntBatch size for generating images (1~16). Default value: 1
UseMainModelVAEBoolWhether to use the codec that comes with the main model. Default value: false
ImageAndMaskList[]Base64A list of reference images and masks encoded in Base64.

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.

Intro to Complex Data Types

Model

Field NameTypeDescriptionRequired
NameStringModel name
ModelCodeStringModel code
IsOfficialBoolIs official model or not
TriggerWordList[]StringTrigger word list, only available with LoRA model
InferenceParamsInferenceParamsInference parameters

ControlNet

Parameter NameTypeDescriptionRequired
ImageIndexIntThe index of an image in ImageAndMaskList, starting from 0.
MaskIndexIntThe 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.
InvertMaskBoolWether to invert the mask. Default: false
PreProcessorPreProcessorThe model and configuration information of a pre-rocessor.
ControlModelControlModelThe model and configuration information of the ControlNet.

Image2Image

Note: The ReferStrength parameter is invalid when the image is used as foreground.

Parameter NameTypeDescriptionRequired
ImageIndexIntThe index of an image in ImageAndMaskList, starting from 0.
ReferStrengthFloatThe reference strength of this image (0~1). Default value: 0.5

PreProcessor

Parameter NameTypeDescriptionRequired
ModelCodeStringThe model code of a ControlNet pre-processor.
InferenceParamsInferenceParamsInference parameters of a pre-processor

ControlModel

Parameter NameTypeDescriptionRequired
ModelCodeStringControlNet model code
InferenceParamsInferenceParamsInference parameters of a ControlNet model

InferenceParams

Note: Specific parameters are only valid for a particular model data type (parent) and are not generic.

Parameter NameTypeValid Parent TypeDescriptionDefaultRangeStepRequired
LoraWeightFloatModelThe influence weight when inferencing. Only available with the LoRA model.1-1~20.01
ResolutionIntPreProcessorThe resolution of images generated by the pre-processor.51264~204864
ControlWeightFloatControlModelThe influence weight of a ControlNet model when inferencing.10~20.01
StartingStepFloatControlModelTiming (ratio) of a ControlNet model to start intervening in the inference process.00~10.01
EndingStepFloatControlModelTiming (ratio) of a ControlNet model to stop intervening in the inference process.10~10.01

Simple Request Example

{
	"Action": "GenerateImages",
	"PublicKey": "ALLaXAM4cNdHXPDJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
	"Signature": "83f3ce02e110bbb25cecb5092637934a95e3bdc8",
	"request_uuid": "432c57d3-102b-4817-9e98-28054b33db8e",
	"MainModel": {
		"InferenceParams": {
			"Steps": 10
		},
		"ModelCode": "PICPIK Anime"
	},
	"PositivePrompts": [
		"a cat on the sofa"
	]
}

Advanced Request Example

{
    "Action": "GenerateImages",
    "BatchSize": 1,
    "ControlNetList": [
        {
            "ControlModel": {
                "InferenceParams": {
                    "ControlMode": "Balanced",
                    "ControlWeight": 1,
                    "EndingStep": 1,
                    "ResizeMode": "ResizeAndFill",
                    "StartingStep": 0
                },
                "ModelCode": "control_v11p_sd15_mlsd"
            },
            "ImageIndex": 1,
            "InvertMask": false,
            "MaskIndex": 2,
            "PreProcessor": {
                "InferenceParams": {
                    "MLSDDistanceThreshold": 0.1,
                    "MLSDValueThreshold": 0.1,
                    "Resolution": 512
                },
                "ModelCode": "mlsd"
            }
        }
    ],
    "Height": 512,
    "Image2Image": {
        "ImageIndex": 0,
        "ReferStrength": 0.5,
        "ResizeMode": "ResizeAndFill"
    },
    "MainModel": {
        "InferenceParams": {
            "Steps": 10
        },
        "ModelCode": "PICPIK General"
    },
    "NegativePrompts": [],
    "PositivePrompts": [
        "a cat on the sofa"
    ],
    "PublicKey": "ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
    "Seed": -1,
    "Signature": "59734dfd3985e96d452a2072533f47c766d52c19",
    "SubModelList": [
        {
            "InferenceParams": {
                "LoraWeight": 1
            },
            "ModelCode": "sub_model1_20230825_165436"
        }
    ],
    "Tileable": false,
    "TranslatePrompts": true,
    "UseMainModelVAE": false,
    "Width": 512,
    "request_uuid": "9e3f5da5-8020-463c-af54-a24912f4eb0e",
    "ImageAndMaskList": ["data:image/png;base64,xxx","data:image/png;base64,xxx"]
}

Response

Field NameTypeDescriptionRequired
RetCodeIntReturn status code: 0 indicates a successful return, while non-zero indicates a failure
ActionStringInstruction name
MessageStringThe error message is returned when RetCode is non-zero, providing a detailed description
request_uuidStringReturns the UUID that were included in the request
Parameter NameTypeDescriptionRequired
TaskUIDStringTask 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"
}