Skip to main content

Class: StableDiffusionLocalProvider

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:111

Implements

Constructors

Constructor

new StableDiffusionLocalProvider(fetchImpl?): StableDiffusionLocalProvider

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:125

Parameters

fetchImpl?

{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Returns

StableDiffusionLocalProvider

Properties

defaultModelId?

optional defaultModelId: string

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:114

Implementation of

IImageProvider.defaultModelId


isInitialized

isInitialized: boolean = false

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:113

Implementation of

IImageProvider.isInitialized


providerId

readonly providerId: "stable-diffusion-local" = 'stable-diffusion-local'

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:112

Implementation of

IImageProvider.providerId

Methods

editImage()

editImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:441

Edits an image using the A1111 img2img endpoint.

Routes to /sdapi/v1/img2img which accepts init_images (base64 array) and denoising_strength to control how much the output deviates from the source. When a mask is provided, A1111 performs inpainting on the white regions of the mask.

Parameters

request

ImageEditRequest

Edit request with source image buffer and prompt.

Returns

Promise<ImageGenerationResult>

Generation result containing the edited image(s).

Throws

When the provider is not initialised.

Throws

When the A1111 API returns an HTTP error.

Implementation of

IImageProvider.editImage


generateImage()

generateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:204

Generate one or more images from a text prompt.

Dispatches to the detected backend (A1111 or ComfyUI).

Parameters

request

ImageGenerationRequest

Returns

Promise<ImageGenerationResult>

Throws

When the provider has not been initialised.

Implementation of

IImageProvider.generateImage


initialize()

initialize(config): Promise<void>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:142

Initialise the provider.

Accepts baseURL / baseUrl / baseurl from the config bag and auto-detects the backend by probing known endpoints.

Parameters

config

Record<string, unknown>

Provider configuration. Must contain a baseURL string.

Returns

Promise<void>

Throws

When no baseURL is supplied.

Implementation of

IImageProvider.initialize


listAvailableModels()

listAvailableModels(): Promise<ImageModelInfo[]>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:580

Lists available checkpoint models from an A1111 backend.

ComfyUI does not expose a simple model listing endpoint, so an empty array is returned in that case.

Returns

Promise<ImageModelInfo[]>

Implementation of

IImageProvider.listAvailableModels


shutdown()

shutdown(): Promise<void>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:610

Resets initialisation state. The local backend keeps running independently.

Returns

Promise<void>

Implementation of

IImageProvider.shutdown


upscaleImage()

upscaleImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/media/images/providers/StableDiffusionLocalProvider.ts:524

Upscales an image using the A1111 extras single-image endpoint.

Routes to /sdapi/v1/extra-single-image which accepts a base64 image, an upscaler name, and a resize factor.

Parameters

request

ImageUpscaleRequest

Upscale request with source image and desired scale.

Returns

Promise<ImageGenerationResult>

Generation result containing the upscaled image.

Throws

When the provider is not initialised.

Throws

When the A1111 API returns an HTTP error.

Implementation of

IImageProvider.upscaleImage