Server event reference for Qwen-Audio-TTS: task startup, sentence synthesis, completion, failure, and corresponding requests.
Event flow
- Send run-task to start and configure the task, then wait for task-started.
- After receiving
task-started, send text through continue-task while receiving result-generated events and synthesized audio. - After sending all text, send finish-task and keep receiving remaining results and audio until task-finished arrives. A failed task returns task-failed.
result-generated returns sentence metadata. Audio is transmitted separately as binary frames over WebSocket or through an Audio Track over AOQ. For connection setup, authentication, and audio transport, see WebSocket API or AOQ access.
task-started
Indicates that the task has started successfully and the client can begin sending text for synthesis.
headerobjecttask_idstringThe task ID generated by the client.
eventstringEvent type. Fixed value:
task-started.payloadobjectEmpty object.
Request:
Response:
result-generated
Returns sentence metadata, including sentence starts, audio chunk markers, and sentence ends.
headerobjecttask_idstringThe task ID generated by the client.
eventstringEvent type. Fixed value:
result-generated.payloadobjectoutputobjectOutput information.
sentenceobjectindexintegerSentence index, starting from 0.
wordsarrayWord-level timestamp array.
textstringText content of the word.
begin_indexintegerStart character index of the word within the sentence. Starts at 0.
end_indexintegerEnd character index of the word within the sentence. Starts at 1.
begin_timeintegerStart time of the word's corresponding audio, in milliseconds.
end_timeintegerEnd time of the word's corresponding audio, in milliseconds.
typestringSub-event type. Valid values:
sentence-begin: Sentence start. Returns the text to be synthesized.sentence-synthesis: Marks an audio frame. One audio frame is transmitted over the WebSocket binary channel immediately after each event.sentence-end: Sentence end. Returns the text content and usage information (usage).
original_textstringText of the sentence as segmented for synthesis.
usageobjectBilling usage, returned in the
sentence-end event.usagecontains cumulative usage for the current task. Do not add usage values across events. After the task completes, use the final cumulative usage intask-finished.- qwen-audio-3.1-tts-flash: billed by input and output tokens, reported in
input_tokensandoutput_tokens, respectively. The combined usage is reported intotal_tokens. - qwen-audio-3.1-tts-plus: billed by character (
characters). It also returns the token statistics fields listed above. - qwen-audio-3.0-tts-plus and qwen-audio-3.0-tts-flash: billed by character (
characters).
input_tokensintegerInput token count for this request.
output_tokensintegerOutput token count for this request.
total_tokensintegerSum of input and output tokens.
charactersintegerCumulative number of billed characters.
The following examples set
word_timestamp_enabled=true when starting the task.- sentence-begin
- sentence-synthesis
- sentence-end
Request:
Response:
task-finished
The server returns a task-finished event when the task completes. The client can then close the WebSocket connection or reuse it to start a new task.
headerobjecttask_idstringThe task ID generated by the client.
eventstringEvent type. Fixed value:
task-finished.payloadobjectusageobjectThe fields are the same as usage in
result-generated.Request:
Response:
task-failed
The server returns a task-failed event when the task fails. On receiving this event, the client must close the WebSocket connection and handle the error.
headerobjecttask_idstringThe task ID generated by the client.
eventstringEvent type. Fixed value:
task-failed.error_codestringError code.
error_messagestringDetailed error message.
This example uses an unsupported audio format. After the task starts and text is sent, the server returns an error. The error code and message depend on the cause of failure.
Request:
Response: