Files
life-echo/docs/3rd-party-api-best-practice/liblib-api-python-guide.md

42 KiB
Raw Blame History

LibLibAI 图像生成 API Python 开发指南

基于 LibLibAI 开放平台官方文档整理,仅保留 Python 调用相关内容。


官方文档链接

章节 地址
API 产品主页 & 购买 https://www.liblib.art/apis
工作流挑选 & 商用查询 https://www.liblib.art/workflows
开放平台域名(需配合密钥) https://openapi.liblibai.cloud
API 文档(飞书) https://liblibai.feishu.cn/wiki/UAMVw67NcifQHukf8fpccgS5n6d
文件上传文档(飞书) https://liblibai.feishu.cn/wiki/A9M2whHxsiKtu8kpIn3cZp0PnVw
ComfyUI LibLib 节点 https://github.com/lib-teamwork/ComfyUI-liblib
JS/TS SDK (npm) https://www.npmjs.com/package/liblibai

目录

  1. 产品概览
  2. 认证与签名
  3. 星流 Star-3 Alpha 生图
  4. 自定义模型生图
  5. 查询生图结果
  6. 文件上传
  7. 参数详解
  8. ControlNet 预处理器参考
  9. ControlNet 模型列表
  10. 枚举值速查
  11. 文档版本更新

1. 产品概览

LibLibAI 提供工作流 API 和多款生图模型 API

模型 特点
LiblibAI 工作流 社区商用工作流和个人本地工作流均可调用
F.1 Kontext 文本生图 + 高级图像编辑,真实感和风格一致性行业领先
智能算法 IMG 1 超强风格一致性、Prompt 还原能力
LibDream 中文指令理解良好,中文/海报生成能力最强
星流 Star-3 Alpha 自带 LoRA 推荐算法,照片级真实感,不能自由添加 LoRA仅支持部分 ControlNet
LiblibAI 自定义模型 可调用全量 50 万+ 可商用模型和私有模型,基于 F.1/XL/v3/v1.5 基础算法

计费规则

非固定消耗每次生图任务积分消耗取决于选用模型、采样步数、采样方法SDE 系列额外消耗、图片宽高、张数、重绘幅度、高分辨率修复参数、ControlNet 数量。

并发数和 QPS

项目 限制
生图任务并发数 默认 5同时进行的生图任务数
生图接口 QPS 默认 1 次/秒
查询结果接口 QPS 无限制

2. 认证与签名

2.1 API 密钥

登录 LibLib 领取或购买 API 积分后,系统生成开放平台访问密钥:

密钥 说明 示例
AccessKey API 访问凭证唯一标识用户20-30 位 KIQMFXjHaobx7wqo9XvYKA
SecretKey API 访问密钥用于加密请求参数30 位以上 KppKsn7ezZxhi6lIDjbo7YyVYzanSu2d

2.2 请求签名参数

每次请求 API 接口时,需在 URL 查询字符串中传递以下参数:

参数 类型 必需 说明
AccessKey String 开放平台授权的 AccessKey
Signature String 加密请求参数生成的签名
Timestamp String 生成签名时的毫秒时间戳(有效期 5 分钟)
SignatureNonce String 生成签名时的随机字符串

请求 URL 示例:

https://openapi.liblibai.cloud/api/generate/webui/text2img?AccessKey=KIQMFXjHaobx7wqo9XvYKA&Signature=xxx&Timestamp=1725458584000&SignatureNonce=random1232

2.3 签名生成算法

原文 = URI地址 + "&" + 毫秒时间戳 + "&" + 随机字符串
密文 = hmacSha1(原文, SecretKey)
签名 = encodeBase64URLSafeString(密文)   # 不补全位数,去除尾部 =

2.4 Python 签名实现

import hmac
from hashlib import sha1
import base64
import time
import uuid

def make_sign(uri: str, secret_key: str) -> tuple[str, str, str]:
    """
    生成 LibLib API 签名。
    返回 (signature, timestamp, signature_nonce)。
    """
    timestamp = str(int(time.time() * 1000))
    signature_nonce = str(uuid.uuid4())
    content = '&'.join((uri, timestamp, signature_nonce))

    digest = hmac.new(secret_key.encode(), content.encode(), sha1).digest()
    sign = base64.urlsafe_b64encode(digest).rstrip(b'=').decode()
    return sign, timestamp, signature_nonce

2.5 Python 构造完整请求 URL

def build_url(base_url: str, uri: str, access_key: str, secret_key: str) -> str:
    sign, ts, nonce = make_sign(uri, secret_key)
    return (
        f"{base_url}{uri}"
        f"?AccessKey={access_key}"
        f"&Signature={sign}"
        f"&Timestamp={ts}"
        f"&SignatureNonce={nonce}"
    )

# 示例
url = build_url(
    "https://openapi.liblibai.cloud",
    "/api/generate/webui/text2img/ultra",
    "KIQMFXjHaobx7wqo9XvYKA",
    "KppKsn7ezZxhi6lIDjbo7YyVYzanSu2d",
)

3. 星流 Star-3 Alpha 生图

照片级真实感,自带 LoRA 推荐算法。不能自由添加 LoRA仅支持部分 ControlNet。

3.1 模板 UUID

模板名称 UUID
星流 Star-3 Alpha 文生图 5d7e67009b344550bc1aa6ccbfa1d7f4
星流 Star-3 Alpha 图生图 07e00af4fc464c7ab55ff906f8acf1b7

3.2 文生图

  • 接口: POST /api/generate/webui/text2img/ultra
  • Content-Type: application/json

请求参数:

参数 类型 必需 说明
templateUuid string 5d7e67009b344550bc1aa6ccbfa1d7f4
generateParams object 生图参数

generateParams 字段:

