Skip to main content

Usage guide

Setup, environment variables, and Python/JavaScript/Go usage examples.

XaiRealtime

Realtime speech-to-speech integration for the xAI Grok Realtime API. Wraps an xAI Grok realtime model so it can be used as a full speech-to-speech provider within the runtime. Configuration is supplied through an XaiRealtimeConfig instance and resolved into a flat parameter map for the runtime.

Constructor

api_key
str | None
xAI API key. When omitted, the value of the XAI_API_KEY environment variable is used.
config
XaiRealtimeConfig | None
Provider configuration. When omitted, a default XaiRealtimeConfig is used.

aclose

Release any resources held by the integration. This implementation performs no work and exists so the integration can be used interchangeably with providers that require teardown.

cleanup

Clean up the integration by delegating to aclose.

XaiRealtimeConfig

Fields

model
str
default:"grok-realtime"
voice
str
default:"Ara"
modalities
List[str]
default:"…"
temperature
float
default:"0.8"
max_response_output_tokens
Union[int, str]
default:"inf"
turn_detection
Optional[TurnDetectionConfig]
default:"…"
input_audio_transcription
Optional[InputAudioTranscriptionConfig]
default:"…"
tool_choice
str
default:"auto"
base_url
Optional[str]

TurnDetectionConfig

Fields

type
str
default:"server_vad"
threshold
float
default:"0.5"
prefix_padding_ms
int
default:"300"
silence_duration_ms
int
default:"200"
create_response
bool
default:"True"
interrupt_response
bool
default:"True"

InputAudioTranscriptionConfig

Fields

model
str
default:"gpt-4o-mini-transcribe"