v1

latestOpenAPI 3.1.02026-07-13212942.9 KB
Synchronous

Sync Text To Speech

Synthesise speech and return the audio file directly.

Validates quota, synthesises audio via :func:_generate_tts_bytes, writes the result to a temporary file, and returns it as a FileResponse. The temp file is deleted in a background task after the response is sent.

Args: tts_request: TTS parameters (text, voice, model, output format, etc.). background_tasks: FastAPI background-task queue used to schedule temp-file cleanup. token_service: Injected token validation service. _request: Raw FastAPI Request used for rate-limiting. x_api_key: Bearer API key from the x-api-key header. version: API version extracted from the version request header. tts_service_stub: gRPC stub connected to the XCODEC synthesis server.

Returns: FileResponse: Audio file in the format requested by tts_request.output_format.

Raises: UsageLimitExceeded: When the token has exhausted its quota.

post/text_to_speech

Headers

version'v1'
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