字段 类型 必填 说明 范围
prompt string 正向提示词(纯英文) ≤2000 字符
aspectRatio string 二选一 宽高比预设 square(1024x1024) / portrait(768x1024) / landscape(1280x720)
imageSize object 二选一 具体宽高 {width, height} 512~2048
imgCount int 单次生图张数 1~4
steps int 采样步数 建议 30
controlnet object 构图控制 见下方

controlnet 字段(星流专用简化版):

字段 说明
controlType line(线稿) / depth(深度) / pose(姿态) / IPAdapter(风格迁移) / subject(主体参考,仅文生图)
controlImage 参考图可公网访问的完整 URL
import httpx

url = build_url(BASE_URL, "/api/generate/webui/text2img/ultra", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "templateUuid": "5d7e67009b344550bc1aa6ccbfa1d7f4",
    "generateParams": {
        "prompt": "1 girl, lotus leaf, masterpiece, best quality, highres, 8k",
        "aspectRatio": "portrait",
        "imgCount": 1,
        "steps": 30,
    }
})
data = resp.json()
generate_uuid = data["data"]["generateUuid"]

带 ControlNet 构图控制:

resp = httpx.post(url, json={
    "templateUuid": "5d7e67009b344550bc1aa6ccbfa1d7f4",
    "generateParams": {
        "prompt": "1 girl, lotus leaf, masterpiece, best quality",
        "aspectRatio": "portrait",
        "imgCount": 1,
        "steps": 30,
        "controlnet": {
            "controlType": "depth",
            "controlImage": "https://example.com/reference.png",
        }
    }
})

F.1 主体参考(仅文生图):

resp = httpx.post(url, json={
    "templateUuid": "5d7e67009b344550bc1aa6ccbfa1d7f4",
    "generateParams": {
        "prompt": "A fluffy cat lounges on a plush cushion.",
        "promptMagic": 1,
        "aspectRatio": "square",
        "imgCount": 1,
        "controlnet": {
            "controlType": "subject",
            "controlImage": "https://example.com/cat_ref.png",
        }
    }
})

3.3 图生图

  • 接口: POST /api/generate/webui/img2img/ultra
  • Content-Type: application/json

generateParams 字段:

字段 类型 必填 说明
prompt string 正向提示词纯英文≤2000 字符)
sourceImage string 参考图 URL可公网访问
imgCount int 单次生图张数1~4
controlnet object 构图控制(同文生图)
url = build_url(BASE_URL, "/api/generate/webui/img2img/ultra", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "templateUuid": "07e00af4fc464c7ab55ff906f8acf1b7",
    "generateParams": {
        "prompt": "girl with beautiful face, beautiful and aesthetic",
        "sourceImage": "https://example.com/source.png",
        "imgCount": 1,
    }
})
generate_uuid = resp.json()["data"]["generateUuid"]

4. 自定义模型生图

可自由调用 LiblibAI 网站内 F.1-dev/XL/v3/v1.5 全量模型(暂不支持混元和 PixArt

4.1 查询模型版本

  • 接口: POST /api/model/version/get

versionUuid 从 LibLib 网站模型详情页浏览器 URL 中获取。

url = build_url(BASE_URL, "/api/model/version/get", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "versionUuid": "21df5d84cca74f7a885ba672b5a80d19"
})
print(resp.json())
# {
#     "version_uuid": "21df5d84cca74f7a885ba672b5a80d19",
#     "model_name": "AWPortrait XL",
#     "version_name": "1.1",
#     "baseAlgo": "基础算法 XL",
#     "show_type": "1",
#     "commercial_use": "1",
#     "model_url": "https://www.liblib.art/modelinfo/..."
# }

4.2 文生图

  • 接口: POST /api/generate/webui/text2img
  • Content-Type: application/json

generateParams 基础字段:

字段 类型 必填 说明 范围
checkPointId string 底模 modelVersionUUID 全网可商用或自有模型
prompt string 正向提示词(纯英文) ≤2000 字符
negativePrompt string 负向提示词(纯英文) ≤2000 字符
clipSkip int Clip 跳过层 1~12默认 2
sampler int 采样器枚举值 见枚举参考
steps int 采样步数 1~60
cfgScale double 提示词引导系数 1.0~15.0
width int 初始宽度 12815361.5: 512768, XL: 7681344, F.1: 7681536
height int 初始高度 同上
imgCount int 单次生图张数 1~4
randnSource int 随机种子来源 0: CPU, 1: GPU默认 0
seed long 随机种子 -1~9999999999-1 随机
restoreFaces int 面部修复 0: 关, 1: 开,默认 0
vaeId string VAE 模型 UUID 空值取 checkpoint 的 VAE
additionalNetwork list LoRA 组合(最多 5 个) 7.1 节
hiResFixInfo object 高分辨率修复 7.2 节
controlNet list ControlNet最多 4 组) 7.4 节
url = build_url(BASE_URL, "/api/generate/webui/text2img", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "templateUuid": "e10adc3949ba59abbe56e057f20f883e",
    "generateParams": {
        "checkPointId": "0ea388c7eb854be3ba3c6f65aac6bfd3",
        "prompt": "Asian portrait, A young woman wearing a green baseball cap",
        "negativePrompt": "ng_deepnegative_v1_75t,(badhandv4:1.2),EasyNegative,(worst quality:2)",
        "sampler": 15,
        "steps": 20,
        "cfgScale": 7,
        "width": 768,
        "height": 1024,
        "imgCount": 1,
        "randnSource": 0,
        "seed": -1,
        "restoreFaces": 0,
        "additionalNetwork": [
            {"modelId": "31360f2f031b4ff6b589412a52713fcf", "weight": 0.3},
            {"modelId": "365e700254dd40bbb90d5e78c152ec7f", "weight": 0.6},
        ],
        "hiResFixInfo": {
            "hiresSteps": 20,
            "hiresDenoisingStrength": 0.75,
            "upscaler": 10,
            "resizedWidth": 1024,
            "resizedHeight": 1536,
        },
    }
})
generate_uuid = resp.json()["data"]["generateUuid"]

