StabilityAIClient

org.llm4s.imagegeneration.provider.StabilityAIClient

Stability AI API client for image generation.

This client connects to Stability AI's REST API for text-to-image generation. It supports models like Stable Diffusion XL, Stable Diffusion 3, and other Stability AI models.

Value parameters

config

Configuration containing API key, model selection, and timeout settings

Attributes

Example
val config = StabilityAIConfig(
 apiKey = "your-stability-api-key",
 model = "stable-diffusion-xl-1024-v1-0"
)
val client = new StabilityAIClient(config)
val options = ImageGenerationOptions(
 size = ImageSize.Square1024,
 format = ImageFormat.PNG
)
client.generateImage("a beautiful landscape", options) match {
 case Right(image) => println(s"Generated image: $${image.size}")
 case Left(error) => println(s"Error: $${error.message}")
}
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def editImage(imagePath: Path, prompt: String, maskPath: Option[Path], options: ImageEditOptions): Either[ImageGenerationError, Seq[GeneratedImage]]

Edit an existing image based on a prompt and optional mask.

Edit an existing image based on a prompt and optional mask.

Not currently supported for Stability AI provider.

Attributes

Definition Classes
override def editImageAsync(imagePath: Path, prompt: String, maskPath: Option[Path], options: ImageEditOptions)(implicit ec: ExecutionContext): Future[Either[ImageGenerationError, Seq[GeneratedImage]]]

Edit an existing image asynchronously

Edit an existing image asynchronously

Attributes

Definition Classes
override def generateImage(prompt: String, options: ImageGenerationOptions): Either[ImageGenerationError, GeneratedImage]

Generate a single image from a text prompt using Stability AI API.

Generate a single image from a text prompt using Stability AI API.

Value parameters

options

Optional generation parameters like size, format, etc.

prompt

The text description of the image to generate

Attributes

Returns

Either an error or the generated image

Definition Classes
override def generateImageAsync(prompt: String, options: ImageGenerationOptions)(implicit ec: ExecutionContext): Future[Either[ImageGenerationError, GeneratedImage]]

Generate an image asynchronously

Generate an image asynchronously

Attributes

Definition Classes
override def generateImages(prompt: String, count: Int, options: ImageGenerationOptions): Either[ImageGenerationError, Seq[GeneratedImage]]

Generate multiple images from a text prompt using Stability AI API.

Generate multiple images from a text prompt using Stability AI API.

Value parameters

count

Number of images to generate (1-10)

options

Optional generation parameters

prompt

The text description of the images to generate

Attributes

Returns

Either an error or a sequence of generated images

Definition Classes
override def generateImagesAsync(prompt: String, count: Int, options: ImageGenerationOptions)(implicit ec: ExecutionContext): Future[Either[ImageGenerationError, Seq[GeneratedImage]]]

Generate multiple images asynchronously

Generate multiple images asynchronously

Attributes

Definition Classes
override def health(): Either[ImageGenerationError, ServiceStatus]

Check the health/status of the Stability AI API service.

Check the health/status of the Stability AI API service.

Note: Stability AI doesn't provide a dedicated health endpoint, so we use a minimal user account request as a health check.

Attributes

Definition Classes