-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(google): improve error message for model/API mismatch in Realtime API #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… API When users configure a Gemini API model (e.g., gemini-2.5-flash-native-audio-preview-09-2025) with VertexAI, or vice versa, they receive a cryptic WebSocket 1008 policy violation error. This makes it difficult to diagnose the root cause. This change detects 1008 errors that likely indicate a model/API mismatch and appends a helpful hint to the error message, suggesting the correct model name to use. The hint only appears when: - A WebSocket 1008 policy violation occurs - The model name pattern doesn't match the API being used Example improved error: ``` Failed to connect to Gemini Live Hint: Model 'gemini-2.5-flash-native-audio-preview-09-2025' appears to be a Gemini API model, but VertexAI is enabled. VertexAI requires different model names (prefixed with 'gemini-live-'). Try using model='gemini-live-2.5-flash-preview-native-audio-09-2025' instead. ``` Fixes: livekit/livekit#4026
📝 WalkthroughWalkthroughA new helper function Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py (9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Comment |
Summary
This PR improves error messages when users accidentally configure a Gemini API model with VertexAI (or vice versa) in the Google Realtime plugin. Currently, users receive a cryptic WebSocket 1008 policy violation error that doesn't explain the root cause.
Problem
When using the Google Realtime plugin with incorrect model/API combinations:
websockets.exceptions.ConnectionClosedError: received 1008 (policy violation)Example Scenario
A user tries to use VertexAI with a Gemini API model name:
Current error:
After this fix:
Solution
Added a helper function
_get_model_mismatch_hint()that:The hint is appended to both:
APIConnectionErrorexceptionsThis provides immediate, actionable feedback without blocking any valid configurations or making assumptions about future model naming patterns.
Testing
Fixes livekit/livekit#4026
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.