4.3 图生图

  • 接口: POST /api/generate/webui/img2img
  • Content-Type: application/json

相比文生图额外字段:

字段 类型 必填 说明 范围
sourceImage string 参考图 URL可公网访问 -
resizeMode int 缩放模式 0: 拉伸, 1: 裁剪, 2: 填充
resizedWidth int 缩放后宽度 128~2048
resizedHeight int 缩放后高度 128~2048
mode int 生图模式 0: 图生图, 4: 蒙版重绘
denoisingStrength double 重绘幅度 0~1默认 0.75
inpaintParam object mode=4 时必填 蒙版重绘参数 7.3 节
url = build_url(BASE_URL, "/api/generate/webui/img2img", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "templateUuid": "9c7d531dc75f476aa833b3d452b8f7ad",
    "generateParams": {
        "checkPointId": "0ea388c7eb854be3ba3c6f65aac6bfd3",
        "prompt": "1 girl wear sunglasses",
        "negativePrompt": "ng_deepnegative_v1_75t,(badhandv4:1.2),EasyNegative,(worst quality:2)",
        "clipSkip": 2,
        "sampler": 15,
        "steps": 20,
        "cfgScale": 7,
        "randnSource": 0,
        "seed": -1,
        "imgCount": 1,
        "restoreFaces": 0,
        "sourceImage": "https://example.com/source.png",
        "resizeMode": 0,
        "resizedWidth": 1024,
        "resizedHeight": 1536,
        "mode": 0,
        "denoisingStrength": 0.75,
    }
})
generate_uuid = resp.json()["data"]["generateUuid"]

5. 查询生图结果

  • 接口: POST /api/generate/webui/status
  • Content-Type: application/json

Star-3 Alpha 和自定义模型共用此接口。

返回字段:

字段 类型 说明
generateUuid string 生图任务 UUID
generateStatus int 生图状态(见下方枚举)
percentCompleted float 生图进度 0~1暂未实现
generateMsg string 附加信息(如失败原因)
pointsCost int 本次任务消耗积分
accountBalance int 账户剩余积分
images []object 图片列表(仅审核通过的)
images[].imageUrl string 图片地址(有效期 7 天)
images[].seed int 随机种子值
images[].auditStatus int 审核状态

生图状态枚举:

状态码 含义
1 等待执行
2 执行中
3 已生图
4 审核中
5 任务成功
6 任务失败
import time

url = build_url(BASE_URL, "/api/generate/webui/status", ACCESS_KEY, SECRET_KEY)

# 轮询等待生图完成
while True:
    resp = httpx.post(url, json={"generateUuid": generate_uuid})
    result = resp.json()["data"]

    status = result["generateStatus"]
    if status == 5:
        # 成功
        for img in result["images"]:
            print(f"图片地址: {img['imageUrl']}")
            print(f"种子值: {img['seed']}")
        print(f"消耗积分: {result['pointsCost']}")
        print(f"剩余积分: {result['accountBalance']}")
        break
    elif status == 6:
        print(f"生图失败: {result['generateMsg']}")
        break
    else:
        time.sleep(3)

返回示例:

{
    "code": 0,
    "msg": "",
    "data": {
        "generateUuid": "8dcbfa2997444899b71357ccb7db378b",
        "generateStatus": 5,
        "percentCompleted": 0,
        "generateMsg": "",
        "pointsCost": 10,
        "accountBalance": 1356402,
        "images": [
            {
                "imageUrl": "https://liblibai-online.liblib.cloud/sd-images/xxx.png",
                "seed": 12345,
                "auditStatus": 3
            }
        ]
    }
}

6. 文件上传

当图生图需要使用本地图片作为参考图时,需先上传到 LibLib OSS再使用返回的地址作为 sourceImage

6.1 获取上传签名

  • 接口: POST /api/generate/upload/signature(使用 AK 签名逻辑)
字段 类型 必需 说明
name string 文件名≤100 字符)
extension string 扩展名:jpg / png / jpeg

图片大小不能超过 10MB。

url = build_url(BASE_URL, "/api/generate/upload/signature", ACCESS_KEY, SECRET_KEY)

resp = httpx.post(url, json={
    "name": "my_photo",
    "extension": "jpg",
})
sign_data = resp.json()["data"]
# sign_data 包含: key, policy, postUrl, xOssDate, xOssExpires,
#                 xOssSignature, xOssCredential, xOssSignatureVersion

返回示例:

{
    "code": 0,
    "data": {
        "key": "aliyun-cn-test/a0d9244a5ea14465955faf6b178240b8.png",
        "policy": "eyJleHBpcmF0aW9uIjo...",
        "postUrl": "https://liblibai-airship-temp.oss-cn-beijing.aliyuncs.com",
        "xOssDate": "20250409T134329Z",
        "xOssExpires": 3600,
        "xOssSignature": "22349dd272560cd303ac15a9fcef...",
        "xOssCredential": "LTAI5tLuXj4MH4XhnpKBjnsY/20250409/cn-beijing/oss/aliyun_v4_request",
        "xOssSignatureVersion": "OSS4-HMAC-SHA256"
    },
    "msg": ""
}

6.2 上传文件到 OSS

通过 POST 表单上传到签名接口返回的 postUrl

重要注意事项:

  • 签名过期时间为 1 小时,必须在生成签名后 1 小时内上传
  • file 文件扩展名必须和签名接口使用的 extension 一致
  • file 必须放到表单最末尾,作为最后一个表单域
