Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-pandas-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-google": patch
---

allow configurable api version in gemini realtime
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ..._utils import _build_gemini_ctx, _build_tools

LiveAPIModels = Literal["gemini-2.0-flash-001",]
LiveAPIModels = Literal["gemini-2.0-flash-exp"]

Voice = Literal["Puck", "Charon", "Kore", "Fenrir", "Aoede"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Capabilities:
class ModelOptions:
model: LiveAPIModels | str
api_key: str | None
api_version: str
voice: Voice | str
response_modalities: list[Modality] | None
vertexai: bool
Expand All @@ -107,6 +108,7 @@ def __init__(
instructions: str | None = None,
model: LiveAPIModels | str = "gemini-2.0-flash-exp",
api_key: str | None = None,
api_version: str = "v1alpha",
voice: Voice | str = "Puck",
modalities: list[Modality] = [Modality.AUDIO],
enable_user_audio_transcription: bool = True,
Expand Down Expand Up @@ -136,6 +138,7 @@ def __init__(
Args:
instructions (str, optional): Initial system instructions for the model. Defaults to "".
api_key (str or None, optional): Google Gemini API key. If None, will attempt to read from the environment variable GOOGLE_API_KEY.
api_version (str, optional): The version of the API to use. Defaults to "v1alpha".
modalities (list[Modality], optional): Modalities to use, such as ["TEXT", "AUDIO"]. Defaults to ["AUDIO"].
model (str or None, optional): The name of the model to use. Defaults to "gemini-2.0-flash-exp".
voice (api_proto.Voice, optional): Voice setting for audio outputs. Defaults to "Puck".
Expand Down Expand Up @@ -187,6 +190,7 @@ def __init__(
self._rt_sessions: list[GeminiRealtimeSession] = []
self._opts = ModelOptions(
model=model,
api_version=api_version,
api_key=self._api_key,
voice=voice,
enable_user_audio_transcription=enable_user_audio_transcription,
Expand Down Expand Up @@ -289,7 +293,7 @@ def __init__(
tools=tools,
)
self._client = genai.Client(
http_options=HttpOptions(api_version="v1alpha"),
http_options=HttpOptions(api_version=self._opts.api_version),
api_key=self._opts.api_key,
vertexai=self._opts.vertexai,
project=self._opts.project,
Expand Down