Skip to main content

Class: StabilityImageGenerationModel

Create an image generation model that calls the Stability AI image generation API.

See

https://api.stability.ai/docs#tag/v1generation/operation/textToImage

Example

const image = await generateImage(
stability.ImageGenerator({
model: "stable-diffusion-v1-6",
cfgScale: 7,
clipGuidancePreset: "FAST_BLUE",
height: 512,
width: 512,
steps: 30,
})
[
{ text: "the wicked witch of the west" },
{ text: "style of early 19th century painting", weight: 0.5 },
]
);

Hierarchy

Implements

Accessors

modelInformation

get modelInformation(): ModelInformation

Returns

ModelInformation

Implementation of

ImageGenerationModel.modelInformation

Inherited from

AbstractModel.modelInformation

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:17


modelName

get modelName(): StabilityImageGenerationModelType

Returns

StabilityImageGenerationModelType

Overrides

AbstractModel.modelName

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:149


settingsForEvent

get settingsForEvent(): Partial<StabilityImageGenerationSettings>

Returns settings that should be recorded in observability events. Security-related settings (e.g. API keys) should not be included here.

Returns

Partial<StabilityImageGenerationSettings>

Implementation of

ImageGenerationModel.settingsForEvent

Overrides

AbstractModel.settingsForEvent

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:195

Constructors

constructor

new StabilityImageGenerationModel(settings): StabilityImageGenerationModel

Parameters

NameType
settingsStabilityImageGenerationSettings

Returns

StabilityImageGenerationModel

Overrides

AbstractModel&lt;StabilityImageGenerationSettings&gt;.constructor

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:143

Methods

callAPI

callAPI(input, callOptions): Promise<{ artifacts: { base64: string ; finishReason: "ERROR" | "SUCCESS" | "CONTENT_FILTERED" ; seed: number }[] }>

Parameters

NameType
inputStabilityImageGenerationPrompt
callOptionsFunctionCallOptions

Returns

Promise<{ artifacts: { base64: string ; finishReason: "ERROR" | "SUCCESS" | "CONTENT_FILTERED" ; seed: number }[] }>

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:153


doGenerateImages

doGenerateImages(prompt, callOptions): Promise<{ base64Images: string[] ; rawResponse: { artifacts: { base64: string ; finishReason: "ERROR" | "SUCCESS" | "CONTENT_FILTERED" ; seed: number }[] } }>

Parameters

NameType
promptStabilityImageGenerationPrompt
callOptionsFunctionCallOptions

Returns

Promise<{ base64Images: string[] ; rawResponse: { artifacts: { base64: string ; finishReason: "ERROR" | "SUCCESS" | "CONTENT_FILTERED" ; seed: number }[] } }>

Implementation of

ImageGenerationModel.doGenerateImages

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:209


withPromptTemplate

withPromptTemplate<INPUT_PROMPT>(promptTemplate): PromptTemplateImageGenerationModel<INPUT_PROMPT, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, StabilityImageGenerationModel>

Type parameters

Name
INPUT_PROMPT

Parameters

NameType
promptTemplatePromptTemplate<INPUT_PROMPT, StabilityImageGenerationPrompt>

Returns

PromptTemplateImageGenerationModel<INPUT_PROMPT, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, StabilityImageGenerationModel>

Implementation of

ImageGenerationModel.withPromptTemplate

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:225


withSettings

withSettings(additionalSettings): StabilityImageGenerationModel

The withSettings method creates a new model with the same configuration as the original model, but with the specified settings changed.

Parameters

NameType
additionalSettingsPartial<StabilityImageGenerationSettings>

Returns

StabilityImageGenerationModel

Example

const model = new OpenAICompletionModel({
model: "gpt-3.5-turbo-instruct",
maxGenerationTokens: 500,
});

const modelWithMoreTokens = model.withSettings({
maxGenerationTokens: 1000,
});

Implementation of

ImageGenerationModel.withSettings

Overrides

AbstractModel.withSettings

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:239


withTextPrompt

withTextPrompt(): PromptTemplateImageGenerationModel<string, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, StabilityImageGenerationModel>

Returns

PromptTemplateImageGenerationModel<string, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, StabilityImageGenerationModel>

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:221

Properties

provider

Readonly provider: "stability"

Overrides

AbstractModel.provider

Defined in

packages/modelfusion/src/model-provider/stability/StabilityImageGenerationModel.ts:147


settings

Readonly settings: StabilityImageGenerationSettings

Implementation of

ImageGenerationModel.settings

Inherited from

AbstractModel.settings

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:7