import requests

data = {
    'key': sign_data['key'],
    'policy': sign_data['policy'],
    'x-oss-date': sign_data['xOssDate'],
    'x-oss-expires': sign_data['xOssExpires'],
    'x-oss-signature': sign_data['xOssSignature'],
    'x-oss-credential': sign_data['xOssCredential'],
    'x-oss-signature-version': sign_data['xOssSignatureVersion'],
}

# file 必须放到表单最末尾
files = {
    'file': ('photo.jpg', open('/path/to/photo.jpg', 'rb'), 'image/jpeg')
}

response = requests.post(sign_data['postUrl'], data=data, files=files)
print(f"Status Code: {response.status_code}")  # 200 或 204 表示成功

6.3 使用上传后的图片地址

上传成功后,图片地址 = postUrl + / + key

image_url = f"{sign_data['postUrl']}/{sign_data['key']}"
# 例: https://liblibai-airship-temp.oss-cn-beijing.aliyuncs.com/aliyun-cn-prod/a0d9244a5ea14465955faf6b178240b8.png

将此地址填入生图参数的 sourceImage 字段即可:

resp = httpx.post(img2img_url, json={
    "templateUuid": "07e00af4fc464c7ab55ff906f8acf1b7",
    "generateParams": {
        "prompt": "girl with beautiful face",
        "imgCount": 1,
        "sourceImage": image_url,
    }
})

7. 参数详解

7.1 LoRA 参数

additionalNetwork 最多 5 个 LoRA基础算法类型需与 checkpoint 一致。

字段 类型 说明 范围
modelId string LoRA 模型版本 UUID 从可商用模型中选择
weight double LoRA 权重 -4.00~+4.00,默认 0.8
"additionalNetwork": [
    {"modelId": "31360f2f031b4ff6b589412a52713fcf", "weight": 0.3},
    {"modelId": "365e700254dd40bbb90d5e78c152ec7f", "weight": 0.6},
]

7.2 高分辨率修复

hiResFixInfo 对象。

字段 类型 说明 范围
hiresSteps int 高清修复采样步数 1~30
hiresDenoisingStrength double 去噪强度 0~1
upscaler int 放大算法枚举 从放大算法列表选择
resizedWidth int 缩放宽度 128~2048
resizedHeight int 缩放高度 128~2048
"hiResFixInfo": {
    "hiresSteps": 20,
    "hiresDenoisingStrength": 0.75,
    "upscaler": 10,
    "resizedWidth": 1024,
    "resizedHeight": 1536,
}

7.3 蒙版重绘参数

inpaintParam 对象,当 mode=4 时必填。

字段 类型 说明 范围
maskImage string 蒙版图 URL白色蒙版黑色底色 -
maskBlur int 蒙版模糊度 0~64默认 4
maskPadding int 蒙版边缘预留像素 0~256默认 32
maskMode int 蒙版模式 0: 重绘蒙版区域, 1: 重绘非蒙版区域
inpaintArea int 重绘区域 0: 全图, 1: 仅蒙版区域
inpaintingFill int 填充模式 0: 填充, 1: 原图, 2: 潜空间噪声, 3: 空白潜空间
"inpaintParam": {
    "maskImage": "https://example.com/mask.png",
    "maskBlur": 4,
    "maskPadding": 32,
    "maskMode": 0,
    "inpaintArea": 0,
    "inpaintingFill": 1,
}

7.4 ControlNet 基础参数

controlNet 列表,最多 4 组。每组参数:

字段 类型 必填 说明 范围
unitOrder int 执行顺序 1~4
sourceImage string 参考图 URL 可公网访问
width int 参考图宽度 ≤4096
height int 参考图高度 ≤4096
preprocessor int 预处理器枚举值 第 8 节
annotationParameters object 预处理器参数 第 8 节
model string ControlNet 模型 UUID 第 9 节
controlWeight double 控制权重 0~2默认 1
startingControlStep double 生效起始步(百分比) 0~1默认 0
endingControlStep double 生效终止步(百分比) 0~1默认 1
pixelPerfect int 完美像素 0: 关, 1: 开,默认 1
controlMode int 控制模式 0: 均衡, 1: 更注重提示词, 2: 更注重 ControlNet
resizeMode int 缩放模式 0: 拉伸, 1: 裁剪, 2: 填充
maskImage string 蒙版图 URL白蒙版黑底需与参考图尺寸一致 -
"controlNet": [
    {
        "unitOrder": 1,
        "sourceImage": "https://example.com/ref.png",
        "width": 1024,
        "height": 1536,
        "preprocessor": 3,
        "annotationParameters": {
            "depthLeres": {
                "preprocessorResolution": 1024,
                "removeNear": 0,
                "removeBackground": 0,
            }
        },
        "model": "6349e9dae8814084bd9c1585d335c24c",
        "controlWeight": 1,
        "startingControlStep": 0,
        "endingControlStep": 1,
        "pixelPerfect": 1,
        "controlMode": 0,
        "resizeMode": 1,
        "maskImage": "",
    }
]

8. ControlNet 预处理器参考

8.1 线稿类

Canny硬边缘

预处理器 映射名 枚举值 参数 建议模型
canny canny 1 preprocessorResolution(642048, 默认512), lowThreshold(1255, 默认100), highThreshold(1~255, 默认200) 1.5: control_v11p_sd15_canny, XL: xinsir_controlnet-canny-sdxl_V2, F.1: InstantX-FLUX.1-dev-Controlnet-Union-Pro
"preprocessor": 1,
"annotationParameters": {
    "canny": {"preprocessorResolution": 512, "lowThreshold": 100, "highThreshold": 200}
}

SoftEdge软边缘

