Class GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder
java.lang.Object
dev.langchain4j.model.googleai.GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder
- Enclosing class:
GoogleAiGeminiBatchImageModel
public static class GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder
extends Object
Builder for constructing
GoogleAiGeminiBatchImageModel instances.-
Method Summary
Modifier and TypeMethodDescriptionSets the API key for authenticating with the Gemini API.aspectRatio(String aspectRatio) Sets the aspect ratio for generated images.Sets a custom base URL for the Gemini API.build()Builds a newGoogleAiGeminiBatchImageModelinstance.httpClientBuilder(HttpClientBuilder httpClientBuilder) Sets the HTTP client builder for custom HTTP configuration.Sets the image size/resolution for generated images.logger(org.slf4j.Logger logger) Sets a custom logger for request/response logging.logRequests(Boolean logRequests) Enables or disables logging of requests only.logRequestsAndResponses(Boolean logRequestsAndResponses) Enables or disables logging of both requests and responses.logResponses(Boolean logResponses) Enables or disables logging of responses only.Sets the model name to use for image generation.safetySettings(List<GeminiSafetySetting> safetySettings) Sets safety settings to control content filtering.Sets the timeout for API requests.
-
Method Details
-
httpClientBuilder
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder httpClientBuilder(HttpClientBuilder httpClientBuilder) Sets the HTTP client builder for custom HTTP configuration.- Parameters:
httpClientBuilder- the HTTP client builder- Returns:
- this builder
-
apiKey
Sets the API key for authenticating with the Gemini API.- Parameters:
apiKey- the Google AI API key (required)- Returns:
- this builder
-
baseUrl
Sets a custom base URL for the Gemini API.- Parameters:
baseUrl- the base URL (optional, defaults to Google's API endpoint)- Returns:
- this builder
-
modelName
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder modelName(String modelName) Sets the model name to use for image generation.Defaults to "gemini-2.5-flash-preview-image-generation" if not specified.
- Parameters:
modelName- the model name- Returns:
- this builder
-
aspectRatio
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder aspectRatio(String aspectRatio) Sets the aspect ratio for generated images.Supported aspect ratios: "1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"
- Parameters:
aspectRatio- the aspect ratio (e.g., "16:9")- Returns:
- this builder
-
imageSize
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder imageSize(String imageSize) Sets the image size/resolution for generated images.Supported sizes (for gemini-3-pro-image-preview only): "1K", "2K", "4K"
Note: You must use an uppercase 'K'. Lowercase parameters will be rejected.
- Parameters:
imageSize- the image size (e.g., "2K")- Returns:
- this builder
-
timeout
Sets the timeout for API requests.- Parameters:
timeout- the timeout duration- Returns:
- this builder
-
logRequestsAndResponses
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder logRequestsAndResponses(Boolean logRequestsAndResponses) Enables or disables logging of both requests and responses.- Parameters:
logRequestsAndResponses- true to enable logging- Returns:
- this builder
-
logRequests
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder logRequests(Boolean logRequests) Enables or disables logging of requests only.- Parameters:
logRequests- true to enable request logging- Returns:
- this builder
-
logResponses
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder logResponses(Boolean logResponses) Enables or disables logging of responses only.- Parameters:
logResponses- true to enable response logging- Returns:
- this builder
-
logger
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder logger(org.slf4j.Logger logger) Sets a custom logger for request/response logging.- Parameters:
logger- the SLF4J logger to use- Returns:
- this builder
-
safetySettings
public GoogleAiGeminiBatchImageModel.GoogleAiGeminiBatchImageModelBuilder safetySettings(List<GeminiSafetySetting> safetySettings) Sets safety settings to control content filtering.- Parameters:
safetySettings- the list of safety settings- Returns:
- this builder
-
build
Builds a newGoogleAiGeminiBatchImageModelinstance.- Returns:
- the configured batch image model
- Throws:
IllegalArgumentException- if required parameters are missing
-