Skip to main content

AUTOMATIC1111 Stable Diffusion Web UI

Create images with Stable Diffusion using the AUTOMATIC1111/stable-diffusion-webui. You can run the web UI locally or on a remote server.

Setup

  1. Install AUTOMATIC1111/stable-diffusion-webui using the instructions in the stable-diffusion-webui repository.
  2. Start the web UI with the API enabled: ./webui.sh --api (Mac)
    • Tip: --nowebui disables the UI (port changes to 7861)

Model Functions

Examples

Generate Image

Automatic1111ImageGenerationModel API

import { automatic1111, generateImage } from "modelfusion";

const image = await generateImage({
model: automatic1111.ImageGenerator({
model: "aZovyaRPGArtistTools_v4.safetensors",
steps: 30,
sampler: "DPM++ 2M Karras",
width: 512,
height: 512,
}),
prompt: {
prompt:
"(the wicked witch of the west) (style of early 19th century painting)",
negativePrompt:
"poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb", // optional negative prompt
},
});

Configuration

API Configuration

Automatic1111 API Configuration

const api = automatic1111.Api({
baseUrl: {
port: "7861", // example: set port for --nowebui mode
},
// ...
});

const model = automatic1111.ImageGenerator({
api,
// ...
});

Example: Accessing password-protected server

Start the Stable Diffusion web ui server with: ./webui.sh --api --api-auth user:password --api-log --nowebui.

const api = automatic1111.Api({
baseUrl: {
host: "localhost",
port: "7861", // default port when starting with --nowebui
},
headers: {
Authorization: `Basic ${btoa(`${user}:${password}`)}`,
},
});

Prompt Template

Basic text prompt

You an use mapBasicPromptToAutomatic1111Format() to use text prompts with Automatic1111 models. It is available as a shorthand method:

const image = await generateImage({
model: automatic1111
.ImageGenerator({
//...
})
.withTextPrompt(),

prompt:
"the wicked witch of the west in the style of early 19th century painting",
});