POST
/
v3
/
async
/
img2img
curl --request POST \
  --url https://api.ppinfra.com/v3/async/img2img \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '{
  "extra": {
    "response_image_type": "<string>"
  },
  "request": {
    "model_name": "<string>",
    "image_base64": "<string>",
    "prompt": "<string>",
    "width": 123,
    "height": 123,
    "image_num": 123,
    "steps": 123,
    "guidance_scale": {},
    "sampler_name": "<string>",
    "negative_prompt": "<string>",
    "sd_vae": "<string>",
    "controlnet": {
      "units": [
        {
          "model_name": "<string>",
          "image_base64": "<string>",
          "strength": {},
          "preprocessor": "<string>",
          "guidance_start": {},
          "guidance_end": {}
        }
      ]
    },
    "seed": 123,
    "loras": [
      {
        "model_name": "<string>",
        "strength": {}
      }
    ],
    "embeddings": [
      {
        "model_name": "<string>"
      }
    ],
    "clip_skip": {},
    "strength": {},
    "ip_adapters": [
      {
        "model_name": "<string>",
        "image_base64": "<string>",
        "strength": {}
      }
    ]
  }
}'
{
  "task_id": "<string>"
}

「图生图 API」能基于用户输入的内容和图片,生成符合语义描述的图片。

请求头

Content-Type
string
required

枚举值: application/json

Authorization
string
required

Bearer 身份验证格式,例如:Bearer {{API 密钥}}。

请求体

extra
object

请求的可选 extra 参数

request
object
required
model_name
string
required

可以调用 /v3/model 接口并指定请求参数 filter.types=checkpoint 来获取可用模型列表。

image_base64
string
required

图片二进制的 base64 内容,图片长和宽均不超过 2048 像素,文件最大不超过 30 Mb。

prompt
string
required

提示词,用于指导图像生成的文本输入,文本长度范围 [1, 1024]。

width
integer
required

生成图片的宽度,取值范围:[128, 2048]。

height
integer
required

生成图片的高度,取值范围:[128, 2048]。

image_num
integer
required

生成图片的数量,取值范围:[1, 8]。

steps
integer
required

迭代步数,图片创建过程的迭代数,取值范围:[1, 100]。

guidance_scale
number(float32)
required

提示词引导系数,取值越大越接近于提示词描述,取值范围:[1, 30]。

sampler_name
string
required

指定采样器。Enum: Euler a,Euler,LMS,Heun,DPM2,DPM2 a,DPM++ 2S a,DPM++ 2M,DPM++ SDE,DPM fast,DPM adaptive,LMS Karras,DPM2 Karras,DPM2 a Karras,DPM++ 2S a Karras,DPM++ 2M Karras,DPM++ SDE Karras,DDIM,PLMS,UniPC

negative_prompt
string

反向提示词,文本长度范围 [0, 1024]。

sd_vae
string

模型 VAE(Variational Auto Encoder),可以调用 /v3/model 接口并指定请求参数 filter.types=vae 来获取可用模型列表。

controlnet
object

ControlNet 配置信息,为文本到图像生成提供更高的控制程度。

seed
integer

随机数种子,稳定扩散产生噪声的数字,取值范围:>= -1。默认值为 -1。

loras
object[]

LoRA 模型,最多支持指定 5 个。

embeddings
object[]

Textual Inversion 模型,最多支持 5 个。

clip_skip
integer¦null

CLIP 跳过层数,取值范围:[1, 12]。

strength
number(float)¦null

控制对原始图片的调整幅度。总体来说,strength 值越大,调整幅度越大,和原始图片越不像。取值范围:(0, 1]。

ip_adapters
object[]

IP-Adapter 是一种图像提示适配器,可以插入扩散模型中,以实现对图像提示而无需对底层模型进行任何更改。此外,该适配器可以与从相同基础模型微调的其他模型复用,并且可以与其他适配器(如 ControlNet)结合使用,目前支持最多 1 个 IP-Adapter。

响应参数

task_id
string
required

异步任务的 task_id。您应该使用该 task_id 请求 查询任务结果 API 以获取生成结果