Class StabilityImageProvider

Implements

Constructors

Methods

  • 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.

  • 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

    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.

Properties

providerId: "stability" = 'stability'
isInitialized: boolean = false
defaultModelId?: string