Skip to content

Commit 47655a8

Browse files
authored
allow configurable api version in gemini realtime (#1656)
1 parent cd728e6 commit 47655a8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.changeset/modern-pandas-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-plugins-google": patch
3+
---
4+
5+
allow configurable api version in gemini realtime

livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime/api_proto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ..._utils import _build_gemini_ctx, _build_tools
88

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

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

livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime/realtime_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Capabilities:
8383
class ModelOptions:
8484
model: LiveAPIModels | str
8585
api_key: str | None
86+
api_version: str
8687
voice: Voice | str
8788
response_modalities: list[Modality] | None
8889
vertexai: bool
@@ -107,6 +108,7 @@ def __init__(
107108
instructions: str | None = None,
108109
model: LiveAPIModels | str = "gemini-2.0-flash-exp",
109110
api_key: str | None = None,
111+
api_version: str = "v1alpha",
110112
voice: Voice | str = "Puck",
111113
modalities: list[Modality] = [Modality.AUDIO],
112114
enable_user_audio_transcription: bool = True,
@@ -136,6 +138,7 @@ def __init__(
136138
Args:
137139
instructions (str, optional): Initial system instructions for the model. Defaults to "".
138140
api_key (str or None, optional): Google Gemini API key. If None, will attempt to read from the environment variable GOOGLE_API_KEY.
141+
api_version (str, optional): The version of the API to use. Defaults to "v1alpha".
139142
modalities (list[Modality], optional): Modalities to use, such as ["TEXT", "AUDIO"]. Defaults to ["AUDIO"].
140143
model (str or None, optional): The name of the model to use. Defaults to "gemini-2.0-flash-exp".
141144
voice (api_proto.Voice, optional): Voice setting for audio outputs. Defaults to "Puck".
@@ -187,6 +190,7 @@ def __init__(
187190
self._rt_sessions: list[GeminiRealtimeSession] = []
188191
self._opts = ModelOptions(
189192
model=model,
193+
api_version=api_version,
190194
api_key=self._api_key,
191195
voice=voice,
192196
enable_user_audio_transcription=enable_user_audio_transcription,
@@ -289,7 +293,7 @@ def __init__(
289293
tools=tools,
290294
)
291295
self._client = genai.Client(
292-
http_options=HttpOptions(api_version="v1alpha"),
296+
http_options=HttpOptions(api_version=self._opts.api_version),
293297
api_key=self._opts.api_key,
294298
vertexai=self._opts.vertexai,
295299
project=self._opts.project,

0 commit comments

Comments
 (0)