预处理器 映射名 枚举值 参数
hed hed 5 preprocessorResolution(默认512)
hed_safe hedSafe 6 preprocessorResolution(默认512)
pidinet pidinet 17 preprocessorResolution(默认512)
pidinet_safe pidinetSafe 18 preprocessorResolution(默认512)
softedge_teed softedgeTeed 58 preprocessorResolution(默认512), safeSteps(0~64, 默认2)
softedge_anyline softedgeAnyline 65 preprocessorResolution(默认512), safeSteps(0~64, 默认2)

建议模型 — 1.5: control_v11p_sd15_softedge, XL: mistoLine_rank256, F.1: InstantX-FLUX.1-dev-Controlnet-Union-Pro / F.1_mistoline_dev_v1

MLSD直线

预处理器 映射名 枚举值 参数
mlsd mlsd 8 preprocessorResolution(默认512), valueThreshold(0.012.00, 默认0.1), distanceThreshold(0.0120.00, 默认0.1)

建议模型 — 1.5: control_v11p_sd15_mlsdXL/F.1: 暂无

Scribble/Sketch涂鸦/草图)

预处理器 映射名 枚举值 参数
scribble_pidinet scribblePidinet 20 preprocessorResolution(默认512)
scribble_xdog scribbleXdog 21 preprocessorResolution(默认512), XDoGThreshold(1~64, 默认32)
scribble_hed scribbleHed 22 preprocessorResolution(默认512)

建议模型 — 1.5: control_v11p_sd15_scribble, XL: xinsir_anime_painter, F.1: InstantX-FLUX.1-dev-Controlnet-Union-Pro

Lineart线稿

预处理器 映射名 枚举值 参数
lineart_realistic lineartRealistic 29 preprocessorResolution(默认512)
lineart_coarse lineartCoarse 30 preprocessorResolution(默认512)
lineart_anime lineartAnime 31 preprocessorResolution(默认512)
lineart_standard lineartStandard 32 preprocessorResolution(默认512)
lineart_anime_denoise lineartAnimeDenoise 36 preprocessorResolution(默认512)

建议模型 — 1.5: control_v11p_sd15_lineart / control_v11p_sd15s2_lineart_anime, XL: xinsir_anime_painter, F.1: InstantX-FLUX.1-dev-Controlnet-Union-Pro

8.2 空间关系类

Depth深度图

预处理器 映射名 枚举值 参数
depth_midas depthMidas 2 preprocessorResolution(默认512)
depth_leres depthLeres 3 preprocessorResolution, removeNear(0100, 默认0), removeBackground(0100, 默认0)
depth_leres++ depthLeresPlus 4 同 depth_leres
depth_zoe depthZoe 25 preprocessorResolution(默认512)
depth_hand_refiner depthHandRefiner 57 preprocessorResolution(默认512)
depth_anything depthAnything 64 preprocessorResolution(默认512)

建议模型 — 1.5: control_v11f1p_sd15_depth, XL: xinsir_controlnet_depth_sdxl_1.0, F.1: InstantX-FLUX.1-dev-Controlnet-Union-Pro

Segment语义分割

预处理器 映射名 枚举值 参数
segmentation segmentation 23 preprocessorResolution(默认512)
oneformer_coco oneformerCoco 27 preprocessorResolution(默认512)
oneformer_ade20k oneformerAde20k 28 preprocessorResolution(默认512)
anime_face_segment animeFaceSegment 54 preprocessorResolution(默认512)

建议模型 — 1.5: control_v11p_sd15_segXL/F.1: 暂无

Normal法线贴图

预处理器 映射名 枚举值 参数
normal_map normalMap 9 preprocessorResolution(默认512), backgroundThreshold(0~1.0, 默认0.4)
normal_bae normalBae 26 preprocessorResolution(默认512)

建议模型 — 1.5: control_v11p_sd15_normalbae, F.1: Flux.1-dev-Controlnet-Surface-Normal

8.3 姿态类

OpenPose

预处理器 映射名 枚举值 参数
mediapipe_face mediapipeFace 7 preprocessorResolution, maxFaces(110, 默认1), minConfidence(0.011, 默认0.5)
openpose openpose 10 preprocessorResolution(默认512)
openpose_hand openposeHand 11 preprocessorResolution
openpose_face openposeFace 12 preprocessorResolution
openpose_faceonly openposeFaceonly 13 preprocessorResolution
openpose_full openposeFull 14 preprocessorResolution
dw_openpose_full dwOpenposeFull 45 preprocessorResolution
animal_openpose animalOpenpose 53 preprocessorResolution
densepose densepose 55 preprocessorResolution
densepose_parula denseposeParula 56 preprocessorResolution

建议模型 — 1.5: control_v11p_sd15_openpose, XL: xinsir_controlnet-openpose-sdxl-1.0, F.1: F.1-ControlNet-Pose-V1 / InstantX-FLUX.1-dev-Controlnet-Union-Pro

8.4 画面参考

Tile/Blur分块/模糊)

预处理器 映射名 枚举值 参数
tile_resample tileResample 34 downSamplingRate(1.00~8.00, 默认1)
tile_colorfix tileColorfix 43 variation(3~32, 默认8)
tile_colorfix+sharp tileColorfixSharp 44 variation(332, 默认8), sharpness(02.00, 默认1)
blur_gaussian blurGaussian 52 preprocessorResolution(默认512), sigma(0~64, 默认9)

建议模型 — 1.5: control_v11f1e_sd15_tile, XL: xinsir_controlnet_tile_sdxl_1.0, F.1: Flux.1-dev-Controlnet-Upscaler

Reference参考

预处理器 映射名 枚举值 参数
reference_only referenceOnly 37 styleFidelity(0~1.0, 默认0.5)
reference_adain referenceAdain 38 styleFidelity(0~1.0, 默认0.5)
reference_adain+attn referenceAdainAttn 39 styleFidelity(0~1.0, 默认0.5)

