Text to Speech Streaming API
The Text to Speech Streaming API accepts text and a voice_id, then returns
MP3 or WAV audio through an HTTP stream or WebSocket messages. The Base URL is
https://api.kitschlabs.com.
Endpoints
| Transport | Endpoint | Purpose |
|---|---|---|
POST | /v1/text-to-speech/{voice_id}/stream | Receive audio binary over HTTP |
WSS | /v1/text-to-speech/{voice_id}/stream-input | Send text and receive audio chunks over WebSocket |
Select a voice_id from the GET /v1/voices response. Supported
output_format values are mp3_44100_128 and wav_24000.
HTTP Streaming API
Send the same JSON body as standard speech generation and receive audio binary in the selected format as a stream.
curl --request POST \
"https://api.kitschlabs.com/v1/text-to-speech/<VOICE_ID>/stream?output_format=mp3_44100_128" \
--header "xi-api-key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"text": "Have a great day today.",
"language_code": "en"
}' \
--output speech.mp3
| Field | Location | Type | Required | Description |
|---|---|---|---|---|
voice_id | path | string | Yes | Voice ID to use |
output_format | query | string | No | mp3_44100_128 or wav_24000 |
text | body | string | Yes | Text to synthesize |
language_code | body | string | No | One of en, ko, ja, or zh |
instruct | body | string | No | Natural-language instructions for the speaking style |
A successful request returns a binary response with an audio/mpeg or
audio/wav Content-Type.
WebSocket Streaming API
Connect with output_format and language_code as query parameters.
wss://api.kitschlabs.com/v1/text-to-speech/<VOICE_ID>/stream-input?output_format=mp3_44100_128&language_code=en
Authenticate with an xi-api-key header in the WebSocket handshake, or include
xi_api_key in the first JSON message. Send the text for one audio output in
messages, then set flush to true in the final message.
{"text":"Have a great ","xi_api_key":"<API_KEY>"}
{"text":"day today.","flush":true}
The server returns base64 audio chunks.
{"audio":"<BASE64_AUDIO_CHUNK>","isFinal":false}
The final message for an audio output is:
{"audio":null,"isFinal":true}
Send an empty text value to close the connection.
{"text":""}
text must be a string and flush must be a boolean. An invalid message or
request may return JSON containing error.status and error.message.
See the Text to Speech API for HTTP error codes and retry guidance.