API Reference (Legacy)
Image to Image

Image to Image

API GenerateImg2Img

Introduction

⚠️

This interface is no longer maintained.

This interface generates images by using reference images.

Request

Parameter NameTypeDescriptionRequired
ActionstringThe corresponding API command name, the current API is GenerateImg2Img
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
ModelTypestringModel type, reference value: combined_model, custom_model. To use the official model provided by PICPIK, you need to fill in combined_model, and to use a self-trained or uploaded model, you need to fill in custom_model
MainModelIdintMain model ID, if ModelType is combined_model, fill in the Id of SystemPreInstallModels, otherwise fill in the Id of SelfMainModels
SubModelIds[]intSubmodel list, do not fill in if ModelType is combined_model
SubModelParams[]SubModelParamSubmodel parameters. If SubModelIds is used, the weight of the submodel can be controlled through this parameter.
BatchSizeintBatch image size 1~16
StepsintIteration steps 1~150
CfgScalefloatPrompt word guidance level 0~30
SeedintRandom number seed
SamplerstringSampler,Reference Support Samplers
WidthintImage generation width, max: 1440, min: 16
HeightintImage generation height, max: 1440, min: 16
ClipSkipintClipSkip
TranslatePromptboolWhether to translate the prompt word into English
PositivePrompts[]stringPositive prompts
NegativePrompts[]stringNegative prompts
ReferenceImagestringReference image base64
ReferenceScalefloatReference intensity (0~1)
EnableControlNetboolWhether to enable controlNet
ControlNetParams[]ControlNetParam ControlNet parameters list (max length:3)
UseCustomMainModelVaeboolUsing main model VAE ,true means use main model VAE,default false

ControlNetParam

Parameter NameTypeDescriptionRequired
ControlNetImgstringControlNet image base64
ControlPreSetIdstringControlNet Default parameter ID, 0: customized, 1: Graffiti and Sketch, 2: Figure's Pose, 3: Anime Line Drawing, 4: Spatial Line Drawing
ControlWeightfloatControlNet weight 0~2
ModelIdintControlNet model Id
PreProcessorIdintControlNet preprocessor Id
StartingControlStepfloatControlNet starting intervention step
EndingControlStepfloatControlNet ending intervention step
ControlModestringControl mode, reference value: Balanced、MyPromptIsMoreImportant、ControlNetIsMoreImportant
ResizeModestringResize mode, reference value: JustResize、CropAndResize、ResizeAndFill
PreProcessorResolutionintPreProcessorResolution
Param1ValuefloatParameter 1
Param2ValuefloatParameter 2

Note: If ControlPreSetId is not 0, you only need to fill in the ControlNetImg and ControlWeight parameter. Otherwise, all parameters need to be filled in. Parameter referenceControlNet Model List

SubModelParam

参数名类型描述信息必填
SubModelIdintSub model Id
ControlWeightfloatSub model control weight(Lora weight)

Request Example

{
    "Action":"GenerateImg2Img",
    "PublicKey":"ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
    "Signature":"10e99193615e2c363f15f7339b3dac0c91a9272a",
    "request_uuid":"a6daddb3-04d8-46b6-a831-88e80769aef3",
    "ModelType":"combined_model",
    "MainModelId":1,
    "BatchSize":1,
    "Steps":20,
    "CfgScale":7.5,
    "Seed":-1,
    "Sampler":"Euler",
    "ClipSkip":1,
    "Width":512,
    "Height":512,
    "PositivePrompts":[
        "an apple"
    ],
    "NegativePrompts":[
 
    ],
    "ReferenceImage":"data:image/jpeg;base64,/9j/4AAQSxxxxxx",
    "ReferenceScale":0.5,
    "TranslatePrompt":true
}

Request example with ControlNet

{
    "Action":"GenerateImg2Img",
    "PublicKey":"ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
    "Signature":"10e99193615e2c363f15f7339b3dac0c91a9272a",
    "request_uuid":"a6daddb3-04d8-46b6-a831-88e80769aef3",
    "ModelType":"combined_model",
    "MainModelId":1,
    "BatchSize":1,
    "Steps":20,
    "CfgScale":7.5,
    "Seed":-1,
    "Sampler":"Euler",
    "ClipSkip":1,
    "Width":512,
    "Height":512,
    "PositivePrompts":[
        "an apple"
    ],
    "NegativePrompts":[
 
    ],
    "ReferenceImage":"data:image/jpeg;base64,/9j/4AAQSxxxxxx",
    "ReferenceScale":0.5,
    "TranslatePrompt":true,
    "ControlNetParams":[
        {
            //ControlNet using preset parameters
            "ControlPreSetId":2,
            "ControlWeight":1.5,
            "ControlNetImg":"data:image/jpeg;base64,xxx"
        },
        {
            //ControlNet using custom parameters, ControlPreSetId need to be set 0
            "ControlMode":"Balanced",
            "ControlNetImg":"data:image/jpeg;base64,xxx",
            "ControlPreSetId":0,
            "ControlWeight":1,
            "EndingControlStep":1,
            "ModelId":4,
            "PreProcessorId":5,
            "PreProcessorResolution":512,
            "ResizeMode":"JustResize",
            "StartingControlStep":0,
            "Param1Value":10,
            "Param2Value":30
        }
    ]
}

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
TaskUIDstringTask UID, used to query task details and get results

Response Example

{
    "Action":"",
    "RetCode":0,
    "Message":"",
    "TaskUID":"cjr997tleg738lelk3n0"
}