Class WatsonxGatewayImageModel.Builder

java.lang.Object
dev.langchain4j.model.watsonx.WatsonxGatewayImageModel.Builder
Enclosing class:
WatsonxGatewayImageModel

public static class WatsonxGatewayImageModel.Builder extends Object
Builder class for constructing WatsonxGatewayImageModel instances with configurable parameters.
  • Field Details

    • baseUrl

      protected URI baseUrl
    • version

      protected String version
    • apiKey

      protected String apiKey
    • logRequests

      protected Boolean logRequests
    • logResponses

      protected Boolean logResponses
    • timeout

      protected Duration timeout
    • authenticator

      protected com.ibm.watsonx.ai.core.auth.Authenticator authenticator
    • httpClient

      protected HttpClient httpClient
    • verifySsl

      protected boolean verifySsl
  • Method Details

    • modelName

      public WatsonxGatewayImageModel.Builder modelName(String 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, so ModelGatewayImageParameters.OutputFormat.PNG or ModelGatewayImageParameters.OutputFormat.WEBP.
      Parameters:
      background - the ModelGatewayImageParameters.Background
      Returns:
      this
    • background

      public WatsonxGatewayImageModel.Builder background(String background)
      Sets the background of the generated images as a raw string, for the values that ModelGatewayImageParameters.Background does 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.LOW being the least restrictive.
      Parameters:
      moderation - the ModelGatewayImageParameters.Moderation
      Returns:
      this
    • moderation

      public WatsonxGatewayImageModel.Builder moderation(String moderation)
      Sets how strictly the generated images are filtered as a raw string, for the values that ModelGatewayImageParameters.Moderation does not cover yet.
      Parameters:
      moderation - the moderation level
      Returns:
      this
    • outputCompression

      public WatsonxGatewayImageModel.Builder outputCompression(Integer outputCompression)
      Sets the compression level of the generated images, from 0 to 100. Only the ModelGatewayImageParameters.OutputFormat.JPEG and ModelGatewayImageParameters.OutputFormat.WEBP formats 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 - the ModelGatewayImageParameters.OutputFormat
      Returns:
      this
    • outputFormat

      public WatsonxGatewayImageModel.Builder outputFormat(String outputFormat)
      Sets the file format of the generated images as a raw string, for the formats that ModelGatewayImageParameters.OutputFormat does 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 - the ModelGatewayImageParameters.Quality
      Returns:
      this
    • quality

      public WatsonxGatewayImageModel.Builder quality(String quality)
      Sets the quality of the generated images as a raw string, for the values that ModelGatewayImageParameters.Quality does 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 with ModelGatewayImageParameters.ResponseFormat.URL or as Base64 data with ModelGatewayImageParameters.ResponseFormat.B64_JSON. Only the models that support it accept this value.
      Parameters:
      responseFormat - the ModelGatewayImageParameters.ResponseFormat
      Returns:
      this
    • responseFormat

      public WatsonxGatewayImageModel.Builder responseFormat(String responseFormat)
      Sets how the generated images are returned as a raw string, for the formats that ModelGatewayImageParameters.ResponseFormat does 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 - the ModelGatewayImageParameters.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 - the ModelGatewayImageParameters.Style
      Returns:
      this
    • style

      Sets the visual style of the generated images as a raw string, for the values that ModelGatewayImageParameters.Style does 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

      public WatsonxGatewayImageModel build()
    • baseUrl

      public WatsonxGatewayImageModel.Builder baseUrl(com.ibm.watsonx.ai.CloudRegion baseUrl)
      Sets the IBM watsonx.ai endpoint from a predefined CloudRegion.
      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

      public WatsonxGatewayImageModel.Builder baseUrl(URI url)
      Sets the base URL of the IBM watsonx.ai API as a URI.
      Parameters:
      url - the base URL URI
      Returns:
      this
    • version

      public WatsonxGatewayImageModel.Builder version(String version)
      Sets the watsonx.ai API version date, e.g. "2024-05-31".
      Parameters:
      version - the API version date string
      Returns:
      this
    • apiKey

      public WatsonxGatewayImageModel.Builder apiKey(String 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

      public WatsonxGatewayImageModel.Builder logRequests(Boolean logRequests)
      Enables debug logging of request bodies sent to the watsonx.ai API.
      Parameters:
      logRequests - true to enable request logging
      Returns:
      this
    • logResponses

      public WatsonxGatewayImageModel.Builder logResponses(Boolean logResponses)
      Enables debug logging of response bodies received from the watsonx.ai API.
      Parameters:
      logResponses - true to enable response logging
      Returns:
      this
    • timeout

      public WatsonxGatewayImageModel.Builder timeout(Duration 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 custom Authenticator for generating bearer tokens.
      Parameters:
      authenticator - the authenticator
      Returns:
      this
    • httpClient

      public WatsonxGatewayImageModel.Builder httpClient(HttpClient httpClient)
      Sets a custom HttpClient to use for all API calls.
      Parameters:
      httpClient - the HTTP client
      Returns:
      this
    • verifySsl

      public WatsonxGatewayImageModel.Builder verifySsl(boolean verifySsl)
      Controls whether SSL certificate verification is performed. Defaults to true.
      Parameters:
      verifySsl - false to disable SSL verification
      Returns:
      this