From 492c9702ee4de57415e38e397691a5845001bb6d Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Fri, 1 May 2026 09:16:52 -0400 Subject: [PATCH] fix(xai/realtime): pass model as query param on connect xAI's Voice Agent API selects the model via the ?model= query parameter on the WebSocket URL; it cannot be changed later via session.update. The Grok Realtime service was setting the model in Settings but never including it in the connection URL, so every session silently fell back to the deprecated default grok-voice-fast-1.0. Append the model from Settings to the WebSocket URL on connect, and default to the recommended grok-voice-think-fast-1.0. --- src/pipecat/services/xai/realtime/llm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pipecat/services/xai/realtime/llm.py b/src/pipecat/services/xai/realtime/llm.py index 448b5e339..64c8ebb59 100644 --- a/src/pipecat/services/xai/realtime/llm.py +++ b/src/pipecat/services/xai/realtime/llm.py @@ -17,6 +17,7 @@ from collections.abc import Mapping from dataclasses import dataclass, field from dataclasses import fields as dataclass_fields from typing import Any +from urllib.parse import quote from loguru import logger @@ -235,7 +236,7 @@ class GrokRealtimeLLMService(LLMService): """ # 1. Initialize default_settings with hardcoded defaults default_settings = self.Settings( - model=None, + model="grok-voice-think-fast-1.0", system_instruction=None, temperature=None, max_tokens=None, @@ -533,8 +534,13 @@ class GrokRealtimeLLMService(LLMService): if self._websocket: return + # Model is selected via query param at connection time; xAI does + # not support changing it via session.update. + model = assert_given(self._settings.model) + uri = f"{self.base_url}?model={quote(model, safe='')}" + self._websocket = await websocket_connect( - uri=self.base_url, + uri=uri, additional_headers={ "Authorization": f"Bearer {self.api_key}", },