OpenAIImageClient

org.llm4s.imagegeneration.provider.OpenAIImageClient

OpenAI DALL-E API client for image generation.

This client connects to OpenAI's DALL-E API for text-to-image generation. It supports both DALL-E 2 and DALL-E 3 models with their respective capabilities and limitations.

Value parameters

config

Configuration containing API key, model selection, and timeout settings

Attributes

Example
val config = OpenAIConfig(
 apiKey = "your-openai-api-key",
 model = "dall-e-2"  // or "dall-e-3"
)
val client = new OpenAIImageClient(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 generateImage(prompt: String, options: ImageGenerationOptions): Either[ImageGenerationError, GeneratedImage]

Generate a single image from a text prompt using OpenAI DALL-E API.

Generate a single image from a text prompt using OpenAI DALL-E 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 generateImages(prompt: String, count: Int, options: ImageGenerationOptions): Either[ImageGenerationError, Seq[GeneratedImage]]

Generate multiple images from a text prompt using OpenAI DALL-E API.

Generate multiple images from a text prompt using OpenAI DALL-E API.

Note: DALL-E 3 only supports generating 1 image at a time.

Value parameters

count

The number of images to generate (1-10 for DALL-E 2, 1 for DALL-E 3)

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 health(): Either[ImageGenerationError, ServiceStatus]

Check the health/status of the OpenAI API service.

Check the health/status of the OpenAI API service.

Note: OpenAI doesn't provide a dedicated health endpoint, so we use a minimal models list request as a health check.

Attributes

Definition Classes