Skip to main content
GET
Python WebSocket Client

Multi-context support

All client and server message types support an optional context_id field. This allows you to manage multiple independent TTS streams over a single WebSocket connection.

Additional client message types

context.cancel — Cancel and clean up a specific context.

Additional server message types

context.cancelled — Confirms a context was cancelled.

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

model
enum<string>
default:hexgrad/Kokoro-82M

The TTS model to use for speech generation. Can also be set via tts_session.updated event.

Available options:
hexgrad/Kokoro-82M,
cartesia/sonic-english
voice
string

The voice to use for speech generation. Default is 'tara'. Available voices vary by model. Can also be updated via tts_session.updated event.

max_partial_length
integer
default:250

Maximum number of characters in partial text before forcing TTS generation even without a sentence ending. Helps reduce latency for long text without punctuation.

language
string
default:en

Language or locale of input text. Accepts ISO 639-1 language codes (e.g., en, fr, es, zh) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., zh-hk for Cantonese). Can also be set via tts_session.updated event.

Example:

"en"

Response

101

Switching Protocols - WebSocket connection established successfully.

Error message format: