InstrumentedImageGenerationClient
org.llm4s.imagegeneration.InstrumentedImageGenerationClient
class InstrumentedImageGenerationClient(delegate: ImageGenerationClient, config: ImageGenerationConfig, metrics: MetricsCollector, tracing: Tracing) extends ImageGenerationClient
Decorator that wraps an ImageGenerationClient with metrics collection and trace event emission.
Records:
- the ImageMetrics of every generate/edit call (success or failure), through the collector's generic
incrementandobserve - ImageMetrics.CostUsd when pricing is available via ImagePricingRegistry
TraceEvent.ImageGenerationCompletedfor 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; any backend that exports generic metrics exports these
- tracing
-
Tracing backend for structured event emission
Attributes
- Source
- InstrumentedImageGenerationClient.scala
- Graph
-
- Supertypes
Members list
In this article
