Package dev.langchain4j.model.openai
Class OpenAiImageModel
java.lang.Object
dev.langchain4j.model.openai.OpenAiImageModel
- All Implemented Interfaces:
ImageModel
Represents an OpenAI DALL·E models to generate artistic images. Versions 2 and 3 (default) are supported.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionOpenAiImageModel
(String baseUrl, String apiKey, String organizationId, String modelName, String size, String quality, String style, String user, String responseFormat, Duration timeout, Integer maxRetries, Proxy proxy, Boolean logRequests, Boolean logResponses, Boolean withPersisting, Path persistTo, Map<String, String> customHeaders) Instantiates OpenAI DALL·E image processing model. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Given a prompt, generate an image.Given a prompt, generate n images.static OpenAiImageModel
withApiKey
(String apiKey) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.image.ImageModel
edit, edit
-
Constructor Details
-
OpenAiImageModel
public OpenAiImageModel(String baseUrl, String apiKey, String organizationId, String modelName, String size, String quality, String style, String user, String responseFormat, Duration timeout, Integer maxRetries, Proxy proxy, Boolean logRequests, Boolean logResponses, Boolean withPersisting, Path persistTo, Map<String, String> customHeaders) Instantiates OpenAI DALL·E image processing model. Find the parameters description here.- Parameters:
modelName
- dall-e-3 is default onewithPersisting
- generated response will be persisted underjava.io.tmpdir
. The URL withindev.ai4j.openai4j.image.GenerateImagesResponse
will contain the URL to local images then.persistTo
- specifies the local path where the generated image will be downloaded to (in case provided). The URL withindev.ai4j.openai4j.image.GenerateImagesResponse
will contain the URL to local images then.
-
-
Method Details
-
modelName
-
generate
Description copied from interface:ImageModel
Given a prompt, generate an image.- Specified by:
generate
in interfaceImageModel
- Parameters:
prompt
- The prompt to generate an image from.- Returns:
- The generated image Response.
-
generate
Description copied from interface:ImageModel
Given a prompt, generate n images.Not supported by all models; as explicit support is needed to generate different images from the same prompt.
- Specified by:
generate
in interfaceImageModel
- Parameters:
prompt
- The prompt to generate images from.n
- The number of images to generate.- Returns:
- The generated images Response.
-
builder
-
withApiKey
Deprecated, for removal: This API element is subject to removal in a future version.Please usebuilder()
instead, and explicitly set the model name and, if necessary, other parameters. The default value for the model name will be removed in future releases!
-
builder()
instead, and explicitly set the model name and, if necessary, other parameters.