Overview
GoogleLLMService provides integration with Google’s Gemini models, supporting streaming responses, function calling, and multimodal inputs. It includes specialized context handling for Google’s message format while maintaining compatibility with OpenAI-style contexts.
Gemini LLM API Reference
Pipecat’s API methods for Google Gemini integration
Example Implementation
Complete example with function calling
Gemini Documentation
Official Google Gemini API documentation and features
Google AI Studio
Access Gemini models and manage API keys
Installation
To use Google Gemini services, install the required dependencies:Prerequisites
Google Gemini Setup
Before using Google Gemini LLM services, you need:- Google Account: Sign up at Google AI Studio
- API Key: Generate a Gemini API key from AI Studio
- Model Selection: Choose from available Gemini models
Required Environment Variables
GOOGLE_API_KEY: Your Google Gemini API key for authentication
Configuration
str
required
Google AI API key for authentication.
str
default:"None"
deprecated
Gemini model name to use. Deprecated in v0.0.105. Use
settings=GoogleLLMService.Settings(...) instead.InputParams
default:"None"
deprecated
Runtime-configurable model settings. See Settings below.
Deprecated in v0.0.105. Use
settings=GoogleLLMService.Settings(...)
instead.str
default:"None"
deprecated
System instruction/prompt for the model. Sets the overall behavior and
context. Deprecated in v0.0.105. Use
settings=GoogleLLMService.Settings(system_instruction=...) instead.List[Dict[str, Any]]
default:"None"
List of available tools/functions for the model to call.
Dict[str, Any]
default:"None"
Configuration for tool usage behavior.
HttpOptions
default:"None"
HTTP options for the Google API client.
float | None
default:"20.0"
How long to wait for the next chunk of a streamed response before giving up on
it. Bounds the wait when the API accepts a request and then stops producing
without closing the stream. This is a gap between chunks, not a limit on how
long a response may take overall. The first chunk is the slowest, since its
wait spans the whole round trip including any thinking the model does before
it emits anything; raise this for models configured to think at length. Set to
None to wait indefinitely.float | None
default:"5.0"
How long to wait for the first chunk before giving up on the request and
re-issuing it, when
retry_on_timeout is set. Like the first-chunk wait
above, this window spans the whole round trip including any thinking, so it is
only a good fit for models that start emitting quickly.bool | None
default:"False"
Whether to re-issue the request once if the first chunk doesn’t arrive within
retry_timeout_secs. Only the first chunk is retried: once a chunk has been
pushed downstream, re-issuing would duplicate the response.Settings
Runtime-configurable settings passed via thesettings constructor argument using GoogleLLMService.Settings(...). These can be updated mid-conversation with LLMUpdateSettingsFrame. See Service Settings for details.
NOT_GIVEN values are omitted from the API request, letting the Gemini API
use its own defaults. If thinking is not provided, Pipecat applies
low-latency thinking defaults for Flash models: Gemini 2.5 Flash uses
thinking_budget=0 (disables thinking), while Gemini 3+ Flash uses
thinking_level="minimal".GoogleThinkingConfig
Configuration for controlling the model’s internal thinking process. Gemini 2.5 and 3 series models support this feature.Gemini 2.5 series models use
thinking_budget, while Gemini 3 models use
thinking_level. Do not mix these parameters across model generations.Usage
Basic Setup
With Custom Settings
With Thinking Configuration
With Safety Settings
Updating Settings at Runtime
Model settings can be changed mid-conversation usingLLMUpdateSettingsFrame:
Notes
- System instruction priority: The
system_instructionset via the constructor orGoogleLLMSettingstakes priority over any system message in the context. If both are set, a warning is logged and the constructor/settings value is used. - Thinking defaults: By default, Pipecat applies low-latency thinking defaults for Flash models to reduce latency. Gemini 2.5 Flash uses
thinking_budget=0(disables thinking), while Gemini 3+ Flash usesthinking_level="minimal". To override this behavior, explicitly pass aGoogleThinkingConfigviasettings. - Safety settings: Categories left unspecified in
safety_settingskeep the Gemini API defaults. The setting acceptsSafetySettingobjects or plain dicts, and is runtime-updatable viaLLMUpdateSettingsFrame. - Multimodal support: Gemini models natively support image and audio inputs through Google’s Content/Part format. Images and audio are automatically converted from OpenAI-style contexts.
- Grounding with Google Search: When grounding metadata is present in the response (e.g., from Google Search tool), the service emits
LLMSearchResponseFramewith search results and source attributions. - Context format: The service automatically converts between OpenAI-style message formats and Google’s native Content/Part format, so you can use either.
Event Handlers
GoogleLLMService supports the following event handlers, inherited from LLMService: