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

> Python API reference for the google llm plugin.

<Card title="Usage guide" icon="book" href="/plugins/llm/google" horizontal>
  Setup, environment variables, and Python/JavaScript/Go usage examples.
</Card>

## GoogleLLM

Google Gemini LLM via the Gemini API or Vertex AI.

Supports the full Gemini model family (2.5 and 3.x series) including
thinking/reasoning models, safety-settings control, and optional
service-account-authenticated Vertex AI routing.

### Constructor

```python theme={null}
GoogleLLM(*, api_key: 'str | None' = None, model: 'GoogleLLMModel | str' = 'gemini-2.5-flash-lite', temperature: 'float' = 0.7, max_output_tokens: 'int' = 8192, thinking_budget: 'Optional[int]' = 0, include_thoughts: 'bool' = False, safety_settings: 'Optional[List[Dict[str, str]]]' = None, top_p: 'Optional[float]' = None, top_k: 'Optional[int]' = None, presence_penalty: 'Optional[float]' = None, frequency_penalty: 'Optional[float]' = None, seed: 'Optional[int]' = None, vertexai: 'bool' = False, project_id: 'Optional[str]' = None, location: 'str' = 'us-central1', service_account_json: 'Optional[Union[str, Dict]]' = None, service_account_path: 'Optional[str]' = None, **kwargs) -> 'None'
```

<ParamField path="api_key" type="str | None">
  Google AI Studio API key. Falls back to `GOOGLE_API_KEY` env var. Ignored when `vertexai=True`.
</ParamField>

<ParamField path="model" type="GoogleLLMModel | str" default="gemini-2.5-flash-lite">
  Gemini model ID. Known values (`GoogleLLMModel`): `"gemini-2.5-flash-lite"` (default), `"gemini-2.5-flash"`, `"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"`. Any string is accepted for forward compatibility.
</ParamField>

<ParamField path="temperature" type="float" default="0.7">
  Sampling temperature controlling response randomness. Higher values produce more varied output. Default: `0.7`.
</ParamField>

<ParamField path="max_output_tokens" type="int" default="8192">
  Maximum number of tokens in the generated response. Default: `8192`.
</ParamField>

<ParamField path="thinking_budget" type="Optional[int]" default="0">
  Token budget reserved for the model's internal reasoning chain (applicable to thinking-capable models). `0` disables thinking; higher values allow deeper reasoning at the cost of latency and tokens. Default: `0`.
</ParamField>

<ParamField path="include_thoughts" type="bool" default="False">
  When `True` and `thinking_budget > 0`, the model's reasoning trace is included in the response alongside the final answer. Default: `False`.
</ParamField>

<ParamField path="safety_settings" type="Optional[List[Dict[str, str]]]">
  List of `&#123;"category": ..., "threshold": ...&#125;` dicts overriding Gemini's default harm-blocking thresholds. See Google AI safety-settings docs for valid category and threshold strings.
</ParamField>

<ParamField path="top_p" type="Optional[float]">
  Nucleus sampling probability mass cutoff (0.0–1.0). `None` uses the model default.
</ParamField>

<ParamField path="top_k" type="Optional[int]">
  Top-K sampling limit. `None` uses the model default.
</ParamField>

<ParamField path="presence_penalty" type="Optional[float]">
  Penalises tokens that have already appeared, encouraging topic diversity (range typically −2.0–2.0). `None` uses the model default.
</ParamField>

<ParamField path="frequency_penalty" type="Optional[float]">
  Penalises tokens proportional to how often they have appeared, reducing repetition (range typically −2.0–2.0). `None` uses the model default.
</ParamField>

<ParamField path="seed" type="Optional[int]">
  Fixed random seed for deterministic outputs when supported. `None` uses non-deterministic sampling.
</ParamField>

<ParamField path="vertexai" type="bool" default="False">
  When `True`, routes requests through Vertex AI instead of the Gemini API. Requires `project_id`. Default: `False`.
</ParamField>

<ParamField path="project_id" type="Optional[str]">
  Google Cloud project ID. Required when `vertexai=True`. Falls back to `GOOGLE_CLOUD_PROJECT` env var (resolved in the calling code).
</ParamField>

<ParamField path="location" type="str" default="us-central1">
  Vertex AI regional endpoint, e.g. `"us-central1"` (default) or `"europe-west4"`. Ignored when `vertexai=False`.
</ParamField>

<ParamField path="service_account_json" type="Optional[Union[str, Dict]]">
  Service-account credentials as a JSON string or dict. Used for Vertex AI authentication when `vertexai=True`. Takes precedence over `service_account_path`.
</ParamField>

<ParamField path="service_account_path" type="Optional[str]">
  Path to a service-account JSON key file. Used when `service_account_json` is not provided and `vertexai=True`. Falls back to `GOOGLE_APPLICATION_CREDENTIALS` env var.
</ParamField>

### aclose

```python theme={null}
def aclose(self) -> 'None'
```

Release any resources held by the provider.

### cancel\_current\_generation

```python theme={null}
def cancel_current_generation(self) -> 'None'
```

Cancel the in-progress generation for the active session, if any.

### chat

```python theme={null}
def chat(self, messages: 'Any', tools: 'Any' = None, conversational_graph: 'Any' = None, **kwargs: 'Any') -> 'AsyncIterator[LLMResponse]'
```

Generate a streamed chat completion.

<ParamField path="messages" type="Any" required>
  The conversation history to send to the model.
</ParamField>

<ParamField path="tools" type="Any">
  Optional tool definitions the model may call.
</ParamField>

<ParamField path="conversational_graph" type="Any">
  Optional conversational graph guiding the exchange.
</ParamField>

<ResponseField name="returns" type="AsyncIterator[LLMResponse]">
  LLMResponse: Response chunks produced as the model generates output.
</ResponseField>

### emit

```python theme={null}
def emit(self, event: 'T', *args: 'Any') -> 'None'
```

Emit an event, invoking all registered handlers with the given arguments.

Handlers are called in registration order. Coroutine handlers are
scheduled on the running event loop. If the emitter is closed, the call
is a no-op.

<ParamField path="event" type="T" required>
  The event to emit.
</ParamField>

### off

```python theme={null}
def off(self, event: 'T', callback: 'Callable[..., Any]') -> 'None'
```

Remove a previously registered handler for an event.

If the handler is not registered for the event, the call is a no-op.

<ParamField path="event" type="T" required>
  The event the handler was registered for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any]" required>
  The handler to remove.
</ParamField>

### on

```python theme={null}
def on(self, event: 'T', callback: 'Callable[..., Any] | None' = None) -> 'Callable[..., Any]'
```

Register a handler for an event.

Can be used directly by passing a callback, or as a decorator when
`callback` is omitted.

<ParamField path="event" type="T" required>
  The event to listen for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any] | None">
  The handler to invoke when the event is emitted. If `None`, a decorator is returned that registers the decorated function.
</ParamField>

<ResponseField name="returns" type="Callable[..., Any]">
  The registered callback when `callback` is provided, otherwise a decorator that registers and returns the function it wraps.
</ResponseField>

***

## GoogleLLMModel

```python theme={null}
GoogleLLMModel = typing.Literal['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']
```
