A specialized AgentDriver for the Google Gemini API (AI Studio / Vertex AI).
Details
Setup: Requires the GOOGLE_API_KEY environment variable to
be set. Add it to your .Renviron: GOOGLE_API_KEY="AIza..."
Super class
HydraR::AgentDriver -> GeminiAPIDriver
Methods
Method new()
Initialize GeminiAPIDriver
Usage
GeminiAPIDriver$new(
id = "gemini_api",
model = "gemini-3.1-flash-lite-preview",
validation_mode = "warning",
working_dir = NULL
)Method call()
Usage
GeminiAPIDriver$call(
prompt,
model = NULL,
system_prompt = NULL,
cli_opts = list(),
...
)Arguments
promptString. The prompt or query provided by the user.
modelString. Optional override for the model ID.
system_promptString. Optional system-level instructions for the model.
cli_optsList. Advanced API parameters (e.g.,
generationConfig)....Additional arguments passed to the requester.
Examples
if (FALSE) { # \dontrun{
# 1. Initialize Gemini Pro API
driver <- GeminiAPIDriver$new(model = "gemini-1.5-pro")
# 2. Advanced call with custom generation config and safety filtering
response <- driver$call(
prompt = "Write a high-performance R function for matrix multiplication.",
cli_opts = list(
generationConfig = list(
temperature = 0.9,
topP = 0.8,
topK = 40,
maxOutputTokens = 2048
),
safetySettings = list(
list(category = "HARM_CATEGORY_HARASSMENT", threshold = "BLOCK_LOW_AND_ABOVE")
)
)
)
} # }