Fix Grok Realtime voice type validation for server responses

The Grok API now returns prefixed voice names (e.g. "human_Ara") in
session.updated events, causing Pydantic validation errors. Widen the
voice field type from GrokVoice to GrokVoice | str to accept both
user-facing names and server-returned values.
This commit is contained in:
Mark Backman
2026-02-11 18:04:20 -05:00
parent e75ccd9c2f
commit 16b060d9e9

View File

@@ -216,7 +216,7 @@ class SessionProperties(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
instructions: Optional[str] = None
voice: Optional[GrokVoice] = "Ara"
voice: Optional[GrokVoice | str] = "Ara"
turn_detection: Optional[TurnDetection] = Field(
default_factory=lambda: TurnDetection(type="server_vad")
)