Based on the 404 error you got, when you set `enab...
# ask-ai
r
Based on the 404 error you got, when you set
enable_affective_dialog=True
, the code automatically tried to use
v1alpha
, but that API endpoint returned 404, meaning: • Your API key doesn't have access to the alpha API • The alpha API may not be publicly available yet • You may need to request access from Google The default stable API works without these parameters, which is why commenting them out fixed the connection issue.
t
Thanks for reaching out, Phanos. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you please help me understand a bit more about how this issue is connected to LiveKit? Are you seeing this 404 error when you're using LiveKit's APIs or maybe while working with a particular feature? I'm here to help you get to the bottom of this!
r
I see this error when i use the gemini native audio realtime api
t
I'm sorry you're encountering the 404 error! This usually happens because some preview features, like
enable_affective_dialog
, need the
v1alpha
API version endpoint, which isn’t the default setting. When you enable this feature, the LiveKit Google plugin kindly switches the
api_version
to
v1alpha
automatically—unless you’ve already specified a version. To help you get this sorted out, here are a few steps you can follow: 1. Use a compatible model: Please make sure you're using the
gemini-2.5-flash-native-audio-preview-09-2025
model, as it supports preview features like affective dialog and proactivity. 2. Verify your API key setup: Double-check that your Gemini API key is properly configured, either through the
GOOGLE_API_KEY
environment variable or passed directly to the
RealtimeModel
constructor. 3. Avoid overriding `api_version`: It’s best not to manually set the
api_version
parameter, since that can stop the plugin from switching to
v1alpha
when those special features are turned on. Here’s an example of a working configuration that you might find helpful:
Copy code
llm=google.beta.realtime.RealtimeModel(
    model="gemini-2.5-flash-native-audio-preview-09-2025",
    proactivity=True,
    enable_affective_dialog=True
)
This setup ensures the plugin uses the right
v1alpha
endpoint for those preview features, while keeping your authentication and model compatibility just right. Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | plugins/google/src/beta/realtime/realtime_api.ts | realtime/gemini_live_vision.py | Gemini Live API plugin | LiveKit Docs
r
but i get this error when i use it. cuments\GitHub\chickytutor3009\env\Lib\site-packages\websockets\asyncio\client.py", line 114, in handshake raise self.protocol.handshake_exc File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\client.py", line 325, in parse self.process_response(response) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\client.py", line 142, in process_response raise InvalidStatus(response) websockets.exceptions.InvalidStatus: server rejected WebSocket connection: HTTP 404 2025-10-06 210535,848 - ERROR - livekit.plugins.google - Error in _main_task Traceback (most recent call last): File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 640, in _main_task async with self._client.aio.live.connect( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ model=self._opts.model, config=config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as session: ^ File "C:\Python313\Lib\contextlib.py", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\google\genai\live.py", line 1057, in connect async with ws_connect( ~~~~~~~~~~^ uri, additional_headers=headers, **self._api_client._websocket_ssl_ctx ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as ws: ^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\asyncio\client.py", line 587, in aenter return await self ^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\asyncio\client.py", line 543, in __await_impl__ await self.connection.handshake( ...<2 lines>... ) File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\asyncio\client.py", line 114, in handshake raise self.protocol.handshake_exc File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\client.py", line 325, in parse self.process_response(response) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\websockets\client.py", line 142, in process_response raise InvalidStatus(response) websockets.exceptions.InvalidStatus: server rejected WebSocket connection: HTTP 404 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\livekit\agents\utils\log.py", line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 690, in _main_task raise APIConnectionError(message="Failed to connect to Gemini Live") from e livekit.agents._exceptions.APIConnectionError: Failed to connect to Gemini Live (body=None, retryable=True) 2025-10-06 210535,848 - ERROR livekit.plugins.google - Error in _main_task Traceback (most recent call last): File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\livekit\plugins\google\beta\realtime\realtime_api.py", line 640, in _main_task async with self._client.aio.live.connect( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ model=self._opts.model, config=config ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as session: ^ File "C:\Python313\Lib\contextlib.py", line 214, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\phano\OneDrive\Documents\GitHub\chickytutor3009\env\Lib\site-packages\google\genai\live.py", line 1057, in connect async with ws_connect( ~~~~~~~~~~^ uri, additional_headers=headers, **self._api_client._websocket_ssl_ctx ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) as ws: ^ File "C:\Users\phano\OneDrive\Do
t
It looks like you're encountering a WebSocket connection error (HTTP 404) because the
v1alpha
API version endpoint, which is needed for features like
enable_affective_dialog
, might not be accessible with your current setup. Don’t worry, I’m here to help you through this! Here are some friendly steps to get this sorted out: 1. Use the correct model: Please double-check that you’re using the exact model name
gemini-2.5-flash-native-audio-preview-09-2025
. This model supports the preview features you’re trying to use. 2. Set the API version: Make sure to explicitly set
api_version="v1alpha"
in your client configuration if it’s not being picked up automatically. 3. Verify API key access: It’s important to confirm that your Google Cloud project has access to the Gemini Live API preview features and that your API key is authorized for this. 4. Set authentication: You can use the
GOOGLE_API_KEY
environment variable or pass the key directly to the
RealtimeModel
constructor. If you’re using Vertex AI, please ensure
GOOGLE_APPLICATION_CREDENTIALS
points to your service account key file. 5. Check network policies: Sometimes firewalls or network restrictions can block WebSocket connections to Google’s API endpoints, so it’s worth verifying that there’s nothing in your network setup causing this. If you’ve tried all these steps and the issue is still there, it might help to double-check your access to the Gemini Live API preview program through Google’s developer console. And of course, don’t hesitate to reach out to LiveKit and Google support—they’re there to help you too! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py | plugins/google/src/beta/realtime/realtime_api.ts | realtime/gemini_realtime_api.py