> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google

> JavaScript API reference for the google llm plugin.

## 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

```typescript theme={null}
new GoogleLLM(opts: GoogleLLMOptions)
```

<ParamField path="apiKey" type="string | null">
  Google AI (Gemini) API key. Falls back to the `GOOGLE_API_KEY` environment variable, then `null`. Not used for Vertex AI auth.
</ParamField>

<ParamField path="model" type="GoogleLLMModel | string">
  Gemini model id. Default `'gemini-2.5-flash-lite'`.
</ParamField>

<ParamField path="temperature" type="number">
  Sampling temperature controlling randomness. Default `0.7`.
</ParamField>

<ParamField path="maxOutputTokens" type="number">
  Maximum number of tokens to generate in the response. Default `8192`.
</ParamField>

<ParamField path="thinkingBudget" type="number | null">
  Token budget for Gemini "thinking" (reasoning). `0` disables thinking. Default `0`.
</ParamField>

<ParamField path="includeThoughts" type="boolean">
  Whether to include the model's thought/reasoning content in responses. Default `false`.
</ParamField>

<ParamField path="safetySettings" type="Array<Record<string, string>> | null">
  Gemini safety/content-filter settings, as an array of category/threshold maps. Default `null` (provider defaults).
</ParamField>

<ParamField path="topP" type="number | null">
  Nucleus sampling probability mass. Default `null` (model default).
</ParamField>

<ParamField path="topK" type="number | null">
  Top-K sampling cutoff. Default `null` (model default).
</ParamField>

<ParamField path="presencePenalty" type="number | null">
  Presence penalty discouraging repeated topics. Default `null` (model default).
</ParamField>

<ParamField path="frequencyPenalty" type="number | null">
  Frequency penalty discouraging repeated tokens. Default `null` (model default).
</ParamField>

<ParamField path="seed" type="number | null">
  Seed for reproducible sampling. Default `null` (non-deterministic).
</ParamField>

<ParamField path="vertexai" type="boolean">
  Route requests through Vertex AI instead of the Gemini API. When `true`, `projectId` is required. Default `false`.
</ParamField>

<ParamField path="projectId" type="string | null">
  Google Cloud project id for Vertex AI auth. Required when `vertexai` is `true`; falls back to `GOOGLE_CLOUD_PROJECT`. Default `null`.
</ParamField>

<ParamField path="location" type="string">
  Vertex AI region. Default `'us-central1'`. Only used when `vertexai` is `true`.
</ParamField>

<ParamField path="serviceAccountJson" type="string | Record<string, any> | null">
  Vertex AI service-account credentials, as a JSON string or parsed object. Used when `vertexai` is `true`. Default `null`.
</ParamField>

<ParamField path="serviceAccountPath" type="string | null">
  Path to a Vertex AI service-account JSON file. Used when `vertexai` is `true`; falls back to `GOOGLE_APPLICATION_CREDENTIALS`. Default `null`.
</ParamField>

### cancelCurrentGeneration

```typescript theme={null}
cancelCurrentGeneration(): Promise<void>
```

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

### chat

```typescript theme={null}
chat(_messages: any, _opts?: LLMChatOptions): AsyncIterator<LLMResponse>
```

Stream a completion for the given messages, yielding LLMResponse chunks.

<ResponseField name="returns" type="AsyncIterator<LLMResponse>" />

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

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

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## GoogleLLMModel

Supported Google Gemini LLM model ids.

```typescript theme={null}
type GoogleLLMModel = | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.5-pro' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.5-flash' | 'gemini-3.1-flash-lite' | 'gemini-flash-latest'
```
