Documentation
¶
Overview ¶
Package stability wraps Stability AI's image generation REST API.
NewImageModel targets the v2beta /stable-image/generate endpoints (ultra, core, sd3, etc.). Per-model knobs (aspect_ratio, negative_prompt, seed, style_preset, output_format) ride through the typed image.Options fields plus extension-threaded params. cfg_scale belongs only to SD 3.5; the resolved model, including a per-call override, determines admission. Unknown style_preset values are rejected before transport, while omission leaves the service default intact.
Stability's edit / upscale / control / video surfaces ship at sibling paths under /v2beta but require a different request shape; they're not modeled here.
Filtered generations. The adapter requests the JSON envelope so it can read finish_reason, because a generation the safety classifier stops still answers 200 with base64 bytes and those bytes are the classifier's stand-in, not the requested image. CONTENT_FILTERED is returned as an error, as is any finish_reason this adapter cannot classify.
See https://platform.stability.ai/docs/api-reference for the full reference.
Index ¶
Constants ¶
const ( RequestExtensionKey = Provider + "/request" ResponseExtensionKey = Provider + "/response" // DefaultBaseURL is Stability AI's current Stable Image REST endpoint. DefaultBaseURL = "https://api.stability.ai/v2beta" // ResponseModeImage requests raw image bytes in the response body. ResponseModeImage = "image/*" // ResponseModeJSON requests a JSON envelope holding base64 bytes plus // the finish reason and the seed actually used (only reachable in // JSON mode). ResponseModeJSON = "application/json" )
const ( ModelCore = "stable-image-core" ModelUltra = "stable-image-ultra" ModelSD3Point5Large = "sd3.5-large" ModelSD3Point5LargeTurbo = "sd3.5-large-turbo" ModelSD3Point5Medium = "sd3.5-medium" ModelSD3Point5Flash = "sd3.5-flash" )
const (
Provider = "stability"
)
Provider is the stable backend name for host-side attribution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageModel ¶
type ImageModel struct {
// contains filtered or unexported fields
}
ImageModel wraps Stability AI's Stable Image / SD3 endpoints.
Stability uses an aspect-ratio code ("1:1" / "16:9" / ...) rather than per-pixel W×H sizes — Core/Ultra render at a fixed total pixel budget. Scope's Width/Height options are intentionally NOT translated to an aspect ratio; set aspect_ratio under RequestExtensionKey when control is needed.
image.Options.Model selects Core, Ultra, or one exact SD 3.5 model; the adapter derives the official endpoint and request model field from it.
func NewImageModel ¶
func NewImageModel(ctx context.Context, config ImageModelConfig) (*ImageModel, error)