仅适用基础算法 1.5,模型选 None

8.5 风格迁移

IP-Adapter

预处理器 映射名 枚举值 参数 适用算法
ip-adapter_clip_sd15 ipAdapterClipSd15 48 preprocessorResolution 1.5
ip-adapter_clip_sdxl ipAdapterClipSdxl 49 preprocessorResolution XL
ip-adapter_clip_sdxl_plus_vith ipAdapterClipSdxlPlusVith 61 XL
ip-adapter-siglip ipAdapterSiglip 66 preprocessorResolution F.1

T2I-Adapter / Shuffle

预处理器 映射名 枚举值 参数
clip_vision clipVision 15 preprocessorResolution
color color 16 preprocessorResolution
pidinet_sketch pidinetSketch 19 preprocessorResolution
shuffle shuffle 33 preprocessorResolution(默认512)

8.6 上色

预处理器 映射名 枚举值 参数
recolor_luminance recolorLuminance 50 gammaCorrection(0.1~2.0, 默认1)
recolor_intensity recolorIntensity 51 gammaCorrection(0.1~2.0, 默认1)

建议模型 — 1.5: ioclab_sd15_recolor, XL: sai_xl_recolor_256lora

8.7 局部重绘

预处理器 映射名 枚举值 参数
inpaint_global_harmonious inpaintGlobalHarmonious 40
inpaint_only inpaintOnly 41
inpaint_only+lama inpaintOnlyLama 42

建议模型 — 1.5: segmentation_mask_brushnet_ckpt, XL: segmentation_mask_brushnet_ckpt_sdxl_v1, F.1: F.1-dev-Controlnet-Inpainting-Beta

8.8 换脸

IP-Adapter Face

预处理器 映射名 枚举值 参数
ip-adapter_face_id ipAdapterFaceId 62
ip-adapter_face_id_plus ipAdapterFaceIdPlus 63

Instant ID

预处理器 映射名 枚举值 参数
instant_id_face_keypoints instantIdFaceKeypoints 59 preprocessorResolution(默认512)
instant_id_face_embedding instantIdFaceEmbedding 60 preprocessorResolution(默认512)

8.9 其他

预处理器 映射名 枚举值 说明
none none 0 参考图已处理为线稿/深度图/骨骼图时使用
invert invert 35 白底黑线反色,应用线稿模型时使用

9. ControlNet 模型列表

9.1 线稿类

Canny硬边缘

模型名称 算法 UUID
control_v11p_sd15_canny 1.5 7d917ec7e55c5805db737d3b493c91ce
t2iadapter_canny_sd14v1 1.5 a2c41c4e97944f3aa71f913bdc45b1ca
t2iadapter_canny_sd15v2 1.5 c04144bcf017232483181cd8607097c2
diffusers_xl_canny_full XL 56de5edadb6f2891aff05ff078dc0470
diffusers_xl_canny_mid XL efb97e9d8c237573298c3a5a7869b89c
diffusers_xl_canny_small XL dccde738064e9748f93b48ec5868968e
kohya_controllllite_xl_canny XL 5242e3d18cc18689bd8af11dd2d675c1
kohya_controllllite_xl_canny_anime XL 4f3e1cfe79f87496ec69a37826c3afeb
sai_xl_canny_128lora XL 63c7f2c6c354336513831aa522d7e0f4
sai_xl_canny_256lora XL 5bf551f53651764cad56363e17900d87
t2i-adapter_diffusers_xl_canny XL 618390ab2957a422612cb2ba92a2788f
t2i-adapter_xl_canny XL 7cd56501c336c1edba78430355c9d081
xinsir_controlnet-canny-sdxl_V2 XL b6806516962f4e1599a93ac4483c3d23
XLabs-flux-canny-controlnet_v3 F.1 017997cd6ba44c4dbe8f60e0a26cd0df
InstantX-FLUX.1-dev-Controlnet-Union-Pro F.1 13c1e1b96ba64f9cbb2b54f89b5fe873
InstantX-Qwen-Image-Controlnet-Union Qwen 5b5f21d2b80445598db19e924bd3a409

SoftEdge软边缘

模型名称 算法 UUID
control_v11p_sd15_softedge 1.5 0929722d9047ec6498a50ff5d1081629
sargezt_xl_softedge XL dda1a0c480bfab9833d9d9a1e4a71fff
controlnet-sd-xl-1.0-softedge-dexined XL 37bddde3d45c11ee9b5e00163e365853
mistoLine_softedge_sdxl_fp16 XL 4f6726be104a432f8039b018c92ed4bf
mistoLine_rank256 XL 83286d0e66a845c58f7d23442f9dedf9
XLabs-flux-hed-controlnet_v3 F.1 6c4d620df3644514903b8189735c6ae9
F.1_mistoline_dev_v1 F.1 3e6860a3b9444f25ae07d9c1b5d1ba9e
InstantX-FLUX.1-dev-Controlnet-Union-Pro F.1 13c1e1b96ba64f9cbb2b54f89b5fe873

MLSD直线 control_v11p_sd15_mlsd (1.5) → 7168cece6a0d491375aa1753ff3bdc21

Scribble/Sketch涂鸦

模型名称 算法 UUID
control_v11p_sd15_scribble 1.5 fe57911f7ba1b84eb27f1e1ecead3367
kohya_controllllite_xl_scribble_anime XL 4a399a87f1ffbc26d065a38765d30d24
xinsir_controlnet-scribble-sdxl-1.0 XL 888cf8985bd6442cba1f2d975b6eb022
xinsir_anime_painter XL f936bf22cb8e4dcfa6b0f3b96cdd8eb7

Lineart线稿

