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