websockets.exceptions.ConnectionClosedError: recei...
# ask-ai
b
websockets.exceptions.ConnectionClosedError: received 1008 (policy violation) models/gemini-2.5-flash-preview-09-2025 is not found for API version v1beta, or is not supported for bidiGenerateContent. C; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-09-2025 is not found for API version v1beta, or is not supported for bidiGenerateContent. C {“pid”: 55946, “job_id”: “AJ_GQG8TBoJUnRL”} 2025-10-16 102255,654 - ERROR livekit.plugins.google - Error in _main_task Traceback (most recent call last): File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py”, line 591, in _main_task async with self._client.aio.live.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/opt/anaconda3/lib/python3.12/contextlib.py”, line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.12/site-packages/google/genai/live.py”, line 1057, in connect logger.info(await ws.recv(decode=False)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.12/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-09-2025 is not found for API version v1beta, or is not supported for bidiGenerateContent. C; then sent 1008 (policy violation) models/gemini-2.5-flash-preview-09-2025 is not found for API version v1beta, or is not supported for bidiGenerateContent. C The above exception was the direct cause of the following exception: Traceback (most recent call last): File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.12/site-packages/livekit/agents/utils/log.py”, line 16, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/madhavsharma/uplevel-livekit-worker/venv/lib/python3.12/site-packages/livekit/plugins/google/beta/realtime/realtime_api.py”, line 641, in _main_task raise APIConnectionError(message=“Failed to connect to Gemini Live”) from
t
Thanks for reaching out, Madhav. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like the error is happening because the model ID
gemini-2.5-flash-preview-09-2025
isn’t recognized or supported for the Gemini Live API in LiveKit. No worries though! Here are the model IDs that are supported: •
gemini-2.0-flash-exp
•
gemini-2.0-flash-live-001
•
gemini-2.5-flash-preview-native-audio-dialog
•
gemini-2.5-flash-exp-native-audio-thinking-dialog
•
gemini-2.5-flash-native-audio-preview-09-2025
To help you get this sorted out, here’s what you can do: 1. Swap out
gemini-2.5-flash-preview-09-2025
with
gemini-2.5-flash-native-audio-preview-09-2025
in your model configuration. 2. Make sure you’re using the Realtime API (bidiGenerateContent) and that the
RealtimeModel
class is set up properly. 3. Double-check that you’re on the right API version (
v1beta
) and using supported model IDs. Here’s a quick example in Python to guide you:
Copy code
from livekit.plugins.google import RealtimeModel

realtime_model = RealtimeModel(
    model="gemini-2.5-flash-native-audio-preview-09-2025",  # Correct model ID
    api_key="your-api-key"
)
Using the correct model ID like this should clear up the connection error. If you run into any more questions or need a hand, feel free to reach out—I’m here to help! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py | Gemini Live API plugin | LiveKit Docs
b
which is latest and best model
t
I'm happy to share some information about the latest models for the Gemini Live API! The 2.5 generation models come with some exciting advanced features like native audio processing and improved dialog capabilities. Here’s a quick overview to help you get started: • Latest Models: ◦ `gemini-2.5-flash-preview-native-audio-dialog`: Great for native audio and dialog. ◦ `gemini-2.5-flash-exp-native-audio-thinking-dialog`: An experimental model that brings enhanced reasoning and dialog features. ◦ `gemini-2.5-flash-native-audio-preview-09-2025`: A native audio preview model. • Stable Models: ◦ `gemini-2.0-flash-exp`: The default choice for Vertex AI implementations. ◦ `gemini-2.0-flash-live-001`: The go-to for Google Gemini API implementations. Here’s a little recommendation to guide you: • If you’re aiming for production stability,
gemini-2.0-flash-exp
or
gemini-2.0-flash-live-001
would be solid picks. • If you want to explore the latest features,
gemini-2.5-flash-preview-native-audio-dialog
or
gemini-2.5-flash-exp-native-audio-thinking-dialog
are fantastic options, though just keep in mind they might have some limitations with function calling. If you’d like, feel free to share more about your specific use case or what’s most important to you—whether that’s function calling, native audio, or reasoning capabilities. I’m here to help you find the perfect model that fits your needs! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py | plugins/google/src/beta/realtime/realtime_api.ts | Gemini Live API plugin | LiveKit Docs