模型名称 算法 UUID
control_v11p_sd15_lineart 1.5 b06dfbd1a61c35e933d9f8caa8a0e031
control_v11p_sd15s2_lineart_anime 1.5 c263e039c57b8a958ee0a936039af654
t2i-adapter_diffusers_xl_lineart XL a0f01da42bf48b0ba02c86b6c26b5699

9.2 空间关系类

Depth深度图

模型名称 算法 UUID
control_v11f1p_sd15_depth 1.5 cf63d214734760dcdc108b1bd094921b
t2iadapter_depth_sd15v2 1.5 f08a4a889b56d4099e8a947503cabc14
t2iadapter_depth_sd14v1 1.5 8b74bf9ea84f592c069b523d9bef9dab
t2iadapter_zoedepth_sd15v1 1.5 fc8b79f97eeceda388b43df12509c311
control_sd15_inpaint_depth_hand_fp16 1.5 3497061cd45c11ee9b5e00163e365853
t2i-adapter_diffusers_xl_depth_zoe XL a35993a2d1cde4a6c800364a68731c67
sai_xl_depth_128lora XL 3156f3428afc7122c66b2b950f09d4cd
t2i-adapter_diffusers_xl_depth_midas XL c22ec6a7a24eed6b91889ae1a1e94b2e
diffusers_xl_depth_mid XL 740d6d428e70d4b40888efa4d9eb642a
xinsir_controlnet_depth_sdxl_1.0 XL 6349e9dae8814084bd9c1585d335c24c
sai_xl_depth_256lora XL 08d0fbb72d7fab601218df26978a46e0
sargezt_xl_depth XL feb9ee5779bf2eb3fdd669f2e3e6b1aa
sargezt_xl_depth_zeed XL 4216d4b49a6b559d76d181908f866eb8
kohya_controllllite_xl_depth_anime XL dea707d52e3a8f243da5579579cb3a3d
kohya_controllllite_xl_depth XL 693d7182db5293c0087524580111fd96
sargezt_xl_depth_faid_vidit XL 1c6d32d0fb004cf1becc2b526fd83690
diffusers_xl_depth_small XL 6a786af31a13776100e9c6a90f99aebf
diffusers_xl_depth_full XL 04dcab4b18c7b821e96660d6c19de50b
XLabs-flux-depth-controlnet_v3 F.1 0cc4e6b8206b44cdab51e30fb8b9c328
InstantX-FLUX.1-dev-Controlnet-Union-Pro F.1 13c1e1b96ba64f9cbb2b54f89b5fe873
Flux.1-dev-Controlnet-Depth F.1 64dd7a6c714f4512a4500f6a01b016b7

Segment语义分割 control_v11p_sd15_seg (1.5) → 94571f4bb5136464afc1540a92ae3ee8

Normal法线贴图

模型名称 算法 UUID
control_v11p_sd15_normalbae 1.5 9a85fdca18a8b58b2fb2ff13ab339be4
Flux.1-dev-Controlnet-Surface-Normal F.1 e51fdccdf3b8417aab246bde40b5f360

9.3 姿态类

模型名称 算法 UUID
control_v11p_sd15_openpose 1.5 b46dd34ef9c2fe189446599d62516cbf
t2iadapter_openpose_sd14v1 1.5 5a8b19a8809e00be4e17517e8ab174ad
control_v11p_sd15_densepose_fp16 1.5 3b4e0830d45c11ee9b5e00163e365853
control_sd15_animal_openpose_fp16 1.5 329f0073d45c11ee9b5e00163e365853
control_v2p_sd15_mediapipe_face 1.5 73de0752a7a8431ba21637cda6723c95
kohya_controllllite_xl_openpose_anime_v2 XL 4cbbd2483088ef5f0d41bfef0d7141fb
kohya_controllllite_xl_openpose_anime XL abb5d55cf94c504f6f8c64abc0b1483f
thibaud_xl_openpose_256lora XL 4dd1f4df2a9d3a9db8aeaa9480196d02
t2i-adapter_xl_openpose XL 9deac5a5c60abfd03261bd174ddba47d
t2i-adapter_diffusers_xl_openpose XL 9cd43e1856040c2436f00802d5b54ee5
thibaud_xl_openpose XL 2fe4f992a81c5ccbdf8e9851c8c96ff2
controlnet-densepose-sdxl XL 3ae77dfdd45c11ee9b5e00163e365853
xinsir_controlnet-openpose-sdxl-1.0 XL 23ef8ab803d64288afdb7106b8967a55
F.1-ControlNet-Pose-V1 F.1 7c6d889cb9c04b78858d8fece80f9f85

9.4 画面参考

Tile/Blur

模型名称 算法 UUID
control_v11f1e_sd15_tile 1.5 37e42c6bdb6fab4c24a662100f20f722
kohya_controllllite_xl_blur_anime XL 46a34a643f6855e9b3861515712df5d9
xinsir_controlnet_tile_sdxl_1.0 XL 0f47ef6d4f4b40afab8b290c98baac0e
kohya_controllllite_xl_blur_anime_beta XL 44199bb6dcf4f65e09a4e5e57ebdf9b4
kohya_controllllite_xl_blur XL aac5fe593565f0673673731d54ecfab8
TTPLanet_SDXL_Controlnet_Tile_Realistic_v1 XL 13bfaf39f9214c658507a92cd15fd02d
TTPLanet_SDXL_Controlnet_Tile_Realistic_v2 XL 163d505651a64d6bac9a907b213dc8b0
Flux.1-dev-Controlnet-Upscaler F.1 a696b5bdadc740119fd76505b33d6898

9.5 风格迁移

IP-Adapter

