org.llm4s.imagegeneration

Members list

Type members

Classlikes

case class GeneratedImage(data: String, format: ImageMediaType, size: ImageSize, createdAt: Instant, prompt: String, seed: Option[Long], filePath: Option[Path], url: Option[String])

Represents a generated image

Represents a generated image

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait HealthStatus

Service health status

Service health status

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Degraded
object Healthy
object Unhealthy
object Unknown
object HealthStatus

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class HuggingFaceConfig(apiKey: Secret, model: String, timeout: FiniteDuration) extends ImageGenerationConfig

Configuration for the HuggingFace Inference API.

Configuration for the HuggingFace Inference API.

Value parameters

apiKey

Your HuggingFace API token. This is required for authentication.

model

The identifier of the model to use on the HuggingFace Hub, e.g., "runwayml/stable-diffusion-v1-5".

timeout

Request timeout. Defaults to a higher value suitable for cloud APIs.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ImageEditOptions(size: Option[ImageSize], n: Int, providerOptions: Option[ProviderImageEditOptions])

Options for image editing

Options for image editing

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
sealed trait ImageGenerationError extends LLMError

Why an image generation call failed.

Why an image generation call failed.

An org.llm4s.error.LLMError, so the client methods can return org.llm4s.error.CancelledError when their thread is interrupted - the contract of every llm4s client - next to these cases: they return Either[LLMError, _].

Every case says whether trying again can help, with a marker: LLMError.isRecoverable (and the retry policies built on it) is true only for a org.llm4s.error.RecoverableError, and every other case is a org.llm4s.error.NonRecoverableError. Recoverable: ImageRateLimitError, and an ImageServiceError whose status is transient (see ImageServiceError.isTransientStatus). Everything else is not: a rejected credential, request or prompt gets the same answer on the next call, and an ImageUnknownError is not retried blindly.

The cases that would share a name with an org.llm4s.error type carry an Image prefix (ImageAuthenticationError, ImageRateLimitError, ImageServiceError, ImageValidationError, ImageUnknownError): both families are LLMErrors, so a match on the wrong one would compile and never fire.

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
case class ImageGenerationOptions(size: ImageSize, format: ImageMediaType, seed: Option[Long], guidanceScale: Double, inferenceSteps: Int, negativePrompt: Option[String], samplerName: Option[String], quality: Option[String], style: Option[String], responseFormat: Option[String], outputFormat: Option[String], background: Option[String], outputCompression: Option[Int], user: Option[String])

Options for image generation

Options for image generation

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Providers for image generation

Providers for image generation

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object DALLE
object HuggingFace
object StabilityAI

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Registry of image generation model pricing.

Registry of image generation model pricing.

Provides per-image cost lookup for supported image generation models. Costs are in USD per image and vary by model, size, and quality.

Pricing sources:

Attributes

See also

org.llm4s.model.ModelPricing for LLM token-based pricing

Supertypes
class Object
trait Matchable
class Any
Self type
case class ImageRateLimitError(message: String) extends ImageGenerationError, RecoverableError

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

The provider's service failed or refused the call, with the HTTP status it answered (0 when it did not answer at all, as in a failed health check).

The provider's service failed or refused the call, with the HTTP status it answered (0 when it did not answer at all, as in a failed health check).

Whether trying again can help follows from the status, which a class cannot express by itself, so there are two cases behind this type and ImageServiceError.apply picks one: a transient status gives a org.llm4s.error.RecoverableError, any other a org.llm4s.error.NonRecoverableError. Build it with ImageServiceError(message, status) and match it with case ImageServiceError(message, status).

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ImageSize

Image size enumeration

Image size enumeration

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Auto
class Custom
object Square1024
object Square512
Show all
object ImageSize

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
ImageSize.type
case class ImageUnknownError(throwable: Throwable) extends ImageGenerationError, NonRecoverableError

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ImageValidationError(message: String) extends ImageGenerationError, NonRecoverableError

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

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

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

Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class InvalidPromptError(message: String) extends ImageGenerationError, NonRecoverableError

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class OpenAIConfig(apiKey: Secret, model: String, baseUrl: String, timeout: FiniteDuration) extends ImageGenerationConfig

Configuration for OpenAI DALL-E API.

Configuration for OpenAI DALL-E API.

Value parameters

apiKey

Your OpenAI API key. This is required for authentication.

model

The DALL-E model version to use (dall-e-2 or dall-e-3).

timeout

Request timeout.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Provider-specific edit options; keeps shared API provider-agnostic.

Provider-specific edit options; keeps shared API provider-agnostic.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class OpenAI

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class RejectedImageServiceError(message: String, statusCode: Int) extends ImageServiceError, NonRecoverableError

An ImageServiceError the provider refused for good: the same call gets the same answer.

An ImageServiceError the provider refused for good: the same call gets the same answer.

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ServiceStatus(status: HealthStatus, message: String, lastChecked: Instant, queueLength: Option[Int], averageGenerationTime: Option[FiniteDuration])

Represents the status of the image generation service

Represents the status of the image generation service

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class StabilityAIConfig(apiKey: Secret, model: String, baseUrl: String, timeout: FiniteDuration) extends ImageGenerationConfig

Configuration for Stability AI API.

Configuration for Stability AI API.

Value parameters

apiKey

Your Stability AI API key. This is required for authentication.

baseUrl

Base URL for Stability AI API (default: https://api.stability.ai).

model

The engine/model ID to use (e.g., "stable-diffusion-xl-1024-v1-0", "stable-diffusion-v1-6").

timeout

Request timeout.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class StableDiffusionConfig(baseUrl: String, apiKey: Option[Secret], model: String, timeout: FiniteDuration) extends ImageGenerationConfig

Configuration for Stable Diffusion

Configuration for Stable Diffusion

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class TransientImageServiceError(message: String, statusCode: Int) extends ImageServiceError, RecoverableError

An ImageServiceError with a transient status: trying again can help.

An ImageServiceError with a transient status: trying again can help.

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class UnsupportedOperation(message: String) extends ImageGenerationError, NonRecoverableError

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all