Class: StabilityImageProvider
Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:164
Implements
Constructors
Constructor
new StabilityImageProvider():
StabilityImageProvider
Returns
StabilityImageProvider
Properties
defaultModelId?
optionaldefaultModelId:string
Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:167
Implementation of
isInitialized
isInitialized:
boolean=false
Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:166
Implementation of
providerId
readonlyproviderId:"stability"='stability'
Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:165
Implementation of
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/sd3withmode=image-to-image,imageandstrength. The route takes the SD3 models only, and itsimageandstrengthare valid in that mode only; - with a mask, inpainting:
/v2beta/stable-image/edit/inpaintwithimageandmask(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
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
generateImage()
generateImage(
request):Promise<ImageGenerationResult>
Defined in: packages/agentos/src/io/media/images/providers/StabilityImageProvider.ts:195
Parameters
request
Returns
Promise<ImageGenerationResult>
Implementation of
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
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
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
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
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.