文生图
curl --request POST \
--url https://api.ppinfra.com/v3/async/txt2img \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '{
"extra": {
"response_image_type": "<string>"
},
"request": {
"model_name": "<string>",
"prompt": "<string>",
"width": 123,
"height": 123,
"image_num": 123,
"steps": 123,
"guidance_scale": {},
"sampler_name": "<string>",
"negative_prompt": "<string>",
"sd_vae": "<string>",
"seed": 123,
"loras": [
{
"model_name": "<string>",
"strength": {}
}
],
"embeddings": [
{
"model_name": "<string>"
}
],
"hires_fix": {
"target_width": 123,
"target_height": 123,
"strength": {},
"upscaler": "<string>"
},
"refiner": {
"switch_at": {}
},
"clip_skip": {},
"enable_transparent_background": true,
"restore_faces": true
}
}'
{
"task_id": "<string>"
}
文生图 API 能基于用户输入的内容,生成符合语义描述的图片。
请求头
枚举值: application/json
Bearer 身份验证格式,例如:Bearer {{API 密钥}}。
请求体
可以调用 /v3/model 接口并指定请求参数 filter.types=checkpoint
来获取可用模型列表。
提示词,用于指导图像生成的文本输入,文本长度范围 [1, 1024]。
生成图片的宽度,取值范围:[128, 2048]。
生成图片的高度,取值范围:[128, 2048]。
生成图片的数量,取值范围:[1, 8]。
迭代步数,图片创建过程的迭代数,取值范围:[1, 100]。
提示词引导系数,取值越大越接近于提示词描述,取值范围:[1, 30]。
指定采样器。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
反向提示词,文本长度范围 [0, 1024]。
模型 VAE(Variational Auto Encoder),可以调用 /v3/model 接口并指定请求参数 filter.types=vae
来获取可用模型列表。
随机数种子,稳定扩散产生噪声的数字,取值范围:>= -1。默认值为 -1。
Textual Inversion 模型,最多支持 5 个。
可以调用 /v3/model 接口并指定请求参数 filter.types=textualinversion
来获取可用模型列表。
Refiner 信息, 用作增强图片细节。
Refiner 的权重。当设置为 0 时,Refiner 没有效果;设置为 1 时,Refiner 完全激活。中间值如 0.5 提供平衡效果,Refiner 适度参与,增强或调整输出而不主导原始模型的特征。此设置对于微调输出以实现 Refiner 与原始生成特征之间的理想平衡特别有用,取值范围: [0, 1]。
CLIP 跳过层数,取值范围:[1, 12]。
使生成图像的背景透明。请注意,如果启用 transparent_background,则请求参数 response_image_type 必须置顶为 PNG,并且 Checkpoint 只能指定为 SDXL 模型。
用于控制是否启用面部修复功能。
响应参数
异步任务的 task_id。您应该使用该 task_id 请求 查询任务结果 API 以获取生成结果
curl --request POST \
--url https://api.ppinfra.com/v3/async/txt2img \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '{
"extra": {
"response_image_type": "<string>"
},
"request": {
"model_name": "<string>",
"prompt": "<string>",
"width": 123,
"height": 123,
"image_num": 123,
"steps": 123,
"guidance_scale": {},
"sampler_name": "<string>",
"negative_prompt": "<string>",
"sd_vae": "<string>",
"seed": 123,
"loras": [
{
"model_name": "<string>",
"strength": {}
}
],
"embeddings": [
{
"model_name": "<string>"
}
],
"hires_fix": {
"target_width": 123,
"target_height": 123,
"strength": {},
"upscaler": "<string>"
},
"refiner": {
"switch_at": {}
},
"clip_skip": {},
"enable_transparent_background": true,
"restore_faces": true
}
}'
{
"task_id": "<string>"
}