v1

latestOpenAPI 3.1.02026-07-13212942.9 KB
Streaming

Stream Text To Speech

Stream synthesised speech as Server-Sent Events (SSE).

Authenticates the caller, checks quota, and delegates synthesis to the versioned handler registered in voice_registry["streaming_text_to_speech"]. Concurrency is enforced per-token via Redis before the handler is invoked.

Args: tts_request: TTS parameters (text, voice, model, format, etc.). background_tasks: FastAPI background-task queue (passed through to the handler). token_service: Injected token validation service. _request: Raw FastAPI Request object used for rate-limiting and app.state access. version: API version extracted from the version request header. x_api_key: Bearer API key from the x-api-key header.

Returns: StreamingResponse: SSE stream of audio chunks.

Raises: UsageLimitExceeded: When the token has exhausted its quota. TooManyConcurrentRequests: When the per-token concurrency cap is reached.

post/text_to_speech/streaming

Headers

X-Api-Keystring

Request body

model_id'async_flash_v1.0' | 'async_flash_v1.5' | 'async_pro_v1.0'
normalizeboolean

Whether to normalize the input text. If False, the input text will be used as is.

experimental_streaming_modeboolean

Whether to stream audio in experimental mode.

experimental_stp_v2boolean

Use v2 STP prompt format (pr_speech_start/end). Only has effect when experimental_streaming_mode=True.

transcriptstring required
previous_request_idstring uuid nullable

ID returned in the X-Request-Id header of a previous TTS response. When provided, the last sentence of that request is appended AFTER the voice reference, enabling voice continuity across requests. Effective only for STP-based models (async_flash_v1.5, async_pro_v1.0). Silently falls back to the voice reference alone when the entry has expired, is missing, or belongs to a different token / voice / model / experimental_stp_v2 setting.

language'en' | 'fr' | 'it' | 'de' | 'es' | 'pt' | 'ar' | 'ru' | 'ro' | 'ja' | 'he' | 'hy' | 'tr' | 'hi' | 'zh' | 'cmn' | 'ur'
lang_detection_mode'llm' | 'fasttext'
sentence_splitter_chunk_sizeinteger nullable

Number of characters to split the transcript into chunks. None if based on sentences.

durationnumber nullable
stabilityinteger

TTS's stability.

speed_controlnumber

TTS's speed control.

Example request

{
  "transcript": "Hello, world!"
}

Response

Successful Response

{"stackTrail":"paths:/text_to_speech/streaming:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}