Skip to main content

GoogleLLM

Google Gemini LLM provider. Supports both the Gemini API (via apiKey) and Vertex AI (set vertexai: true with projectId and service-account credentials).

Constructor

apiKey
string | null
Google AI (Gemini) API key. Falls back to the GOOGLE_API_KEY environment variable, then null. Not used for Vertex AI auth.
model
GoogleLLMModel | string
Gemini model id. Default 'gemini-2.5-flash-lite'.
temperature
number
Sampling temperature controlling randomness. Default 0.7.
maxOutputTokens
number
Maximum number of tokens to generate in the response. Default 8192.
thinkingBudget
number | null
Token budget for Gemini “thinking” (reasoning). 0 disables thinking. Default 0.
includeThoughts
boolean
Whether to include the model’s thought/reasoning content in responses. Default false.
safetySettings
Array<Record<string, string>> | null
Gemini safety/content-filter settings, as an array of category/threshold maps. Default null (provider defaults).
topP
number | null
Nucleus sampling probability mass. Default null (model default).
topK
number | null
Top-K sampling cutoff. Default null (model default).
presencePenalty
number | null
Presence penalty discouraging repeated topics. Default null (model default).
frequencyPenalty
number | null
Frequency penalty discouraging repeated tokens. Default null (model default).
seed
number | null
Seed for reproducible sampling. Default null (non-deterministic).
vertexai
boolean
Route requests through Vertex AI instead of the Gemini API. When true, projectId is required. Default false.
projectId
string | null
Google Cloud project id for Vertex AI auth. Required when vertexai is true; falls back to GOOGLE_CLOUD_PROJECT. Default null.
location
string
Vertex AI region. Default 'us-central1'. Only used when vertexai is true.
serviceAccountJson
string | Record<string, any> | null
Vertex AI service-account credentials, as a JSON string or parsed object. Used when vertexai is true. Default null.
serviceAccountPath
string | null
Path to a Vertex AI service-account JSON file. Used when vertexai is true; falls back to GOOGLE_APPLICATION_CREDENTIALS. Default null.

cancelCurrentGeneration

Cancel the in-flight generation for the current session, if any.

chat

Stream a completion for the given messages, yielding LLMResponse chunks.
returns
AsyncIterator<LLMResponse>

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

removeAllListeners

event
string

GoogleLLMModel

Supported Google Gemini LLM model ids.