Skip to content

API Reference parrot.clients.google.live

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.google.live

View source

GeminiLiveClient - Live/Realtime API Client for AI-Parrot

Inherits from AbstractClient to maintain consistency with the AI-Parrot ecosystem while supporting the unique requirements of voice streaming.

Key Features:

  • Inherits from AbstractClient (same as GoogleGenAIClient, AnthropicClient, etc.)
  • Reuses tool_manager and the preset system
  • Uses same credential pattern as GoogleGenAIClient
  • Supports AbstractTool integration via LiveToolAdapter
  • Returns LiveVoiceResponse with CompletionUsage metadata

Location: parrot/clients/google/live.py

Class GeminiLiveClient

Client for Gemini Live API voice interactions.

Inherits from AbstractClient to maintain consistency with the AI-Parrot ecosystem. Reuses tool_manager and credential patterns from GoogleGenAIClient.

Key features:

  • Inherits tool_manager from AbstractClient (FEAT-524: clients are memory-less; live.py keeps its own realtime session model instead)
  • Uses same credential system (api_key, vertexai, credentials_file)
  • Integrates AbstractTool via LiveToolAdapter
  • Returns LiveVoiceResponse with usage metadata
Parameter Type Default Description
model Optional[Union[str, GoogleVoiceModel]] None Model identifier (defaults to latest native audio model)
api_key Optional[str] None Google API key (falls back to GOOGLE_API_KEY env var)
vertexai bool False Use Vertex AI instead of Gemini API
project Optional[str] None Vertex AI project ID
location Optional[str] None Vertex AI location
credentials_file Optional[Union[str, Path]] None Path to service account credentials
voice_name str 'Puck' Voice for speech synthesis (Puck, Charon, Kore, etc.)
language str 'en-US' Language code (en-US, es-ES, etc.)
preset Optional[str] None LLM preset name
tools Optional[List[Union[str, AbstractTool]]] None List of tools to register
use_tools bool False Enable tool usage
tool_manager Optional[ToolManager] None Existing ToolManager instance
debug bool False Enable debug mode
**kwargs {} Additional AbstractClient params (temperature, top_k, etc.)

Attributes:

Attribute Type Description
client_type str
client_name str
supports_tool_loop bool
provider_keys tuple[str, ...]
models type[Enum]
studio_offered bool
voice_capabilities VoiceCapabilities Describe what Gemini Live natively supports today (FEAT-418). This descriptor reflects current behavior only — flags below are flipped to True by later FEAT-418 tasks as each capability is actually implemented. supports_top_p/supports_per_call_inference are True as of TASK-2166 (per-call temperature/max_tokens/ top_p now reach _build_live_config()); supports_per_call_voice is True as of TASK-2167 (per-call voice override, validated against voice_catalog with a warned fallback) — canonical role also lands in TASK-2167; emits_reconnect_signal/ supports_session_resumption are True as of TASK-2168 (GoAway/1008-close now also set metadata["reconnect_required"], and a session-resumption handle is requested on every connect and retained across reconnects). The provider conformance kit (TASK-2176) asserts descriptor-vs-behavior consistency, so this must never claim a capability ahead of the code that provides it.

Method GeminiLiveClient.get_client

Return the underlying genai.Client instance.

Required by AbstractClient (abstract method).

get_client() -> genai.Client

Returns: genai.Client

Method GeminiLiveClient.stream_voice

Stream bidirectional voice interaction.

This is the main method for voice interactions. It handles:

  • Audio streaming to the model
  • Receiving audio/text responses
  • Tool execution (via tool_manager)
  • Usage tracking

stream_voice(audio_iterator: AsyncIterator[bytes], system_prompt: Optional[str] = None, session_id: Optional[str] = None, user_id: Optional[str] = None, stt_only: bool = False, options: Optional[VoiceStreamOptions] = None, **kwargs) -> AsyncIterator[LiveVoiceResponse]

