Skip to main content

Class: StabilityImageProvider

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:164

Implements​

Constructors​

Constructor​

new StabilityImageProvider(): StabilityImageProvider

Returns​

StabilityImageProvider

Properties​

defaultModelId?​

optional defaultModelId: string

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:167

Implementation of​

IImageProvider.defaultModelId


isInitialized​

isInitialized: boolean = false

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:166

Implementation of​

IImageProvider.isInitialized


providerId​

readonly providerId: "stability" = 'stability'

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:165

Implementation of​

IImageProvider.providerId

Methods​

editImage()​

editImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:345

Edits an image with Stability AI, on the endpoint the request needs (Stability's API specification, https://api.stability.ai/v2alpha/openapi):

  • without a mask, image-to-image: /v2beta/stable-image/generate/sd3 with mode=image-to-image, image and strength. The route takes the SD3 models only, and its image and strength are valid in that mode only;
  • with a mask, inpainting: /v2beta/stable-image/edit/inpaint with image and mask (white is repainted, black kept). It takes no model and no strength.

The request's mode is not read: 'outpaint' runs as image-to-image.

Parameters​

request​

ImageEditRequest

Edit request containing the source image, prompt, and optional mask.

Returns​

Promise<ImageGenerationResult>

Generation result with the edited image(s).

Throws​

When the provider is not initialised.

Throws​

When the Stability API returns an HTTP error status.

Implementation of​

IImageProvider.editImage


generateImage()​

generateImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:195

Parameters​

request​

ImageGenerationRequest

Returns​

Promise<ImageGenerationResult>

Implementation of​

IImageProvider.generateImage


initialize()​

initialize(config): Promise<void>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:173

Parameters​

config​

Record<string, unknown>

Returns​

Promise<void>

Implementation of​

IImageProvider.initialize


listAvailableModels()​

listAvailableModels(): Promise<ImageModelInfo[]>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:655

Returns​

Promise<ImageModelInfo[]>

Implementation of​

IImageProvider.listAvailableModels


styleTransferModel()​

styleTransferModel(modelId): string

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:502

The model a style transfer reports: Stability's style-transfer endpoint takes no model, so an empty id and STABILITY_STYLE_TRANSFER_MODEL are the only ones accepted.

Parameters​

modelId​

string

The model the call names, or an empty string.

Returns​

string

Throws​

For any other model.

Implementation of​

IImageProvider.styleTransferModel


transferStyle()​

transferStyle(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:527

Restyles an image after a style reference with Stability AI's style transfer, /v2beta/stable-image/control/style-transfer, which takes the source as init_image and the reference as style_image and answers with one image of 1 MP at the source's aspect ratio (Stability's API reference). strength is sent as style_strength, where 0 leaves the source as it is; the endpoint takes no model and no size.

Before the request: both images must be JPEG, PNG or WebP, the request within 10 MiB, the prompt and negative prompt at most 10,000 characters, the seed an integer from 0 to 4,294,967,294, compositionFidelity from 0 to 1 and changeStrength from 0.1 to 1.

Parameters​

request​

ImageStyleTransferRequest

The source, the reference and the prompt.

Returns​

Promise<ImageGenerationResult>

Generation result with the restyled image.

Throws​

When the provider is not initialised, the model or an argument is refused, the API returns an HTTP error status, or the answer holds no image.

Implementation of​

IImageProvider.transferStyle


upscaleImage()​

upscaleImage(request): Promise<ImageGenerationResult>

Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:443

Upscales an image with Stability AI's fast upscaler, /v2beta/stable-image/upscale/fast, which takes the image alone and returns it at four times its resolution. The request's scale, width and height are not used: no Stability upscaler takes a target size, and the conservative and creative upscalers require a prompt, which an upscale request does not carry (Stability's API specification, https://api.stability.ai/v2alpha/openapi).

Parameters​

request​

ImageUpscaleRequest

Upscale request with the source image.

Returns​

Promise<ImageGenerationResult>

Generation result with the upscaled image.

Throws​

When the provider is not initialised.

Throws​

When the Stability API returns an HTTP error status.

Implementation of​

IImageProvider.upscaleImage