{
"type": "<string>",
"context_id": "<string>",
"text": "<string>",
"voice_id": "<string>",
"speed": 123
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>"
}{
"type": "<string>"
}{
"type": "<string>",
"session_id": "<string>",
"max_contexts": 123,
"sample_rate": 123,
"encoding": "<string>"
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"sample_rate": 123
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"audio": "<string>"
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"credits_utilized": 123,
"error": true
}{
"type": "<string>",
"context_id": "<string>",
"reason": "<string>",
"segments": 123,
"credits_utilized": 123,
"code": "<string>",
"message": "<string>"
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"contexts": 123,
"credits_utilized": 123
}{
"type": "<string>"
}Multi-context TTS WebSocket
Beta. Several independent speech streams (contexts) over one connection. Every message names its context_id. The first input.text for a new context_id opens the context; input.flush generates its buffered text as the next segment; context.close finishes it and context.cancel stops it immediately. Each context ends with one context.done, and nothing is sent for it afterwards. Up to 5 contexts can be open at once.
All messages are JSON text frames. Audio arrives in audio.chunk messages as base64-encoded raw PCM, signed 16-bit little-endian, mono.
Authenticate with the chariotai-api-key header, or with the api_key query parameter when your client cannot set handshake headers.
The connection closes with code 1000 after session.close, 1008 on an auth or parameter problem or the idle timeout, 1011 on an internal error, and 4402 when the workspace has insufficient credits. Every other error affects a single message or context and leaves the connection open.
{
"type": "<string>",
"context_id": "<string>",
"text": "<string>",
"voice_id": "<string>",
"speed": 123
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"context_id": "<string>"
}{
"type": "<string>"
}{
"type": "<string>"
}{
"type": "<string>",
"session_id": "<string>",
"max_contexts": 123,
"sample_rate": 123,
"encoding": "<string>"
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"sample_rate": 123
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"audio": "<string>"
}{
"type": "<string>",
"context_id": "<string>",
"segment": 123,
"credits_utilized": 123,
"error": true
}{
"type": "<string>",
"context_id": "<string>",
"reason": "<string>",
"segments": 123,
"credits_utilized": 123,
"code": "<string>",
"message": "<string>"
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"context_id": "<string>"
}{
"type": "<string>",
"contexts": 123,
"credits_utilized": 123
}{
"type": "<string>"
}GET
Append text to a context's buffer. The first input.text for a context_id opens the context. Does not generate audio on its own.
Generate the context's buffered text as its next segment. The context stays open.
No more text for this context. The rest of its buffer is generated, all audio is delivered, then context.done arrives with reason completed.
End the context now: generation in progress is stopped, queued and unflushed text is discarded, and context.done arrives with reason cancelled. No audio for the context is sent after it. Ignored if the context has already ended.
Finish every open context as if each received context.close, then close the connection.
Keep the connection alive. Answered with pong.
The connection is authenticated and ready.
A segment of a context is about to stream.
Audio for a segment.
The segment has finished streaming. Carries the credits charged for it.
The last message for a context, whatever ended it.
A message was rejected. The connection stays open unless code is insufficient_credits (closes with 4402) or idle_timeout (closes with 1008).
Sent after session.close once every context has finished. The connection then closes with code 1000.
Answer to ping.