@@ -83,6 +83,7 @@ class Capabilities:
8383class 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