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

> Use the Google Gemini LLM plugin in a Zero Runtime pipeline. Setup, options, and usage in Python, JavaScript, and Go.

Google Gemini is an **LLM** plugin. It takes the transcribed conversation and generates
the reply.

## Setup

Set your Google API key in the worker environment. Generate a key from the [Google AI Studio](https://aistudio.google.com/apikey):

```bash theme={null}
export GOOGLE_API_KEY=<key>
```

## Usage

Import the plugin and pass it to the pipeline's `llm` slot.

<CodeGroup>
  ```python Python theme={null}
  from zrt.plugins import GoogleLLM

  llm = GoogleLLM(
      model="gemini-2.5-flash",
      thinking_budget=0,
      include_thoughts=False,
      max_output_tokens=8192,
  )

  # Pipeline(llm=llm, ...)
  ```
</CodeGroup>

## Vertex AI

By default the plugin calls the public Gemini API with `GOOGLE_API_KEY`. To run Gemini
through **Vertex AI** instead, enable the Vertex backend and supply your Google Cloud
project and location. Authenticate with a service account. Set `GOOGLE_APPLICATION_CREDENTIALS`
(Python and JavaScript), or pass the key file path directly in Go:

```bash theme={null}
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
```

<CodeGroup>
  ```python Python theme={null}
  from zrt.plugins import GoogleLLM

  llm = GoogleLLM(
      model="gemini-2.5-flash",
      vertexai=True,
      project_id="your-gcp-project-id",
      location="us-central1",
  )

  # Pipeline(llm=llm, ...)
  ```
</CodeGroup>

<Note>
  `location` defaults to `us-central1` in all SDKs. In Python, `project_id` is required when
  `vertexai=True` and must be passed explicitly.
</Note>

## Configuration Options

*Constructor parameters for the Python SDK (`GoogleLLM`). The JavaScript and Go SDKs expose equivalent options where supported, in their idiomatic form (camelCase / `LLMOptions` struct).*

### Core

| Parameter           | Type    | Default                   | Description                                                                         |
| ------------------- | ------- | ------------------------- | ----------------------------------------------------------------------------------- |
| `model`             | `str`   | `"gemini-2.5-flash-lite"` | Gemini model used to generate replies.                                              |
| `api_key`           | `str`   | `None`                    | Google API key. Falls back to the `GOOGLE_API_KEY` environment variable when unset. |
| `temperature`       | `float` | `0.7`                     | Sampling randomness; lower is more deterministic.                                   |
| `max_output_tokens` | `int`   | `8192`                    | Caps the length of each reply.                                                      |
| `top_p`             | `float` | `None`                    | Nucleus-sampling probability cutoff.                                                |
| `top_k`             | `int`   | `None`                    | Top-k sampling cutoff.                                                              |
| `presence_penalty`  | `float` | `None`                    | Penalizes tokens already present, encouraging new topics.                           |
| `frequency_penalty` | `float` | `None`                    | Penalizes frequent tokens, reducing repetition.                                     |

### Generation knobs

| Parameter | Type  | Default | Description                     |
| --------- | ----- | ------- | ------------------------------- |
| `seed`    | `int` | `None`  | Seed for reproducible sampling. |

### Vertex AI

| Parameter              | Type          | Default         | Description                                                                                                       |
| ---------------------- | ------------- | --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `vertexai`             | `bool`        | `False`         | Route requests through Vertex AI instead of the Gemini API.                                                       |
| `project_id`           | `str`         | `None`          | Google Cloud project ID. Required when `vertexai` is enabled.                                                     |
| `location`             | `str`         | `"us-central1"` | Vertex AI regional endpoint used when `vertexai` is enabled.                                                      |
| `service_account_json` | `str \| dict` | `None`          | Service-account credentials as a JSON string or dict, used for Vertex AI authentication.                          |
| `service_account_path` | `str`         | `None`          | Path to a service-account JSON key file. Falls back to the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. |

### Safety

| Parameter         | Type   | Default | Description                |
| ----------------- | ------ | ------- | -------------------------- |
| `safety_settings` | `list` | `None`  | Content-safety thresholds. |

### Extended thinking

| Parameter          | Type   | Default | Description                                                                                           |
| ------------------ | ------ | ------- | ----------------------------------------------------------------------------------------------------- |
| `thinking_budget`  | `int`  | `0`     | Tokens the model may spend reasoning. `0` disables it for lower latency. Not available in the Go SDK. |
| `include_thoughts` | `bool` | `False` | Include the model's reasoning in the output. Not available in the Go SDK.                             |

<Tip>
  For voice, short replies feel best. A zero or small thinking budget and a concise system
  instruction keep latency down.
</Tip>

## Import paths

| SDK        | Import                              | Constructor                             |
| ---------- | ----------------------------------- | --------------------------------------- |
| Python     | `from zrt.plugins import GoogleLLM` | `GoogleLLM(...)`                        |
| JavaScript | `from '@zrt/js-sdk/plugins/google'` | `GoogleLLM({ ... })`                    |
| Go         | `.../zrt-golang-sdk/plugins/google` | `google.NewLLM(google.LLMOptions{...})` |
