Package org.springframework.ai.openai
Class OpenAiImageModel
java.lang.Object
org.springframework.ai.openai.OpenAiImageModel
- All Implemented Interfaces:
ImageModel,Model<ImagePrompt,ImageResponse>
Image Model implementation using the OpenAI Java SDK.
- Author:
- Julien Dubois, Thomas Vitale, Hyunjoon Choi, Christian Tzolov, Mark Pollack
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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.OpenAiImageModel(@Nullable OpenAiImageOptions options) 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 TypeMethodDescriptioncall(ImagePrompt imagePrompt) Executes a method call to the AI model.Gets the image options for this model.voidsetObservationConvention(ImageModelObservationConvention observationConvention) Use the provided convention for reporting observation data
-
Constructor Details
-
OpenAiImageModel
public OpenAiImageModel()Creates a new OpenAiImageModel with default options. -
OpenAiImageModel
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 optionsobservationRegistry- 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 clientoptions- 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 clientobservationRegistry- 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 clientoptions- the image optionsobservationRegistry- the observation registry
-
-
Method Details
-
getOptions
Gets the image options for this model.- Returns:
- the image options
-
call
Description copied from interface:ModelExecutes a method call to the AI model.- Specified by:
callin interfaceImageModel- Specified by:
callin 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
-