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

# Gemini Live

> GeminiLiveLLMService connects Pipecat to Google's Gemini Live API for real-time speech-to-speech multimodal conversation.

## Overview

`GeminiLiveLLMService` enables natural, real-time conversations with Google's Gemini model. It provides built-in audio transcription, voice activity detection, and context management for creating interactive AI experiences with multimodal capabilities including audio, video, and text processing.

> [!TIP]
>
> Want to start building? Check out our [Gemini Live
> Guide](https://docs.pipecat.ai/pipecat/features/gemini-live.md).

> [card] [Gemini Live API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.google.gemini_live.llm.html)
>
> Pipecat's API methods for Gemini Live integration

> [card] [Example Implementation](https://github.com/pipecat-ai/pipecat/blob/main/examples/realtime/realtime-gemini-live-async-tool.py)
>
> Complete Gemini Live async tool calling example

> [card] [Gemini Documentation](https://ai.google.dev/gemini-api/docs/live)
>
> Official Google Gemini Live API documentation

> [card] [Gemini Live Model Card](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-live)
>
> Gemini Live available models

## Installation

To use Gemini Live services, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[google]"
```

## Prerequisites

### Google AI Setup

Before using Gemini Live services, you need:

1. **Google Account**: Set up at [Google AI Studio](https://aistudio.google.com/)
2. **API Key**: Generate a Gemini API key from AI Studio
3. **Model Access**: Ensure access to Gemini Live models
4. **Multimodal Configuration**: Set up audio, video, and text modalities

### Required Environment Variables

* `GOOGLE_API_KEY`: Your Google Gemini API key for authentication

### Key Features

* **Multimodal Processing**: Handle audio, video, and text inputs simultaneously
* **Real-time Streaming**: Low-latency audio and video processing
* **Voice Activity Detection**: Automatic speech detection and turn management
* **Function Calling**: Advanced tool integration and API calling capabilities
* **Context Management**: Intelligent conversation history and system instruction handling

## Configuration

### GeminiLiveLLMService

**api\_key** `str` *required*

Google AI API key for authentication.

**model** `str` *deprecated* (default: models/gemini-3.8-live)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=GeminiLiveLLMService.Settings(model=...)` instead.

**voice\_id** `str` *deprecated* (default: Charon)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=GeminiLiveLLMService.Settings(voice=...)` instead.

**system\_instruction** `str` (default: None)

System prompt for the model. Can also be provided via the LLM context.

**tools** `ToolsSchema | List[FunctionSchema | DirectFunction] | List[dict]` (default: None)

Tools available to the model: a `ToolsSchema`, a plain list of direct
functions and/or `FunctionSchema` objects, or a list of provider-native tool
dicts. Can also be provided via the LLM context.

**params** `InputParams` *deprecated* (default: InputParams())

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=GeminiLiveLLMService.Settings(...)` instead.

**settings** `GeminiLiveLLMService.Settings` (default: None)

Generation and session settings. See [Settings](#settings) below.

**start\_audio\_paused** `bool` (default: False)

Whether to start with audio input paused. Resume with
`set_audio_input_paused(False)`.

**start\_video\_paused** `bool` (default: False)

Whether to start with video input paused. Resume with
`set_video_input_paused(False)`.

**inference\_on\_context\_initialization** `bool` (default: True)

Whether to generate a response when context is first set. Set to `False` to
wait for user input before the model responds.

**user\_audio\_preroll\_secs** `float | None` (default: None)

Seconds of recent audio replayed at the start of a user turn when server-side
VAD is disabled, so the speech onset isn't clipped. `None` sizes it to the
upstream VAD's `start_secs` plus 0.1 seconds, or 0.5 seconds with no VAD; set
it explicitly if turns don't start from VAD.

**http\_options** `HttpOptions` (default: None)

HTTP options for the Google API client. Use this to set API version (e.g.
`HttpOptions(api_version="v1alpha")`) or other request options.

**file\_api\_base\_url** `str` (default: [https://generativelanguage.googleapis.com/v1beta/files](https://generativelanguage.googleapis.com/v1beta/files))

Base URL for the Gemini File API.

### Settings

Settings passed via the `settings` constructor argument using `GeminiLiveLLMService.Settings(...)`. Changing them mid-conversation with `LLMUpdateSettingsFrame` is not supported: the service stores the change and logs a warning, but doesn't apply it to the session in progress. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"models/gemini-3.8-live"` | Model identifier. *(Inherited from base settings.)* |
| `system_instruction` | `str` | `None` | System instruction/prompt. *(Inherited from base settings.)* |
| `temperature` | `float` | `None` | Sampling temperature (0.0-2.0). *(Inherited from base settings.)* |
| `max_tokens` | `int` | `4096` | Maximum tokens to generate. *(Inherited from base settings.)* |
| `top_k` | `int` | `None` | Top-k sampling parameter. *(Inherited from base settings.)* |
| `top_p` | `float` | `None` | Top-p (nucleus) sampling parameter (0.0-1.0). *(Inherited from base settings.)* |
| `frequency_penalty` | `float` | `None` | Frequency penalty for generation (0.0-2.0). *(Inherited from base settings.)* |
| `presence_penalty` | `float` | `None` | Presence penalty for generation (0.0-2.0). *(Inherited from base settings.)* |
| `seed` | `int` | `None` | Random seed for reproducibility. *(Inherited from base settings.)* |
| `voice` | `str` | `"Charon"` | TTS voice identifier (e.g. `"Charon"`, `"Puck"`). |
| `modalities` | `GeminiModalities` | `GeminiModalities.AUDIO` | Response modality: `GeminiModalities.AUDIO` or `GeminiModalities.TEXT`. *Note: TEXT modality may not be supported by recent models.* |
| `language` | `Language \| str` | `"en-US"` | Language for generation and transcription. A `Language` value is sent as Gemini's locale code (`Language.ES` as `"es-ES"`); a string is sent as given. |
| `media_resolution` | `GeminiMediaResolution` | `GeminiMediaResolution.UNSPECIFIED` | Media resolution for video input: `UNSPECIFIED`, `LOW`, `MEDIUM`, or `HIGH`. |
| `vad` | `GeminiVADParams` | `None` | Voice activity detection parameters. See [GeminiVADParams](#geminivadparams) below. |
| `turn_coverage` | `TurnCoverage \| None` | `None` | Which realtime input a user turn covers. Unset uses the model's own default. |
| `context_window_compression` | `ContextWindowCompressionParams \| dict` | `{}` | Context window compression settings. |
| `thinking` | `ThinkingConfig \| dict` | `{}` | Thinking/reasoning configuration. Requires a model that supports it. |
| `enable_affective_dialog` | `bool` | `False` | Enable affective dialog for expression and tone adaptation. |
| `proactivity` | `ProactivityConfig \| dict` | `{}` | Proactivity settings for model behavior. |

> [!NOTE]
>
> `None` values are omitted, letting the service use its own defaults.

### GeminiVADParams

Voice activity detection configuration passed via the `vad` Settings field:

| Parameter | Type | Default | Description |
| - | - | - | - |
| `disabled` | `bool` | `None` | Whether to disable server-side VAD. `None`/`False` keeps server-side VAD (default). `True` disables it, so turns must come from a local VAD in the pipeline. |
| `start_sensitivity` | `StartSensitivity` | `None` | Sensitivity for speech start detection. |
| `end_sensitivity` | `EndSensitivity` | `None` | Sensitivity for speech end detection. |
| `prefix_padding_ms` | `int` | `None` | Padding before speech starts in milliseconds. |
| `silence_duration_ms` | `int` | `None` | Silence duration threshold in milliseconds to detect speech end. |

### ContextWindowCompressionParams

| Parameter | Type | Default | Description |
| - | - | - | - |
| `enabled` | `bool` | `False` | Whether context window compression is enabled. |
| `trigger_tokens` | `int` | `None` | Token count to trigger compression. `None` uses the default (80% of context window). |

## Usage

### Basic Setup

```python theme={null}
import os
from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService

llm = GeminiLiveLLMService(
    api_key=os.getenv("GOOGLE_API_KEY"),
    settings=GeminiLiveLLMService.Settings(
        voice="Charon",
        system_instruction="You are a helpful assistant.",
    ),
)
```

### With Settings

```python theme={null}
from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService, GeminiVADParams, ContextWindowCompressionParams

llm = GeminiLiveLLMService(
    api_key=os.getenv("GOOGLE_API_KEY"),
    settings=GeminiLiveLLMService.Settings(
        model="models/gemini-2.5-flash-native-audio-preview-12-2025",
        system_instruction="You are a helpful assistant.",
        voice="Puck",
        temperature=0.7,
        max_tokens=2048,
        language="en-US",
        vad=GeminiVADParams(
            silence_duration_ms=500,
        ),
        context_window_compression={"enabled": True},
    ),
)
```

### With Local VAD

```python theme={null}
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService, GeminiVADParams
from pipecat.processors.aggregators.llm_response_universal import (
    LLMContextAggregatorPair,
    LLMUserAggregatorParams,
)

llm = GeminiLiveLLMService(
    api_key=os.getenv("GOOGLE_API_KEY"),
    settings=GeminiLiveLLMService.Settings(
        voice="Charon",
        vad=GeminiVADParams(disabled=True),  # Disable server-side VAD
    ),
)

# Configure local VAD in your aggregator. The local VAD drives turn-taking
# since server-side VAD is disabled.
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
    context,
    user_params=LLMUserAggregatorParams(
        vad_analyzer=SileroVADAnalyzer(),
    ),
)
```

### Text-Only Mode

> [!WARNING]
>
> TEXT modality may not be supported by recent Gemini Live models. The service
> will log a warning if you configure `modalities=GeminiModalities.TEXT`.

```python theme={null}
from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService, GeminiModalities

llm = GeminiLiveLLMService(
    api_key=os.getenv("GOOGLE_API_KEY"),
    settings=GeminiLiveLLMService.Settings(
        system_instruction="You are a helpful assistant.",
        modalities=GeminiModalities.TEXT,
    ),
)
```

### With Thinking Enabled

```python theme={null}
from google.genai.types import ThinkingConfig

llm = GeminiLiveLLMService(
    api_key=os.getenv("GOOGLE_API_KEY"),
    settings=GeminiLiveLLMService.Settings(
        model="models/gemini-2.5-flash-native-audio-preview-12-2025",
        system_instruction="You are a helpful assistant.",
        thinking=ThinkingConfig(include_thoughts=True),
    ),
)
```

## Methods

### set\_audio\_input\_paused()

```python theme={null}
def set_audio_input_paused(paused: bool)
```

Stops (`True`) or resumes (`False`) sending input audio to the model.

### set\_video\_input\_paused()

```python theme={null}
def set_video_input_paused(paused: bool)
```

Stops (`True`) or resumes (`False`) sending video frames to the model.

### file\_api

```python theme={null}
llm.file_api -> GeminiFileAPI
```

The client for the Gemini File API. Upload a file, then reference its `uri` in a `file_data` content part of a context message. Each method raises an `Exception` when the API returns an error.

| Method | Returns |
| - | - |
| `async upload_file(file_path: str, display_name: str \| None = None)` | `dict`: the file's metadata, with `name` and `uri` under `file` |
| `async get_file(name: str)` | `dict`: the file's metadata |
| `async list_files(page_size: int = 10, page_token: str \| None = None)` | `dict`: one page of files |
| `async delete_file(name: str)` | `True` |

```python theme={null}
from pipecat.processors.aggregators.llm_context import LLMContext

file_info = await llm.file_api.upload_file("menu.txt", display_name="Menu")

context = LLMContext(
    [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What's on the menu today?"},
                {
                    "type": "file_data",
                    "file_data": {
                        "mime_type": "text/plain",
                        "file_uri": file_info["file"]["uri"],
                    },
                },
            ],
        }
    ]
)
```

## Notes

* **Model support**: The service supports Gemini 2.5, Gemini 3.x, and the 3.8 Live family (`gemini-3.8-live`, `gemini-3.8-live-extended-thinking`). The service automatically detects and handles model-specific behavior.
* **Function calling behavior**: Functions registered with `cancel_on_interruption=False` use Gemini's NON\_BLOCKING tool mechanism, allowing the conversation to continue while the tool runs in the background. The 3.8 Live family defaults to NON\_BLOCKING for all function calls; synchronous tools are explicitly declared BLOCKING on `gemini-3.8-live` to maintain blocking semantics. The thinking model `gemini-3.8-live-extended-thinking` accepts only NON\_BLOCKING and logs a warning for synchronous tools. Earlier Gemini 3.x models (before 3.8) do not support NON\_BLOCKING, and the service pushes an error when a function registered with `cancel_on_interruption=False` is used with them. Note: An intermittent 1008 error can occasionally occur on Gemini 2.5 during long-running tool calls; the service auto-reconnects when this happens.
* **Thinking level defaults**: Live thinking models (e.g., `gemini-3.8-live-extended-thinking`) require a `thinking_level` in the thinking configuration. When none is set, the service applies `LOW` as the default to keep reply latency down.
* **Turn completion with interaction status**: On thinking models from 3.8 onward, the service holds the bot turn open while Gemini reports `interaction_status: IN_PROGRESS`, ensuring that a reply spanning multiple `turn_complete` messages is recorded as a single assistant turn. This requires `google-genai>=2.19.0`; older SDKs log a warning.
* **Tool calls in conversation history**: When seeding a session with conversation history that contains tool calls (e.g., after a multi-worker handoff or reconnect), the service automatically converts function calls and their results to text summaries. This is required because Gemini Live's API only accepts text and media content. The conversion happens transparently and preserves the context for the model.
* **System instruction precedence**: The `system_instruction` from service settings takes precedence over an initial system message in the LLM context. A warning is logged when both are set.
* **VAD modes**: By default, Gemini Live uses server-side VAD for detecting when the user starts and stops speaking. To use local VAD (e.g., Silero), set `vad=GeminiVADParams(disabled=True)` and configure an external VAD analyzer in your `LLMUserAggregatorParams`. The service will automatically send activity signals to the Gemini API when local VAD detects speech. With server-side VAD, the service emits no `UserStartedSpeakingFrame` or `UserStoppedSpeakingFrame`, so processors that depend on them (RTVI user speaking events, user idle and mute handling, turn recording) do nothing unless `LLMUserAggregatorParams` has a `vad_analyzer`.
* **Tools precedence**: Similarly, tools provided in the context override tools provided at init time. Tools can't change mid-session: the service drops `LLMSetToolsFrame`.
* **Seed parameter**: Gemini treats the `seed` parameter as best effort. Identical seeds usually but not always produce identical responses.
* **Transcription aggregation**: Gemini Live sends user transcriptions in small chunks. The service aggregates them into complete sentences using end-of-sentence detection with a 0.5-second timeout fallback.
* **Session resumption**: The service automatically handles session resumption on reconnection using session resumption handles. In the rare case where reconnection occurs before a resumption handle is received, conversation history is preserved by reseeding it into the new session.
* **Connection resilience**: The service reconnects after a connection error. On the third consecutive error it reports an error and stops trying.
* **Video frame rate**: Video frames are throttled to a maximum of one per second.
* **Affective dialog and proactivity**: These features require both a supporting model and API version (`v1alpha`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.