Package org.springframework.ai.openai
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>
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 Summary
ConstructorsConstructorDescriptionOpenAiImageModel(OpenAiImageApi openAiImageApi) Creates an instance of the OpenAiImageModel.OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions options, org.springframework.retry.support.RetryTemplate retryTemplate) Initializes a new instance of the OpenAiImageModel.OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions options, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the OpenAiImageModel. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.ai.image.ImageResponsecall(org.springframework.ai.image.ImagePrompt imagePrompt) voidsetObservationConvention(org.springframework.ai.image.observation.ImageModelObservationConvention observationConvention) Use the provided convention for reporting observation data
-
Constructor Details
-
OpenAiImageModel
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:
callin interfaceorg.springframework.ai.image.ImageModel- Specified by:
callin interfaceorg.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
-