Language model implementation for Gemini's generateContent API.
aisdk::LanguageModelV1 -> GeminiLanguageModel
new()Initialize the Gemini language model.
GeminiLanguageModel$new(model_id, config)model_idThe model ID (e.g., "gemini-1.5-pro").
configConfiguration list with api_key, base_url, headers, etc.
get_config()Get the configuration list.
GeminiLanguageModel$get_config()A list with provider configuration.
build_payload_internal()Build the request payload for generation
GeminiLanguageModel$build_payload_internal(params, stream = FALSE)paramsA list of call options.
streamWhether to build for streaming
A list with url, headers, and body.
do_generate()Generate text (non-streaming).
GeminiLanguageModel$do_generate(params)paramsA list of call options including messages, temperature, etc.
A GenerateResult object.
do_stream()Generate text (streaming).
GeminiLanguageModel$do_stream(params, callback)paramsA list of call options.
callbackA function called for each chunk: callback(text, done).
A GenerateResult object.
format_tool_result()Format a tool execution result for Gemini's API.
GeminiLanguageModel$format_tool_result(tool_call_id, tool_name, result_content)tool_call_idThe ID of the tool call (unused in Gemini but present for interface compatibility).
tool_nameThe name of the tool.
result_contentThe result content from executing the tool.
A list formatted as a message for Gemini API.
get_history_format()Get the message format for Gemini.
GeminiLanguageModel$get_history_format()
clone()The objects of this class are cloneable with this method.
GeminiLanguageModel$clone(deep = FALSE)deepWhether to make a deep clone.