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>
Image Model implementation using the OpenAI Java SDK.
- Author:
- Julien Dubois, Thomas Vitale, Hyunjoon Choi, Christian Tzolov, Mark Pollack, guan xu
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable OpenAiImageOptions options) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAiClient, @Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable OpenAiImageOptions options) Deprecated.usebuilder()instead.OpenAiImageModel(@Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiImageModel.Builderbuilder()org.springframework.ai.image.ImageResponsecall(org.springframework.ai.image.ImagePrompt imagePrompt) Gets the image options for this model.voidsetObservationConvention(org.springframework.ai.image.observation.ImageModelObservationConvention observationConvention) Use the provided convention for reporting observation data
-
Constructor Details
-
OpenAiImageModel
Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with default options. -
OpenAiImageModel
Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given options.- Parameters:
options- the image options
-
OpenAiImageModel
@Deprecated public OpenAiImageModel(@Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given observation registry.- Parameters:
observationRegistry- the observation registry
-
OpenAiImageModel
@Deprecated public OpenAiImageModel(@Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given options and observation registry.- Parameters:
options- the image optionsobservationRegistry- the observation registry
-
OpenAiImageModel
Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given OpenAI client.- Parameters:
openAIClient- the OpenAI client
-
OpenAiImageModel
@Deprecated public OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable OpenAiImageOptions options) Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given OpenAI client and options.- Parameters:
openAIClient- the OpenAI clientoptions- the image options
-
OpenAiImageModel
@Deprecated public OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAIClient, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with the given OpenAI client and observation registry.- Parameters:
openAIClient- the OpenAI clientobservationRegistry- the observation registry
-
OpenAiImageModel
@Deprecated public OpenAiImageModel(@Nullable com.openai.client.OpenAIClient openAiClient, @Nullable OpenAiImageOptions options, @Nullable io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.usebuilder()instead.Creates a new OpenAiImageModel with all configuration options.- Parameters:
openAiClient- the OpenAI clientoptions- the image optionsobservationRegistry- the observation registry
-
-
Method Details
-
builder
-
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:
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
-
builder()instead.