Package org.springframework.ai.openai
Class OpenAiImageModel
java.lang.Object
org.springframework.ai.openai.OpenAiImageModel
- All Implemented Interfaces:
ImageModel
,Model<ImagePrompt,
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
ConstructorDescriptionOpenAiImageModel
(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 TypeMethodDescriptioncall
(ImagePrompt imagePrompt) Executes a method call to the AI model.void
setObservationConvention
(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
Description copied from interface:Model
Executes a method call to the AI model.- Specified by:
call
in interfaceImageModel
- Specified by:
call
in interfaceModel<ImagePrompt,
ImageResponse> - Parameters:
imagePrompt
- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention
- The provided convention
-