← All @molecule/* packages · App templates
@molecule/api-ai-image-generation-stabilityProvider bond · ai-image-generation · API (Node) · v1.0.1 · Apache-2.0
Stability AI image generation provider for molecule.dev — Stable Diffusion 3, Stable Image Core/Ultra
npm install @molecule/api-ai-image-generation-stabilitynpm · Source on GitHub · Implements @molecule/api-ai-image-generation
@molecule/api-ai-image-generation-stability is a provider bond on the API (Node) side: it implements the ai-image-generation core interface (@molecule/api-ai-image-generation) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
Works with: @molecule/api-ai-image-generation, @molecule/api-secrets
Secrets: STABILITY_API_KEY
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Stability AI image generation provider for molecule.dev.
provider
npm install @molecule/api-ai-image-generation-stability @molecule/api-ai-image-generation @molecule/api-secrets
StabilityConfigConfiguration for the Stability AI image generation provider.
interface StabilityConfig {
/** Stability AI API key. Defaults to STABILITY_API_KEY env var. */
apiKey?: string
/** Default generation model. Defaults to 'sd3.5-large'. */
defaultModel?: string
/** Base URL for the Stability AI API. Defaults to 'https://api.stability.ai'. */
baseUrl?: string
/** Maximum number of retry attempts for transient failures. Defaults to 3. */
maxRetries?: number
}
StabilityAIProviderStability AI image generation provider.
Supports Stable Diffusion 3 (sd3.5-large, sd3.5-medium, sd3-large, etc.), Stable Image Core, and Stable Image Ultra models via the Stability AI REST API.
createProvider(config)Create a Stability AI image generation provider.
function createProvider(config?: StabilityConfig): StabilityAIProvider
config — Provider configuration. API key defaults to STABILITY_API_KEY env var.Returns: A configured StabilityAIProvider instance.
aiImageGenerationStabilitySecretDefinitionsSecret definitions required by the Stability AI image generation bond.
const aiImageGenerationStabilitySecretDefinitions: SecretDefinition[]
providerThe provider implementation.
const provider: AIImageGenerationProvider
Implements @molecule/api-ai-image-generation interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-ai-image-generation'
import { provider } from '@molecule/api-ai-image-generation-stability'
export function setupAiImageGenerationStability(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-ai-image-generation >=1.0.1@molecule/api-secrets ^1.0.1STABILITY_API_KEY (required) — Stability AI API key
sk-...@molecule/api-ai-image-generation@molecule/api-secretsIntegration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip:
img element actually
decoded (its naturalWidth/naturalHeight are non-zero) and the picture
visibly reflects the prompt (a "red bicycle" prompt shows a red bicycle).img src (and any saved record) points at the app's uploads/storage, not
the provider's temporary URL. Provider url results expire — reload the
page (or revisit the record later) and the image must still load. Download
the provider result server-side and persist it (uploads bond); never
hotlink the provider URL — it 404s later and can leak the API request
context. (base64/data results must likewise be saved, not held only in
the response.)n) of N renders N
images. If the UI exposes no such options, this box is n/a — say so.