InstrumentedImageGenerationClient

org.llm4s.imagegeneration.InstrumentedImageGenerationClient

Decorator that wraps an ImageGenerationClient with metrics collection and trace event emission.

Records:

  • observeImageGeneration for every generate/edit call (success or failure)
  • recordImageGenerationCost when pricing is available via ImagePricingRegistry
  • TraceEvent.ImageGenerationCompleted for observability

Note: Cost estimation uses the requested size, not the actual provider-billed dimensions. For models like dall-e-3 that normalize sizes (e.g., mapping non-standard requested sizes to their nearest supported size), the estimate may differ from actual billing. When size is unknown (e.g., edit operations without an explicit size), cost estimation is skipped.

Value parameters

config

Image generation configuration (provides model/provider info)

delegate

The underlying client to delegate actual generation to

metrics

Metrics collector for Prometheus counters/histograms

tracing

Tracing backend for structured event emission

Attributes

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

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 an image from a text prompt

Generate an image from a text prompt

Attributes

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

Generate multiple images from a text prompt

Attributes

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 image generation service

Check the health/status of the image generation service

Attributes

Definition Classes