Class OpenAiImageModel

java.lang.Object
org.springframework.ai.openai.OpenAiImageModel
All Implemented Interfaces:
ImageModel, Model<ImagePrompt,ImageResponse>

public class OpenAiImageModel extends Object implements ImageModel
OpenAiImageModel is a class that implements the ImageModel interface. It provides a client for calling the OpenAI image generation API.
Since:
0.8.0
Author:
Mark Pollack, Christian Tzolov, Hyunjoon Choi, Thomas Vitale
  • Constructor Details

    • OpenAiImageModel

      public OpenAiImageModel(OpenAiImageApi openAiImageApi)
      Creates an instance of the OpenAiImageModel.
      Parameters:
      openAiImageApi - The OpenAiImageApi instance to be used for interacting with the OpenAI Image API.
      Throws:
      IllegalArgumentException - if openAiImageApi is null
    • OpenAiImageModel

      public OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions options, org.springframework.retry.support.RetryTemplate retryTemplate)
      Initializes a new instance of the OpenAiImageModel.
      Parameters:
      openAiImageApi - The OpenAiImageApi instance to be used for interacting with the OpenAI Image API.
      options - The OpenAiImageOptions to configure the image model.
      retryTemplate - The retry template.
    • OpenAiImageModel

      public OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
      Initializes a new instance of the OpenAiImageModel.
      Parameters:
      openAiImageApi - The OpenAiImageApi instance to be used for interacting with the OpenAI Image API.
      options - The OpenAiImageOptions to configure the image model.
      retryTemplate - The retry template.
      observationRegistry - The ObservationRegistry used for instrumentation.
  • Method Details

    • call

      public ImageResponse call(ImagePrompt imagePrompt)
      Description copied from interface: Model
      Executes a method call to the AI model.
      Specified by:
      call in interface ImageModel
      Specified by:
      call in interface Model<ImagePrompt,ImageResponse>
      Parameters:
      imagePrompt - the request object to be sent to the AI model
      Returns:
      the response from the AI model
    • setObservationConvention

      public void setObservationConvention(ImageModelObservationConvention observationConvention)
      Use the provided convention for reporting observation data
      Parameters:
      observationConvention - The provided convention