API Reference
Generate Images

Generate Images

API GenerateImages

Introduction

This interface is used to generates images.

Request

Parameter NameTypeDescriptionRequired
ActionstringThe corresponding API command name, the current API is GenerateImages
PublicKeystringUser's public key, can be obtained from User Center (opens in a new tab)
SignaturestringUser signature generated based on public key and API command, see Signature
request_uuidstringRequest uuid, randomly generated using uuid generation method, used for troubleshooting
MainModelModelGenerate Image Main Model
SubModelList[]ModelGenerate Image Sub Model
PositivePrompts[]stringPositive Prompts
NegativePrompts[]stringNegative Prompts
TranslatePromptsboolTranslate other language to English, default value: true
ControlNetList[]ExtraControlNetParamControlNet parameter list (up to three),see ControlNet parameters
Image2ImageImage2ImageParamgraph parameters
SeedintRandom seed number (-1~2147483647), default value: -1
TileableboolTileable, default value: false
WidthintWidth (64~2560), default value: 1024
HeightintHeight (64~2560), default value: 1024
BatchSizeintBatch image size (1~16), default value: 1
UseMainModelVAEboolWhether to use the VAE that comes with the main model, default value: false
ImageAndMaskList[]stringBase64 list of reference images and masks

Model

Parameter NameTypeDescriptionRequired
ModelCodestringModel Code
InferenceParamsInferenceParamInference Params

InferenceParam

Parameter NameTypeDescriptionRequired
StepsintSteps(6~100),default: 10
SamplerstringSampler,Refer toSupport Samplers,default: Euler
ClipSkipintPrompt word to skip levels(1~12),default: 1
CFGScalefloat64Prompt word guidance level(1~30),default: 7.5
LoraWeightfloat64Lora weight (only valid when the model is lora),default: 1

Note: If the model used is the official PICPIK model, the default value shall be the default value returned by ListModels.

Image2ImageParam

Parameter NameTypeDescriptionRequired
ImageIndexintThe image is indexed in ImageAndMaskList, starting from 0
ReferStrengthfloatReference strength (0~1) Default value: 0.5
ResizeModestringScaling mode, reference values: JustResize, CropAndResize, ResizeAndFill, default value: ResizeAndFill

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"
	]
}
💡

Tip
In a real development environment, you can pass a Model object returned by the MainModels parameter of the ListModels interface directly into the MainModel parameter of this interface. Take Python as an example:

# Assume a variable "sdModels" as the JSON data returned by the interface "ListModels"
{
    "MainModel": sdModels["MainModels"]["PICPIK General"],
}

Parameters include model data such as SubModelList and ControlNetList can also be set by utilizing similar skills.

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

Parameter NameTypeDescriptionRequired
RetCodeintReturn status code, 0 for successful return, non-zero for failure
ActionstringOperation command name
MessagestringReturn error message, provide detailed description when RetCode is non-zero
request_uuidstringReturns the requested uuid
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"
}