Class OpenAiImageModel

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

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

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
  • 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
     
    org.springframework.ai.image.ImageResponse
    call(org.springframework.ai.image.ImagePrompt imagePrompt)
     
    Gets the image options for this model.
    void
    setObservationConvention(org.springframework.ai.image.observation.ImageModelObservationConvention observationConvention)
    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

    • builder

      public static OpenAiImageModel.Builder builder()
    • getOptions

      public OpenAiImageOptions getOptions()
      Gets the image options for this model.
      Returns:
      the image options
    • call

      public org.springframework.ai.image.ImageResponse call(org.springframework.ai.image.ImagePrompt imagePrompt)
      Specified by:
      call in interface org.springframework.ai.image.ImageModel
      Specified by:
      call in interface org.springframework.ai.model.Model<org.springframework.ai.image.ImagePrompt,org.springframework.ai.image.ImageResponse>
    • setObservationConvention

      public void setObservationConvention(org.springframework.ai.image.observation.ImageModelObservationConvention observationConvention)
      Use the provided convention for reporting observation data
      Parameters:
      observationConvention - The provided convention