Class GoogleGenAiDecisionModel

java.lang.Object
dev.langchain4j.model.google.genai.GoogleGenAiDecisionModel
All Implemented Interfaces:
DecisionModel

@Experimental public class GoogleGenAiDecisionModel extends Object implements DecisionModel
A DecisionModel backed by the Gemini Decisions API (such as gemini-decision-1), using the official Google GenAI Java SDK. It answers yes/no, choice and scale questions about a shared input in a single call, with calibrated probabilities. The Gemini Decisions API is available on the Gemini Developer API only, not on Vertex AI.
DecisionModel model = GoogleGenAiDecisionModel.builder()
        .apiKey(System.getenv("GOOGLE_AI_GEMINI_API_KEY"))
        .modelName("gemini-decision-1")
        .build();
The input can be:
  • text,
  • named fields: each field is sent as text labeled with its name, or, for a field that holds contents such as an image, as its label followed by the contents,
  • a list of TextContents, ImageContents, AudioContents, VideoContents and PdfFileContents,
  • a conversation (a list of ChatMessages), sent as a JSON transcript followed by the images, audio, video and PDF files it refers to, for example as [image 1] or [audio 1].

Gemini checks the limits of the API, such as the number of questions, options and levels, and the size of the input, and rejects a request that exceeds them with an InvalidRequestException.

Gemini can block the whole input, for example because it goes against its safety policies. Then no question is answered: the answer to each question is a RefusalAnswer, see DecisionResponse.isRefused(String). The reason is in the metadata of the response, see GoogleGenAiDecisionResponseMetadata.blockReason().

Since:
1.24.0