diff --git a/litellm/litellm_core_utils/realtime_streaming.py b/litellm/litellm_core_utils/realtime_streaming.py index bc2c77e4348..5d7a5bfe318 100644 --- a/litellm/litellm_core_utils/realtime_streaming.py +++ b/litellm/litellm_core_utils/realtime_streaming.py @@ -295,9 +295,9 @@ class RealTimeStreaming: safe_msg = str(e) or "I'm sorry, that request was blocked by the content filter." # Cancel any in-flight response before speaking the warning. # This handles the race where create_response fired before we could intercept. - await self.backend_ws.send(json.dumps({"type": "response.cancel"})) - # Ask OpenAI to speak the warning — TTS audio plays naturally in the client - await self.backend_ws.send( + await self._send_to_backend(json.dumps({"type": "response.cancel"})) + # Ask the model to speak the warning — TTS audio plays naturally in the client + await self._send_to_backend( json.dumps( { "type": "response.create", diff --git a/litellm/llms/gemini/realtime/transformation.py b/litellm/llms/gemini/realtime/transformation.py index 17a8418bb3c..51c4b9e71e7 100644 --- a/litellm/llms/gemini/realtime/transformation.py +++ b/litellm/llms/gemini/realtime/transformation.py @@ -312,13 +312,17 @@ class GeminiRealtimeConfig(BaseRealtimeConfig): if _system_instruction is not None and isinstance(_system_instruction, str): session["instructions"] = _system_instruction if _model is not None and isinstance(_model, str): - # Strip "models/" prefix if present to match OpenAI model name format. - # Use removeprefix (not strip) — strip removes individual chars, not a substring. - session["model"] = ( - _model[len("models/"):] - if _model.startswith("models/") - else _model - ) + # Normalise to bare model name for OpenAI compatibility. + # Vertex AI uses a full resource path: + # projects/{project}/locations/{location}/publishers/google/models/{model} + # Google AI Studio uses: + # models/{model} + if "/models/" in _model: + session["model"] = _model.split("/models/")[-1] + elif _model.startswith("models/"): + session["model"] = _model[len("models/"):] + else: + session["model"] = _model return OpenAIRealtimeStreamSessionEvents( type="session.created",