Class WatsonxGatewayImageModel.Builder
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxGatewayImageModel.Builder
- Enclosing class:
WatsonxGatewayImageModel
Builder class for constructing
WatsonxGatewayImageModel instances with configurable parameters.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionSets the IBM Cloud API key used to generate IAM access tokens for authentication.authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator) Sets a customAuthenticatorfor generating bearer tokens.background(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Background background) Sets the background of the generated images.background(String background) Sets the background of the generated images as a raw string, for the values thatModelGatewayImageParameters.Backgrounddoes not cover yet.baseUrl(com.ibm.watsonx.ai.CloudRegion baseUrl) Sets the IBM watsonx.ai endpoint from a predefinedCloudRegion.Sets the base URL of the IBM watsonx.ai API.Sets the base URL of the IBM watsonx.ai API as aURI.build()httpClient(HttpClient httpClient) Sets a customHttpClientto use for all API calls.logRequests(Boolean logRequests) Enables debug logging of request bodies sent to the watsonx.ai API.logResponses(Boolean logResponses) Enables debug logging of response bodies received from the watsonx.ai API.Sets the gateway image model id, e.g.moderation(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Moderation moderation) Sets how strictly the generated images are filtered,ModelGatewayImageParameters.Moderation.LOWbeing the least restrictive.moderation(String moderation) Sets how strictly the generated images are filtered as a raw string, for the values thatModelGatewayImageParameters.Moderationdoes not cover yet.outputCompression(Integer outputCompression) Sets the compression level of the generated images, from 0 to 100.outputFormat(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.OutputFormat outputFormat) Sets the file format of the generated images.outputFormat(String outputFormat) Sets the file format of the generated images as a raw string, for the formats thatModelGatewayImageParameters.OutputFormatdoes not cover yet.quality(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Quality quality) Sets the quality of the generated images.Sets the quality of the generated images as a raw string, for the values thatModelGatewayImageParameters.Qualitydoes not cover yet.responseFormat(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.ResponseFormat responseFormat) Sets how the generated images are returned, as a link withModelGatewayImageParameters.ResponseFormat.URLor as Base64 data withModelGatewayImageParameters.ResponseFormat.B64_JSON.responseFormat(String responseFormat) Sets how the generated images are returned as a raw string, for the formats thatModelGatewayImageParameters.ResponseFormatdoes not cover yet.size(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Size size) Sets the dimensions of the generated images.Sets the dimensions of the generated images as a raw string, e.g.style(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Style style) Sets the visual style of the generated images.Sets the visual style of the generated images as a raw string, for the values thatModelGatewayImageParameters.Styledoes not cover yet.Sets the HTTP request timeout.Sets the identifier of the end user, used for abuse monitoring.verifySsl(boolean verifySsl) Controls whether SSL certificate verification is performed.Sets the watsonx.ai API version date, e.g.
-
Field Details
-
baseUrl
-
version
-
apiKey
-
logRequests
-
logResponses
-
timeout
-
authenticator
protected com.ibm.watsonx.ai.core.auth.Authenticator authenticator -
httpClient
-
verifySsl
protected boolean verifySsl
-
-
Method Details
-
modelName
Sets the gateway image model id, e.g."gpt-image-1".- Parameters:
modelName- the model id- Returns:
this
-
background
public WatsonxGatewayImageModel.Builder background(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Background background) Sets the background of the generated images. Transparency requires an output format that supports it, soModelGatewayImageParameters.OutputFormat.PNGorModelGatewayImageParameters.OutputFormat.WEBP.- Parameters:
background- theModelGatewayImageParameters.Background- Returns:
this
-
background
Sets the background of the generated images as a raw string, for the values thatModelGatewayImageParameters.Backgrounddoes not cover yet.- Parameters:
background- the background- Returns:
this
-
moderation
public WatsonxGatewayImageModel.Builder moderation(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Moderation moderation) Sets how strictly the generated images are filtered,ModelGatewayImageParameters.Moderation.LOWbeing the least restrictive.- Parameters:
moderation- theModelGatewayImageParameters.Moderation- Returns:
this
-
moderation
Sets how strictly the generated images are filtered as a raw string, for the values thatModelGatewayImageParameters.Moderationdoes not cover yet.- Parameters:
moderation- the moderation level- Returns:
this
-
outputCompression
Sets the compression level of the generated images, from 0 to 100. Only theModelGatewayImageParameters.OutputFormat.JPEGandModelGatewayImageParameters.OutputFormat.WEBPformats accept it.- Parameters:
outputCompression- the compression level- Returns:
this
-
outputFormat
public WatsonxGatewayImageModel.Builder outputFormat(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.OutputFormat outputFormat) Sets the file format of the generated images.- Parameters:
outputFormat- theModelGatewayImageParameters.OutputFormat- Returns:
this
-
outputFormat
Sets the file format of the generated images as a raw string, for the formats thatModelGatewayImageParameters.OutputFormatdoes not cover yet.- Parameters:
outputFormat- the output format- Returns:
this
-
quality
public WatsonxGatewayImageModel.Builder quality(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Quality quality) Sets the quality of the generated images.- Parameters:
quality- theModelGatewayImageParameters.Quality- Returns:
this
-
quality
Sets the quality of the generated images as a raw string, for the values thatModelGatewayImageParameters.Qualitydoes not cover yet.- Parameters:
quality- the image quality- Returns:
this
-
responseFormat
public WatsonxGatewayImageModel.Builder responseFormat(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.ResponseFormat responseFormat) Sets how the generated images are returned, as a link withModelGatewayImageParameters.ResponseFormat.URLor as Base64 data withModelGatewayImageParameters.ResponseFormat.B64_JSON. Only the models that support it accept this value.- Parameters:
responseFormat- theModelGatewayImageParameters.ResponseFormat- Returns:
this
-
responseFormat
Sets how the generated images are returned as a raw string, for the formats thatModelGatewayImageParameters.ResponseFormatdoes not cover yet.- Parameters:
responseFormat- the response format- Returns:
this
-
size
public WatsonxGatewayImageModel.Builder size(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Size size) Sets the dimensions of the generated images.- Parameters:
size- theModelGatewayImageParameters.Size- Returns:
this
-
size
Sets the dimensions of the generated images as a raw string, e.g."1024x1024".- Parameters:
size- the image size- Returns:
this
-
style
public WatsonxGatewayImageModel.Builder style(com.ibm.watsonx.ai.gateway.image.ModelGatewayImageParameters.Style style) Sets the visual style of the generated images.- Parameters:
style- theModelGatewayImageParameters.Style- Returns:
this
-
style
Sets the visual style of the generated images as a raw string, for the values thatModelGatewayImageParameters.Styledoes not cover yet.- Parameters:
style- the image style- Returns:
this
-
user
Sets the identifier of the end user, used for abuse monitoring.- Parameters:
user- the user identifier- Returns:
this
-
build
-
baseUrl
Sets the IBM watsonx.ai endpoint from a predefinedCloudRegion.- Parameters:
baseUrl- the IBM Cloud region whose ML endpoint will be used- Returns:
this
-
baseUrl
Sets the base URL of the IBM watsonx.ai API.- Parameters:
url- the base URL string, e.g."https://us-south.ml.cloud.ibm.com"- Returns:
this
-
baseUrl
Sets the base URL of the IBM watsonx.ai API as aURI.- Parameters:
url- the base URL URI- Returns:
this
-
version
Sets the watsonx.ai API version date, e.g."2024-05-31".- Parameters:
version- the API version date string- Returns:
this
-
apiKey
Sets the IBM Cloud API key used to generate IAM access tokens for authentication.- Parameters:
apiKey- the IBM Cloud API key- Returns:
this
-
logRequests
Enables debug logging of request bodies sent to the watsonx.ai API.- Parameters:
logRequests-trueto enable request logging- Returns:
this
-
logResponses
Enables debug logging of response bodies received from the watsonx.ai API.- Parameters:
logResponses-trueto enable response logging- Returns:
this
-
timeout
Sets the HTTP request timeout. Defaults to 60 seconds.- Parameters:
timeout- the request timeout- Returns:
this
-
authenticator
public WatsonxGatewayImageModel.Builder authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator) Sets a customAuthenticatorfor generating bearer tokens.- Parameters:
authenticator- the authenticator- Returns:
this
-
httpClient
Sets a customHttpClientto use for all API calls.- Parameters:
httpClient- the HTTP client- Returns:
this
-
verifySsl
Controls whether SSL certificate verification is performed. Defaults totrue.- Parameters:
verifySsl-falseto disable SSL verification- Returns:
this
-