Python API client for when clicking WebUI buttons gets old
It wraps AUTOMATIC1111's Stable Diffusion WebUI in a Python client so you can generate and edit images programmatically instead of clicking through Gradio.

What it does
sdwebuiapi is a Python client that talks to a running AUTOMATIC1111 Stable Diffusion WebUI instance over HTTP. It exposes the WebUI’s generation endpoints—txt2img, img2img, inpainting, upscaling, and batch processing—as Python methods that return PIL images. You also get hooks for model switching, sampler lists, ControlNet, and WebUI scripts, effectively turning the Gradio interface into a backend service you can script.
The interesting bit
The client is essentially a thin, hand-typed translation layer over the WebUI’s auto-generated OpenAPI docs, which means it stays close to the underlying HTTP contract. The slightly unusual part is how it handles the WebUI’s extension ecosystem: because there is no formal schema for scripts, you have to manually inspect the extension’s Python source to figure out the argument order, then pass them as raw lists. It is glue code, but it knows its place.
Key highlights
- Supports txt2img, img2img, inpainting, single and batch upscaling, plus async calls.
- Returns results as PIL
Imageobjects with metadata, parameters, and generation info attached. - Includes helpers for model switching, sampler lists, progress polling, and interrupt or skip controls.
- Hooks into ControlNet, LoRA, and always-on scripts.
- Auth support is included, though the README notes basic HTTP auth transmits passwords in cleartext.
Caveats
- The README warns that passing the full options dict back to
set_options()can render the WebUI unusable (as of 2022/11/21). - Script arguments are undocumented by the WebUI itself; you must reverse-engineer them from the extension source code.
- The API surface is pinned to the WebUI docs as of late 2022, so newer endpoints or parameter changes may lag.
Verdict
Grab this if you are building pipelines, batch jobs, or Jupyter notebooks around AUTOMATIC1111’s WebUI and are tired of screenshotting Gradio. Skip it if you are using a different backend like ComfyUI or a native diffusers pipeline; this client is strictly for the WebUI ecosystem.
Frequently asked
- What is mix1009/sdwebuiapi?
- It wraps AUTOMATIC1111's Stable Diffusion WebUI in a Python client so you can generate and edit images programmatically instead of clicking through Gradio.
- Is sdwebuiapi open source?
- Yes — mix1009/sdwebuiapi is open source, released under the MIT license.
- What language is sdwebuiapi written in?
- mix1009/sdwebuiapi is primarily written in Jupyter Notebook.
- How popular is sdwebuiapi?
- mix1009/sdwebuiapi has 1.4k stars on GitHub.
- Where can I find sdwebuiapi?
- mix1009/sdwebuiapi is on GitHub at https://github.com/mix1009/sdwebuiapi.