模型名称 算法 UUID
ip-adapter_sd15 1.5 18801062fe4289dd0a984e69de9f9e7c
ip-adapter_sd15_plus 1.5 ad4bd9b4b05c4ac8faf7f81d9fdcadc8
ip-adapter_sd15_light 1.5 3a1ddfd0d45c11ee9b5e00163e365853
ip-adapter_sd15_vit-G 1.5 36f3d2a0d45c11ee9b5e00163e365853
ip-adapter_xl XL 8ea2538fdd7dcdea52b2da6b5151f875
ip-adapter-plus_sdxl_vit-h XL 38ee73f1d45c11ee9b5e00163e365853
ip-adapter_sdxl_vit-h XL 375866e3d45c11ee9b5e00163e365853
InstantX-F.1-dev-IP-Adapter F.1 c6ed70879cf011ef96d600163e37ec70
F.1-redux-dev F.1 8ddf6f3ba8a111efbb1700163e031cf1

T2I-Adapter

模型名称 算法 UUID
t2iadapter_color_sd14v1 1.5 8e581a4e7c986950d71f1102accad5d0
t2iadapter_keypose_sd14v1 1.5 181d8d213381458cb6e326760637d4b4
t2iadapter_seg_sd14v1 1.5 3c680cc8edfbc4479423549e01f21897
t2iadapter_sketch_sd14v1 1.5 0d19dd02091ec2d01f3cdd99a4f4b442
t2iadapter_sketch_sd15v2 1.5 bd6c5dbb73c2c2e538850c23ab2dcbf5
t2iadapter_style_sd14v1 1.5 e33777a1f374eccd9464623c56a82c91

Shuffle control_v11e_sd15_shuffle (1.5) → 9efba1cc2d469bf4be8fc135689bc8a0

9.6 上色

模型名称 算法 UUID
ioclab_sd15_recolor 1.5 e0db5b9e227eac932c71498cf7e03a78
sai_xl_recolor_128lora XL af92235f1de682ceac136c06450c9a51
sai_xl_recolor_256lora XL 03051a3606b4974ec02fc55b079757e7

9.7 局部重绘

模型名称 算法 UUID
control_v11p_sd15_inpaint 1.5 ebeada0aa92959b4e905ab6980d5d203
segmentation_mask_brushnet_ckpt 1.5 14aa553bf6534a419a9a465eba900f3a
random_mask_brushnet_cpkt 1.5 de44488f84a74e02a1fac604d790698c
segmentation_mask_brushnet_ckpt_sdxl_v1 XL a311363995dd4f2fa42ee3fc9582d920
random_mask_brushnet_ckpt_sdxl XL 3161fc68c59847b0ad826a9fb18c857f
F.1-dev-Controlnet-Inpainting-Alpha F.1 012d2f780c0b44dba829bb223207e608
F.1-dev-Controlnet-Inpainting-Beta F.1 31df01fc271d484ca4d496179d69a665
InstantX-Qwen-Image-ControlNet-Inpainting Qwen 2228ab9234a34aa5abf77caa907c0de1

9.8 换脸

IP-Adapter Face

模型名称 算法 UUID
ip-adapter_face_id 1.5 368e6a37d45c11ee9b5e00163e365853
ip-adapter-faceid-portrait_sd15 1.5 330504bcd45c11ee9b5e00163e365853
ip-adapter-faceid-plusv2_sd15 1.5 34fb8ef6d45c11ee9b5e00163e365853
ip-adapter-faceid-plus_sd15 1.5 362a215ad45c11ee9b5e00163e365853
ip-adapter-faceid-portrait-v11_sd15 1.5 35c50016d45c11ee9b5e00163e365853
ip-adapter-faceid_sdxl XL 38879e1ad45c11ee9b5e00163e365853
ip-adapter-faceid-plusv2_sdxl XL 3953f672d45c11ee9b5e00163e365853
ip-adapter-plus-face_sdxl_vit-h XL 336955e4d45c11ee9b5e00163e365853

Instant ID仅 XL

模型名称 UUID
ip-adapter_instant_id_sdxl 3a8267c7d45c11ee9b5e00163e365853
control_instant_id_sdxl 3560664ad45c11ee9b5e00163e365853

PuLID仅 F.1 pulid_flux_v0.9.1405836d1ae2646b4ba2716ed6bd5453a

9.9 其他

模型名称 算法 UUID 用途
control_v1u_sd15_illumination 1.5 3109072a5cf6403faba6162003b8f483 光影
control_v1p_sd15_brightness 1.5 39b8eac0d45c11ee9b5e00163e365853 光影
control_v1p_sd15_qrcode_monster 1.5 1fa6070c35626e760b1473926852cbbc 二维码

10. 枚举值速查

生图状态 (generateStatus)

含义
1 等待执行
2 执行中
3 已生图
4 审核中
5 任务成功
6 任务失败

审核状态 (auditStatus)

含义
0 待审核
3 审核通过

采样器 (sampler)

需从 LibLib 提供的采样方法列表中选择枚举值。常用值:15

放大算法 (upscaler)

需从 LibLib 提供的放大算法模型枚举中选择。常用值:10


11. 文档版本更新

日期 说明
2025.12.21 增加 Seedream4.5、Kling2.6 接口
2025.11.4 增加 Kling2.5、Seedream4.0 接口
2025.8.19 增加可灵生成视频接口、LibDream & LibEdit
2025.6.16 增加 F.1 Kontext、智能算法 IMG-1
2025.4.30 支持图片上传
2025.3.18 增加 F.1-ControlNetPuLID 人像换脸、主体参考)
2025.1.17 增加调用 ComfyUI 工作流
2025.1.2 增加 ComfyUI 接入星流 API
2024.12.18 查询结果新增 pointsCost 和 accountBalance 字段
2024.12.5 原【进阶模式】更名为【LiblibAI 自定义模型】
2024.11.15 支持 F.1 风格迁移