When stream: true, task: false, the server returns audio data via standard SSE (Server-Sent Events).
Request example
curl -N -X POST https://routerbrain.ai/audio/v1/generations \
-H 'Authorization: Bearer sk-xxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "<streaming-audio-model>",
"prompt": "This is a streaming speech synthesis example.",
"voice": "<voice>",
"stream": true,
"task": false
}'
SSE event types
| Event | Description |
|---|---|
audio | An audio chunk, data.url is the audio URL |
timeline | Word-level timing or additional metadata |
complete | Generation finished, includes final usage and results |
error | Generation failed |
Completion signal
On success, a complete event is sent followed by data: [DONE]. Keep reading events until [DONE] is received.
Error handling
Once audio events have been sent to the client in SSE mode, the stream cannot seamlessly switch to another route. The client should handle the error event and close the stream.