Skip to content

xai TTS: documented API parameters (optimize_streaming_latency, speed, text_normalization) cannot be passed #6077

@moamen-bytesai

Description

@moamen-bytesai

Plugin / version

livekit-plugins-xai 1.6.0, livekit-agents 1.6.0, Python 3.13

Verified on the latest release: inspected the livekit-plugins-xai 1.6.0 wheel from PyPI (uploaded 2026-06-11) and the current main branch (livekit-plugins/livekit-plugins-xai/livekit/plugins/xai/tts.py) — TTS.__init__ and _connect_ws are unchanged; none of the parameters below are exposed. Behavior was originally observed in production on 1.5.17, which is code-identical.

Problem

xAI's TTS WebSocket endpoint (wss://api.x.ai/v1/tts) accepts several connection query parameters documented in the xAI TTS docs:

  • optimize_streaming_latency (0/1/2) — first-chunk latency mode
  • speed (0.7–1.5) — speaking-rate multiplier
  • text_normalization (bool) — spoken-form normalization of numbers/abbreviations

The plugin's TTS.__init__ only accepts api_key, voice, language, tokenizer, http_session (keyword-only, no **kwargs), and _connect_ws sends only voice, language, codec, sample_rate. There is no way to set any of the parameters above — passing them raises TypeError: __init__() got an unexpected keyword argument.

Why it matters

optimize_streaming_latency in particular has a large effect on real-time voice agents. Measured against the live endpoint (same text, voice ara, 4 runs each):

level generation TTFB
0 (plugin's effective behavior) mean 741 ms
2 mean 379 ms

For a voice-agent use case this nearly halves TTS time-to-first-byte, but plugin users are stuck on the slowest setting.

Expected behavior

TTS.__init__ exposes these documented parameters (and forwards them as WS query params), similar to how other TTS plugins expose their providers' generation options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions