弃用
API参考(旧版)
图生图

图生图

Action GenerateImg2Img

简介

⚠️

该接口已过时,不再维护。

此接口利用参考图生成图片

请求

参数名类型描述信息必填
ActionString对应的 API 指令名称,当前 API 为 GenerateImg2Img
PublicKeyString用户公钥,可从 用户中心 (opens in a new tab) 获取
SignatureString根据公钥及 API 指令生成的用户签名,参见 签名算法
request_uuidString请求uuid,采用uuid生成方式随机生成
ModelTypeString模型类型,参考值:combined_modelcustom_model。使用PICPIK提供的官方模型需填写combined_model,使用自训练或上传的模型需填写custom_model
MainModelIdInt主模型ID若ModelType为combined_model,则填写SystemPreInstallModels的Id,否则填写则填写SelfMainModels的Id
SubModelIds[]int子模型列表,若ModelType为combined_model则不填写
SubModelParams[]SubModelParam子模型参数,若使用,SubModelIds,则可通过此参数控制子模型的权重
BatchSizeInt批量出图大小1~16
StepsInt迭代步数1~150
CfgScaleFloat提示词指导程度0~30
SeedInt随机数种子
SamplerString采样器,参考采样器列表
WidthInt图片生成宽度,最大值: 1440,最小值: 16
HeightInt图片生成高度,最大值: 1440,最小值: 16
ClipSkipIntClipSkip
TranslatePromptBool是否将提示词翻译成英文
PositivePrompts[]String正面提示词
NegativePrompts[]String反面提示词
ReferenceImageString参考图base64
ReferenceScaleFloat参考强度(0~1)
EnableControlNetBool是否开启controlNet
ControlNetParams[]ControlNetParam ControlNet参数列表(最多三个)
UseCustomMainModelVaeBool是否使用主模型VAE,true为使用主模型自带VAE,默认false

ControlNetParam

参数名类型描述信息必填
ControlNetImgStringControlNet图片base64
ControlPreSetIdStringControlNet预设参数Id,0:自定义,1:简笔涂鸦,2:人物姿势,3:动漫线稿,4: 空间线稿
ControlWeightFloatControlNet权重 0~2
ModelIdIntControlNet模型Id
PreProcessorIdIntControlNet预处理器Id
StartingControlStepFloatControlNet开始介入步数
EndingControlStepFloatControlNet结束介入步数
ControlModeString控制模式,参考值: Balanced、MyPromptIsMoreImportant、ControlNetIsMoreImportant
ResizeModeString缩放模式,参考值:JustResize、CropAndResize、ResizeAndFill
PreProcessorResolutionIntPreProcessorResolution
Param1ValueFloat参数1
Param2ValueFloat参数2

注: ControlPreSetId 若填写非0,则只需填写ControlNetImgControlWeight参数即可。反之则需要填写所有参数。参数参见获取ControlNet模型列表

SubModelParam

参数名类型描述信息必填
SubModelIdInt子模型id
ControlWeightFloat子模型控制权重(Lora权重)

请求示例

{
    "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
}

带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
            "ControlPreSetId":2,
            "ControlWeight":1.5,
            "ControlNetImg":"data:image/jpeg;base64,xxx"
        },
        {
            //使用自设参数的ControlNet ControlPreSetId为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
        }
    ]
}

响应

参数名类型描述信息必填
RetCodeInt返回状态码,为 0 则为成功返回,非 0 为失败
ActionString操作指令名称
MessageString返回错误消息,当 RetCode 非 0 时提供详细的描述信息
TaskUIDString任务UID,用于查询任务详情与获取结果

响应示例

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