Skip to navigation

WebSocket

View as Markdown

Many streaming synthesis requests on one connection. Each request runs exactly like POST /v1/text-to-speech/stream: the same validation, billing and limits.

The WebSocket guide covers ordering, cancellation, errors, limits and close codes.

  • You send: One JSON text message per synthesis request, or a cancel for a context.
  • You receive: Zero or more chunks per request, then exactly one done or error; one cancelled per cancel.

Handshake

WSS
wss://hub.getraya.app/v1/text-to-speech/ws

Authentication

X-API-Keystring

API key for authentication. Example: raya_ABCD1234567890abcdef

Send

synthesisRequestobjectRequired
Send one JSON text message per request.
OR
cancelRequestobjectRequired

Stops the context’s running request and drops the ones queued behind it. Answered by exactly one cancelled; nothing sent before the cancel arrives after it.

Receive

chunkobjectRequired

Base64 audio of one request, in the request’s output_format.

OR
doneobjectRequired
The request's last message when it succeeds.
OR
errorobjectRequired

Ends one request only; the connection and other contexts carry on. status_code is the HTTP status the same failure gets on the streaming endpoint, and the endpoint’s error fields are included. An error with neither context_id nor request_id is about a message that was not a request.

OR
cancelledobjectRequired
The answer to a cancel.