Parameter Type Default Description
audio_iterator AsyncIterator[bytes] Async iterator yielding audio chunks (PCM 16-bit, 16kHz)
system_prompt Optional[str] None Optional system instructions
session_id Optional[str] None Session identifier for tracking
user_id Optional[str] None User identifier
stt_only bool False When True, run in STT-only mode: Gemini transcribes input but does NOT generate a model response (no response_chunk, no audio output). Only role="user" transcription frames are emitted (FEAT-418 — previously carried in metadata["user_transcription"], now removed). Default False = full-duplex (unchanged behavior).
options Optional[VoiceStreamOptions] None Optional VoiceStreamOptions projection (FEAT-418). temperature/max_tokens/top_p/voice/ enable_input_transcription/enable_output_transcription are derived from it when not explicitly present in **kwargs — an explicit kwarg always wins over options.
**kwargs {} Additional configuration. temperature, max_tokens, top_p, voice (per-call voice override, validated against the descriptor's voice_catalog), enable_input_transcription, enable_output_transcription are recognized here and take precedence over options (FEAT-418).

Returns: AsyncIterator[LiveVoiceResponse]

Method GeminiLiveClient.ask

Send text input and receive voice response.

Useful for testing or text-to-speech scenarios.

ask(question: str, system_prompt: Optional[str] = None, history: Optional[Sequence[HistoryMessage]] = None, **kwargs) -> AsyncIterator[LiveVoiceResponse]

Parameter Type Default Description
question str Text input to send
system_prompt Optional[str] None Optional system instructions
history Optional[Sequence[HistoryMessage]] None Accepted for AbstractClient conformance (FEAT-524) but NOT replayed — the Gemini Live API maintains its own realtime session, which spec §1 keeps out of scope.
**kwargs {} Additional configuration

Returns: AsyncIterator[LiveVoiceResponse]

Method GeminiLiveClient.close

Close the client and clean up resources.

close() -> None

Method GeminiLiveClient.ask_stream

Deprecated alias for stream_voice.

ask_stream(*args, **kwargs)

Parameter Type Default Description
*args ()
**kwargs {}

Method GeminiLiveClient.batch_ask

Deprecated alias for send_text.

batch_ask(*args, **kwargs)

Parameter Type Default Description
*args ()
**kwargs {}

Method GeminiLiveClient.invoke

Not supported: GeminiLiveClient is a realtime voice client.

Defined only to satisfy AbstractClient's @abstractmethod contract so the class can be instantiated. Use stream_voice() for the realtime flow.

invoke(*args, **kwargs)

Parameter Type Default Description
*args ()
**kwargs {}

Method GeminiLiveClient.resume

Not supported: GeminiLiveClient does not implement suspend/resume.

resume(*args, **kwargs)

Parameter Type Default Description
*args ()
**kwargs {}

Alias GoogleVoiceModel

Re-exported from parrot.models.google.GoogleVoiceModel.

Alias LiveCompletionUsage

Re-exported from parrot.models.voice.LiveCompletionUsage.

Class LiveToolAdapter

Adapter to convert AI-Parrot AbstractTool instances to Gemini Live API function declarations and handle execution/response formatting.

Reuses patterns from GoogleGenAIClient._prepare_tool_definitions()

Parameter Type Default Description
tool_manager Optional[ToolManager] None ToolManager instance from AbstractClient
tools Optional[List[Any]] None Additional tool instances
logger Optional[Any] None Logger instance

Attributes:

Attribute Type Description
tool_map Dict[str, Any]

Method LiveToolAdapter.get_function_declarations

Convert all tools to Gemini Live API function declarations.

get_function_declarations() -> List[types.FunctionDeclaration]

Returns: List[types.FunctionDeclaration] — List of types.FunctionDeclaration objects

Method LiveToolAdapter.execute_tool

Execute a tool call and return a (FunctionResponse, display_data) tuple.

execute_tool(function_call: Any, context: Optional[Dict[str, Any]] = None) -> tuple[types.FunctionResponse, Optional[Dict[str, Any]]]

Parameter Type Default Description
function_call Any
context Optional[Dict[str, Any]] None

Returns: tuple[types.FunctionResponse, Optional[Dict[str, Any]]]

Alias LiveToolCall

Re-exported from parrot.models.voice.LiveToolCall.

Alias LiveVoiceResponse

Re-exported from parrot.models.voice.LiveVoiceResponse.

Alias VoiceTurnMetadata

Re-exported from parrot.models.voice.VoiceTurnMetadata.

Function create_live_client

Factory function to create a GeminiLiveClient.

create_live_client(model: Optional[Union[str, GoogleVoiceModel]] = None, voice_name: str = 'Puck', tools: Optional[List[AbstractTool]] = None, use_tools: bool = True, **kwargs) -> GeminiLiveClient

Parameter Type Default Description
model Optional[Union[str, GoogleVoiceModel]] None Model identifier (defaults to latest native audio)
voice_name str 'Puck' Voice for synthesis
tools Optional[List[AbstractTool]] None List of tools to register
use_tools bool True Enable tool usage
**kwargs {} Additional client configuration

Returns: GeminiLiveClient — Configured GeminiLiveClient instance

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally