sillytarvern中如何挂载外部绘图api进行图像生成

Creado el: 4 de septiembre de 2025

Respondido usando GPT-5 Thinking por Chat01

Pregunta

sillytarvern中如何挂载外部绘图api进行图像生成

Pensamiento

Proposing integration steps

For A1111, begin with the --api flag and use --cors-allow-origins if necessary when connecting in ST’s 'Extensions' menu. Use ST's source “Stable Diffusion WebUI / AUTOMATIC1111” and provide the local URL. For ComfyUI, ST has integrated steps for setting up URLs and workflows, with detailed guidance in the documents.

Summarizing integration steps

For OpenAI, mention the gpt-image-1 model (according to v1.13.0 changelog) and cite appropriate discussions. For BFL (Flux) and Stability AI, steps are similar: input API key and model selection. For other sources like TogetherAI, FAL.AI, and HuggingFace, include steps for generating images and troubleshooting tips about tokenized API issues.

Warning about tokenized API

It’s good to note that ST might not support token in the query parameter—it’s mentioned as an open issue. If the user wants to use an external image generation API not supported by default, they’ll need a custom server plugin or can adapt through ComfyUI. We should include command examples and cite the relevant documentation.

Integrating external API

We should provide clear, brief instructions in Chinese. For integrating unsupported external image APIs, it's best to use ComfyUI or create a server plugin. I'll mention ST's support for HuggingFace and FAL.AI, and clarify that unsupported APIs require custom solutions, with the option for a feature request.

Thought for 2m 9s

Respuesta

下面给你一份“开箱即用”的做法,教你在 SillyTavern 里挂载(接入)外部绘图 API 来生图。你可以按自己的环境选其一或多种来源(本地/云端)。

快速上手(通用流程)

  1. 在 SillyTavern 右上角「魔杖」→ Extensions(扩展)里打开 Image Generation(图像生成)扩展。它支持本地和云端多种来源,并可用 /sd ... 斜杠命令直接出图。(SillyTavern Docs)
  2. 在扩展面板里选择来源(Source)→填入所需的 URL / API Key / 模型名→点 Connect/Test。SillyTavern 原生支持:Stable Diffusion WebUI(A1111)、ComfyUI、SD.Next、OpenAI、Stability AI、Black Forest Labs(FLUX)、FAL.ai、HuggingFace Serverless、Stable Horde、Pollinations、TogetherAI、Google Imagen 等。(SillyTavern Docs)
  3. 出图方式:
    • 「魔杖」→ Image Generation;
    • 聊天框输入 /sd 模式或提示词(如 /sd background/sd apple tree);
    • 或开启“交互模式/函数工具”,让模型自动识别你要图的意图。(SillyTavern Docs)

各来源最简配置

A. 本地 Stable Diffusion WebUI / AUTOMATIC1111

  • 启动 A1111 时启用 API(必须):
    • Windows:编辑 webui-user.batCOMMANDLINE_ARGS,加入 --api
    • Linux/macOS:./webui.sh --listen --api
    • 如从浏览器前端直连需跨域,可再加 --cors-allow-origins=*(一般 ST 直连不需要)。(PyPI, Danny Wheildon, Horde Auto Web Bridge)
  • 在 ST 的 Image Generation 里选 Stable Diffusion WebUI / AUTOMATIC1111,默认本地 URL 多为 http://127.0.0.1:7860,测试连接即可。支持即写即用的 /sd 命令与多种生图模式。(SillyTavern Docs)

B. 本地/远程 ComfyUI

  • 在 ST 的图像生成来源里选 ComfyUI,填你的 ComfyUI 服务器地址(默认 http://127.0.0.1:8188;SwarmUI 托管的 ComfyUI 常用 7821 端口),点击 Connect。(SillyTavern Docs)
  • 选择内置工作流(Default_Comfy_Workflow.jsonChar_Avatar_Comfy_Workflow.json),或把你在 ComfyUI 导出的 API 格式工作流 JSON粘贴进 ST 的 Workflow Editor,并用占位符 %prompt%%negative_prompt%%model%%width%%height% 等让 ST 控件与工作流参数联动。(SillyTavern Docs)

C. 云端 OpenAI / Stability / BFL(FLUX)/ FAL.ai / HuggingFace / Stable Horde 等

  • 在 ST 选择对应来源,填入 API Key 与需要的 模型/引擎名即可。例如:
    • OpenAI:支持图像模型(如 gpt-image-1)。(GitHub)
    • Stability AI / BFL(FLUX)/ FAL.ai / HuggingFace Serverless / Stable Horde / TogetherAI / Pollinations:都在 ST 的支持列表内,按面板提示填 Key/模型并连测。(SillyTavern Docs)

贴士:所有来源都可统一用 /sd 触发,并支持“你/你的脸/背景/上一条消息/自由模式”等预设“生图模式”。例如:/sd background/sd cute cat。(SillyTavern Docs)


常用命令与小技巧

  • 自由模式直接写提示词:/sd apple tree
  • 指定负面词:/sd negative="blurry, watermark" portrait of ..."
  • 静默保存到图库但不在聊天里发:/sd quiet=true me
  • 把角色预设前缀插入自由提示:/sd {{charPrefix}}, riding a bike
  • 生成后可 Swipes(重掷同提示)翻页。(SillyTavern Docs)

常见坑 & 排错

  • 跨域问题(CORS):如果你让前端(浏览器)直接打到 A1111,有时需在 A1111 启动参数加 --cors-allow-origins=*。(Horde Auto Web Bridge)
  • “带 token 的 URL”:部分云商把令牌放在 ?token=... 查询串里,目前 ST 对这类“tokenized URL”连接存在兼容性问题(活跃 issue)。此类服务建议反代/改用受支持来源。(GitHub)
  • 远程访问/外网连接:官方建议用 VPN/Tunnel(Tailscale/Cloudflare Zero Trust/ngrok),不要直接端口映射暴露服务。(SillyTavern Docs)

想接“未在列表里的自定义绘图 API”?

SillyTavern 的图像生成来源是白名单式的。如果你的服务不在支持列表:

  • 方案 1:写一个 Server Plugin(Node.js,后端扩展),把你的 REST API包一层,再在 ST 里作为新来源使用。(SillyTavern Docs)
  • 方案 2:用 ComfyUI 做“适配器”:把外部服务迁入/复刻成 ComfyUI 工作流(或用能调用该服务的自定义节点),再通过 ST→ComfyUI 工作流来调度。(SillyTavern Docs)

如果你告诉我打算接入的具体 API 服务名(比如某家云厂商、私有推理网关、或自建的 REST 服务),我可以直接给到那一家的面板填写示例推荐参数故障排查清单,让你一次配置就能出图。

Compartir este Q&A