Class OpenAiSdkImageModel

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

public class OpenAiSdkImageModel extends Object implements ImageModel
Image Model implementation using the OpenAI Java SDK.
Author:
Julien Dubois
  • Constructor Details

    • OpenAiSdkImageModel

      public OpenAiSdkImageModel()
      Creates a new OpenAiSdkImageModel with default options.
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(OpenAiSdkImageOptions options)
      Creates a new OpenAiSdkImageModel with the given options.
      Parameters:
      options - the image options
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(io.micrometer.observation.ObservationRegistry observationRegistry)
      Creates a new OpenAiSdkImageModel with the given observation registry.
      Parameters:
      observationRegistry - the observation registry
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(OpenAiSdkImageOptions options, io.micrometer.observation.ObservationRegistry observationRegistry)
      Creates a new OpenAiSdkImageModel with the given options and observation registry.
      Parameters:
      options - the image options
      observationRegistry - the observation registry
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(com.openai.client.OpenAIClient openAIClient)
      Creates a new OpenAiSdkImageModel with the given OpenAI client.
      Parameters:
      openAIClient - the OpenAI client
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(com.openai.client.OpenAIClient openAIClient, OpenAiSdkImageOptions options)
      Creates a new OpenAiSdkImageModel with the given OpenAI client and options.
      Parameters:
      openAIClient - the OpenAI client
      options - the image options
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(com.openai.client.OpenAIClient openAIClient, io.micrometer.observation.ObservationRegistry observationRegistry)
      Creates a new OpenAiSdkImageModel with the given OpenAI client and observation registry.
      Parameters:
      openAIClient - the OpenAI client
      observationRegistry - the observation registry
    • OpenAiSdkImageModel

      public OpenAiSdkImageModel(com.openai.client.OpenAIClient openAiClient, OpenAiSdkImageOptions options, io.micrometer.observation.ObservationRegistry observationRegistry)
      Creates a new OpenAiSdkImageModel with all configuration options.
      Parameters:
      openAiClient - the OpenAI client
      options - the image options
      observationRegistry - the observation registry
  • Method Details

    • getOptions

      public OpenAiSdkImageOptions getOptions()
      Gets the image options for this model.
      Returns:
      the image options
    • 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