top of page

Automatic1111 Stable Diffusion Web API: FAQ

Updated: Jun 5, 2023

Leveraging the built-in REST API that comes with Stable Diffusion Automatic1111

TLDR: 🎨 This blog post helps you to leverage the built-in API that comes with Stable Diffusion Automatic1111. 💡 Provides answers to frequently asked questions.

Today, we'll dive into the world of the AUTOMATIC1111 Stable Diffusion API, exploring its potential and guiding you through the process of using it. We'll introduce you to the API documentation, key endpoints, and some practical examples to help you harness the full potential of AUTOMATIC1111 Stable Diffusion.

Where is the Stable Diffusion API documentation?

Firstly and most importantly, you need to know where you can find it. Automatic1111 uses Swagger for generating the API documentation, and to access the Swagger UI directly, you'll need to have an instance of Automatic1111 running.

With an instance of Automatic1111, you navigate to A1111 in your browser, and simply append /docs to the URL. Like this:

  • https://YOUR-AUTOMATIC1111-SITE/docs

You should see a screen similar to this one.

A screenshot of the A1111 API's Swagger UI

If you don't have an instance of A1111 running, here's Automatic 1111 API Swagger UI as a PDF document:

StableDiffusion v2 - HTTP API - Swagger UI
Download PDF • 568KB

The AUTOMATIC1111 Stable Diffusion API is responsible for user management and authentication, core functionality like text-to-image and image-to-image translations, additional features for custom image processing, model customization and management, and training and preprocessing tasks.

Can I use Custom Scripts via Web API?

How can you use the extensions or other custom scripts with specific parameters when using the AUTOMATIC1111 API?

To invoke custom scripts via the API, such as the scripts that appear in the scripts pull down menu via the A1111 Web UI, you include the "alwayson_scripts" parameter in the JSON request body. You can pass any required parameters for the script using the "args" field. For example, to use the "Asymmetric tiling" extension with specific parameters, you can include the following JSON fields in your request:

"alwayson_scripts": {
  "script_name": {
    "args": [val1, val2, val3, ..., valN]

Related discussions that might be helpful:

Can I specify which model to use?

If you have multiple models in the /workspace/stable-diffusion-webui/models/stable-diffusion/ folder, you can specify which model to use and apply certain settings when making a request to the AUTOMATIC1111 API.

To specify a particular model and apply certain settings for a single request to the AUTOMATIC1111 API, you can use the "override_settings" parameter in your payload. You can add key-value pairs to "override_settings" to specify the desired settings, such as "sd_model_checkpoint". Here's an example of how to do this:

payload = {
    "prompt": "cirno",
    "steps": 20

override_settings = {}
override_settings["filter_nsfw"] = true
override_settings["sd_model_checkpoint"] = "Your Model Name"

override_payload = {
    "override_settings": override_settings

Keep in mind that the value for the model name should correspond to the name of the checkpoint exactly as it is displayed in the web user interface. To view a list of available model checkpoints, you can use the following API endpoint: [GET] /sdapi/v1/sd-models.

Step-by-Step Guide for Running Stable Diffusion API

In the following video tutorial, we provide a comprehensive guide on how to establish a Stable Diffusion API using RunPod Serverless. This engaging and easy-to-follow tutorial is designed to accommodate both beginners and experienced users.

We kick off by:

  • Outlining the prerequisites, from setting up a RunPod account to installing Docker and Git

  • Walking you through running the API with multiple models, including 'text to image' and 'image to image' Stable Diffusion APIs

  • Showing how to modify Docker files to support multiple models

Whether you're new to these tools or looking to advance your skills, this tutorial provides valuable insights and hands-on experience.

Hope this helps.

2,808 views0 comments


bottom of page