Class WatsonxGatewayImageModel
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxGatewayImageModel
- All Implemented Interfaces:
ImageModel
An
ImageModel implementation that integrates the IBM watsonx.ai Model Gateway with LangChain4j.
Example usage:
ImageModel imageModel = WatsonxGatewayImageModel.builder()
.baseUrl("https://...") // or use CloudRegion
.apiKey("...")
.modelName("gpt-image-1")
.build();
Image image = imageModel.generate("A futuristic city at sunset").content();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingWatsonxGatewayImageModelinstances with configurable parameters. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Returns a newWatsonxGatewayImageModel.Builderinstance.Generates a single image from the given prompt, using the parameters set on the builder.Generatesnimages from the given prompt, using the parameters set on the builder.Generates images from the given prompt, using the specifiedModelGatewayImageParameters.Returns the id of the gateway model used to generate the images.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ImageModel
edit, edit
-
Method Details
-
modelName
Returns the id of the gateway model used to generate the images.- Returns:
- the model id
-
generate
Generates a single image from the given prompt, using the parameters set on the builder.- Specified by:
generatein interfaceImageModel- Parameters:
prompt- the description of the image to generate- Returns:
- the generated image
-
generate
Generatesnimages from the given prompt, using the parameters set on the builder.- Specified by:
generatein interfaceImageModel- Parameters:
prompt- the description of the images to generaten- the number of images to generate, from 1 to 10- Returns:
- the generated images
-
generate
public Response<List<Image>> generate(String prompt, com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters parameters) Generates images from the given prompt, using the specifiedModelGatewayImageParameters.The given parameters replace the ones set on the builder, they are not merged with them.
- Parameters:
prompt- the description of the images to generateparameters- the image parameters to use, ornullto use the ones set on the builder- Returns:
- the generated images
-
builder
Returns a newWatsonxGatewayImageModel.Builderinstance.Example usage:
ImageModel imageModel = WatsonxGatewayImageModel.builder() .baseUrl("https://...") // or use CloudRegion .apiKey("...") .modelName("gpt-image-1") .build();- Returns:
WatsonxGatewayImageModel.Builderinstance.
-