Multi-context TTS WebSocket
GETwss://api.knoxstudio.ai/v1/text-to-speech/:voice_id/multi-stream-input
Same transport as TTS WebSocket, but each context_id keeps its own generation state. Useful for interleaved voice-agent replies. GET and POST accept the upgrade. Stream formats only. Billed per character.
Request
Path, query, and auth match Text-to-speech WebSocket: voice_id, model_id, stream output_format, enable_logging, apply_text_normalization. Plain HTTP returns 400.
Client messages
{
"text": "First context ",
"context_id": "agent-a",
"try_trigger_generation": true
}
Flush or close a single context independently:
{ "context_id": "agent-a", "text": "", "flush": true }
{ "context_id": "agent-a", "close_context": true }
Terminate the whole socket with close_socket: true.
Server messages
Audio frames include contextId so you can demux concurrent generations. isFinal applies to that context.
Use this API when you need concurrent or interleaved streams. For a single sequential stream, prefer /stream-input.
Error Responses
Validation uses HTTP 422:
{
"detail": [
{
"loc": ["body", "field"],
"msg": "…",
"type": "value_error"
}
]
}
Other errors use { "detail": "message" }.
| Status | When |
|---|---|
400 | WebSocket path called without Upgrade: websocket. |
401 | Missing or invalid API key. |
402 | Insufficient credits. |
403 | Token is not allowed to use this model. |
404 | Resource not found. |
422 | Validation error. |
429 | Rate limit exceeded. |
500 | Internal server error. |