Class OpenAiImageModel

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

public class OpenAiImageModel extends Object implements ImageModel
Image Model implementation using the OpenAI Java SDK.
Author:
Julien Dubois, Thomas Vitale, Hyunjoon Choi, Christian Tzolov, Mark Pollack
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new OpenAiImageModel with default options.
    OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient)
    Creates a new OpenAiImageModel with the given OpenAI client.
    OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry)
    Creates a new OpenAiImageModel with the given OpenAI client and observation registry.
    OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable OpenAiImageOptions options)
    Creates a new OpenAiImageModel with the given OpenAI client and options.
    OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAiClient, @Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry)
    Creates a new OpenAiImageModel with all configuration options.
    OpenAiImageModel(@Nullable io.micrometer.observation.ObservationRegistry observationRegistry)
    Creates a new OpenAiImageModel with the given observation registry.
    Creates a new OpenAiImageModel with the given options.
    OpenAiImageModel(@Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry)
    Creates a new OpenAiImageModel with the given options and observation registry.
  • Method Summary

    Modifier and Type
    Method
    Description
    call(ImagePrompt imagePrompt)
    Executes a method call to the AI model.
    Gets the image options for this model.
    void
    Use the provided convention for reporting observation data

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenAiImageModel

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

      public OpenAiImageModel(@Nullable OpenAiImageOptions options)
      Creates a new OpenAiImageModel with the given options.
      Parameters:
      options - the image options
    • OpenAiImageModel

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

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

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

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

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

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

    • getOptions

      public OpenAiImageOptions 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