Any insights on this error: ```websockets.excepti...
# ask-ai
d
Any insights on this error:
Copy code
websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera
    return await anext(self.gen)

Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/livekit/plugins/google/realtime/realtime_api.py", line 717, in _main_task
  File "/app/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
    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)
Error in _main_task
Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/livekit/plugins/google/realtime/realtime_api.py", line 667, in _main_task
    async with self._client.aio.live.connect(
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        model=self._opts.model, config=config
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ) as session:
    ^
  File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/google/genai/live.py", line 1093, in connect
    raw_response = await ws.recv(decode=False)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/websockets/asyncio/connection.py", line 322, in recv
    raise self.protocol.close_exc from self.recv_exc
websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-native-audio-dialog is not found for API version v1beta, or is not supported for bidiGenera

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 16, in async_fn_logs
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/livekit/plugins/google/realtime/realtime_api.py", line 717, 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)
t
Thanks for reaching out, W. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I looked at the error you pasted. It indicates the WebSocket was closed with code 1008 (policy violation) and the message says the model
gemini-2.5-flash-preview-native-audio-dialog
is not found for API version
v1beta
or not supported for bidirectional generation. That points to one of these root causes: • The model name is invalid, deprecated, or not publicly available. • The requested model does not support the realtime/bidirectional (bidi) Live API. • Your project/account lacks access or permissions to use that experimental model. What you can do next 1. Try a supported realtime model: ◦ Use
gemini-2.5-flash-native-audio-preview-09-2025
or
gemini-2.0-flash-exp
with
google.realtime.RealtimeModel
. 1. Confirm you’re using the Realtime plugin (not a standard LLM class) when creating the session. 2. Verify authentication & permissions: ◦ Ensure
GOOGLE_APPLICATION_CREDENTIALS
or
GOOGLE_API_KEY
is set and the service account/project has access to the Gemini/Live APIs. 1. Check experimental/preview access: ◦ Native audio / Live API models can be preview-only and may require enrollment or whitelisting. If you want, share: • the exact model string you’re passing in code, • the snippet that creates the
RealtimeModel
session, • and whether you’re using a service account key or API key. I can then point out precisely what to change. Would you like to paste that snippet? Sources: Gemini Live API plugin | LiveKit docs