Skip to main content

Qwen-Audio-Live server-side events

Read session status, voice responses, and task execution results.

Receive JSON events over the control WebSocket. When using WebRTC or AOQ, wait for session.updated on that WebSocket. Once the media connection is ready, you can also receive server events over the WebRTC DataChannel or the AOQ data track. Handle events according to type. The client_event_id in the acknowledgment corresponds to the event_id in the request. The event_id of each server-side event uniquely identifies that event.

session.created

After the connection is established, the service returns default session information. After sending session.update, wait for session.updated to confirm that the configuration has taken effect.
typestringRequired
Event type; fixed value: session.created.
event_idstringRequired
Server-side event ID.
sessionobjectRequired
Default session information.
idstringRequired
Business session ID. AOQ Relay uses an independent sid.
objectstringRequired
Compatible object name, e.g., realtime.session.
modelstringRequired
Deployed default frontend voice model.
modalitiesarrayReturned per model
Output modality.
voicestringReturned per model
Default voice style.
turn_detectionobjectReturned per model
Default turn detection configuration. The detection settings below are returned when type is server_vad.
typestring
Turn detection type.
thresholdnumber
Voice activity detection threshold.
prefix_padding_msinteger
Length of audio retained before the detected speech start, in milliseconds.
silence_duration_msinteger
Duration of silence required to detect the end of speech, in milliseconds.
create_responseboolean
Whether to generate a reply automatically when speech ends.
interrupt_responseboolean
Whether to interrupt an ongoing reply when the user starts speaking.
input_audio_transcriptionobjectReturned per model
Audio transcription capability and its default configuration.
modelstring
Model used to transcribe input audio.
model_inferencebooleanRequired
The service supports integration with models. Inference and interaction begin only after the session configuration takes effect.
{
  "type": "session.created",
  "event_id": "evt_created",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "model": "<default frontend model ID>",
    "modalities": [
      "text",
      "audio"
    ],
    "turn_detection": {
      "type": "server_vad"
    },
    "input_audio_transcription": {
      "model": "<transcription model ID>"
    },
    "model_inference": true
  }
}

session.updated

The session configuration has taken effect. Use the returned configuration.
typestringRequired
Event type; fixed value: session.updated.
event_idstringRequired
Server-side event ID.
sessionobjectRequired
Effective session configuration, including session metadata and task mode.
idstringRequired
Business session ID.
modelstringRequired
Effective frontend voice model.
objectstringReturned per configuration
Session object type.
modalitiesarrayReturned per configuration
Effective output modality.
delegationobjectRequired
Task mode.
typestringRequired
client or responses.
transportobjectReturned per configuration
Returns connection information for the selected transmission method.
typestringReturned per configuration
When using WebRTC, the value is rtc.
sdpstringReturned per configuration
When using WebRTC, returns the Answer SDP. The client sets it as the remote description. For details, see WebRTC access.
aoqobjectReturned per configuration
When using AOQ, returns temporary connection information. Use the returned sid and temporary credentials to initiate the AOQ connection within 5 minutes of receiving session.updated. For steps to connect, see AOQ access.
sidstring
AOQ session ID.
aoqTokenForClientstring
Temporary token that the client uses to connect to the Relay.
clientRelayCertFingerprintstring
Fingerprint of the Relay’s TLS certificate.
clientRelayEndpointsarray
List of Relay addresses for the connection.
endpointstring
Relay address.
portinteger
Relay port.
route_indexinteger
Relay route index.
extraInfoobject
Additional connection information.
workspaceIdHashstring
Hash of the workspace ID.
  • WebSocket
  • WebRTC (excerpt)
  • AOQ (excerpt)
{
  "type": "session.updated",
  "event_id": "evt_updated",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "model": "qwen-audio-4.0-realtime-preview",
    "modalities": [
      "text",
      "audio"
    ],
    "delegation": {
      "type": "client"
    }
  }
}

session.input_audio.muted

Input is muted.
typestringRequired
Event type; fixed value: session.input_audio.muted.
event_idstringRequired
Server-side event ID.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "session.input_audio.muted",
  "event_id": "evt_muted",
  "client_event_id": "evt_mute"
}

session.input_audio.unmuted

Input is unmuted.
typestringRequired
Event type; fixed value: session.input_audio.unmuted.
event_idstringRequired
Server-side event ID.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "session.input_audio.unmuted",
  "event_id": "evt_unmuted",
  "client_event_id": "evt_unmute"
}

session.input_transcript.delta

Receives the transcription of user speech.
typestringRequired
Event type; fixed value: session.input_transcript.delta.
event_idstringRequired
Server-side event ID.
deltastringRequired
The transcription text returned in this response.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
{
  "type": "session.input_transcript.delta",
  "event_id": "evt_input_transcript",
  "delta": "帮我查库存。",
  "start_ms": 1600,
  "end_ms": 1600
}

session.output_transcript.delta

Receives subtitles for the frontend voice reply. Subtitle timestamps are used to locate positions on the session timeline.
typestringRequired
Event type; fixed value: session.output_transcript.delta.
event_idstringRequired
Server-side event ID.
deltastringRequired
The reply text returned in this response.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
{
  "type": "session.output_transcript.delta",
  "event_id": "evt_output_transcript",
  "delta": "库存还有七把雨伞。",
  "start_ms": 5400,
  "end_ms": 5400
}

session.output_audio.delta

Receives an audio chunk from the frontend voice.
typestringRequired
Event type; fixed value: session.output_audio.delta.
event_idstringOptional
Server-side event ID.
deltastringRequired
Base64-encoded 24 kHz mono PCM16LE raw audio. After decoding, the byte count is even. The audio has no WAV file header.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
{
  "type": "session.output_audio.delta",
  "delta": "AAAAAA==",
  "start_ms": 5400,
  "end_ms": 5420
}

session.delegation.created

The frontend model dispatches a task. This event is received in both Client mode and Responses mode. When returning the task result, use the delegation_id from the corresponding task event.
typestringRequired
Event type; fixed value: session.delegation.created.
event_idstringRequired
Server-side event ID.
offset_msnumberRequired
The offset of this dispatch on the session timeline, in milliseconds.
delegation_idstringRequired
The task ID associated with this dispatch.
task_idstringOptional
Task ID. Used in the return payload as delegation_id.
summarystringReturned upon task dispatch
Summary of the dispatched task in this response.
contextobjectReturned upon task dispatch
Context snapshot at the time the task is accepted.
summarystringRequired
Context summary.
messagesarray[object]Returned upon task dispatch
Context messages.
seqinteger
Sequence number of the message in the context.
item_idstring
Message item ID.
rolestring
Role of the message sender.
sourcestring
Source of the message.
audio_start_msinteger
Start offset of the audio on the session timeline, in milliseconds.
audio_end_msinteger
End offset of the audio on the session timeline, in milliseconds.
playbackstring
Audio playback status.
contentstring
Message text.
incompleteboolean
Whether the context snapshot is incomplete.
truncatedboolean
Whether the context snapshot was truncated.
supplementsarrayReturned per task
Additional content accepted in this batch and their respective contexts.
summarystringRequired
Supplementary content summary.
contextobjectReturned upon task dispatch
Context snapshot at the time the task is accepted.
summarystringRequired
Context summary.
messagesarrayReturned upon task dispatch
Context messages.
argumentsstringOptional
Compatible field. A JSON string that may contain summary.
{
  "type": "session.delegation.created",
  "event_id": "evt_delegation",
  "offset_ms": 3600,
  "delegation_id": "task_stock",
  "task_id": "task_stock",
  "summary": "查询雨伞库存。",
  "context": {
    "summary": "",
    "messages": [
      {
        "seq": 1,
        "item_id": "item_stock_001",
        "role": "user",
        "audio_start_ms": 900,
        "audio_end_ms": 3600,
        "content": "查询雨伞库存。"
      }
    ],
    "incomplete": false,
    "truncated": false
  },
  "supplements": [
    {
      "summary": "查询雨伞库存。",
      "context": {
        "summary": "",
        "messages": []
      }
    }
  ],
  "arguments": "{\"summary\":\"查询雨伞库存。\"}"
}

session.event

Receives frontend function calls. Uses call_id to correlate results.
typestringRequired
Event type; fixed value: session.event.
event_idstringRequired
Server-side event ID.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
eventobjectRequired
Frontend model function call event.
typestringRequired
Inner event name.
itemobjectReturns per event.
Function call item.
typestringRequired
The function call item is function_call.
namestringRequired
Function name.
call_idstringRequired
Call ID.
argumentsstringRequired
Function arguments in JSON string format.
idstringReturns per event.
Call item ID.
statusstringReturns per event.
Call item status.
output_indexnumberReturns per event.
Output location of the call item.
response_idstringReturns per event.
Frontend response ID.
{
  "type": "session.event",
  "event_id": "evt_frontend_tool",
  "event": {
    "type": "response.output_item.added",
    "item": {
      "type": "function_call",
      "name": "lookup_stock",
      "call_id": "call_stock",
      "arguments": "{\"item\":\"雨伞\"}",
      "id": "item_stock",
      "status": "completed"
    },
    "output_index": 0,
    "response_id": "resp_frontend"
  }
}

response.event

Receives backend generation or task events. The inner response.completed indicates the end of backend generation. Frontend voice responses have their own subtitle and audio events.
typestringRequired
Event type; fixed value: response.event.
event_idstringRequired
Server-side event ID.
delegation_idstringReturns per event.
Associated task ID.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
eventobjectRequired
Backend native event or task event.
typestringRequired
Inner event name.
responseobjectReturns per event.
Backend response. Fields vary by event.
idstringReturns per event.
Backend response ID.
usageobjectOptional
Backend model token usage.
input_tokensintegerReturns per event.
Number of input tokens consumed by the backend model.
output_tokensintegerReturns per event.
Number of output tokens generated by the backend model.
total_tokensintegerReturns per event.
Total number of input and output tokens.
{
  "type": "response.event",
  "event_id": "evt_backend_completed",
  "delegation_id": "task_calc",
  "event": {
    "type": "response.completed",
    "response": {
      "id": "resp_calc",
      "usage": {
        "input_tokens": 28,
        "output_tokens": 12,
        "total_tokens": 40
      }
    }
  }
}

session.thinking.appended

Service has accepted the task progress. For request session.thinking.append, the acknowledgment can be matched using the associated field.
typestringRequired
Event type; fixed value: session.thinking.appended.
event_idstringRequired
Server-side event ID.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "session.thinking.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.instructions.appended

Service has accepted the follow-up content. For request session.instruction.append, the acknowledgment can be matched using the associated field.
typestringRequired
Event type; fixed value: session.instructions.appended.
event_idstringRequired
Server-side event ID.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "session.instructions.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.commentary.appended

Service has accepted the result or text. For request session.commentary.append, the acknowledgment can be matched using the associated field.
typestringRequired
Event type; fixed value: session.commentary.appended.
event_idstringRequired
Server-side event ID.
start_msnumberRequired
Start time on the session timeline, in milliseconds.
end_msnumberRequired
End time on the session timeline, in milliseconds.
client_event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "session.commentary.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.usage.updated

After session activation, the service reports cumulative billing duration every 5 seconds; reports are also sent during idle periods. The current value takes the latest usage.seconds, and the final value is read from session.closed. Backend model token usage is available in response.event.
typestringRequired
Event type; fixed value: session.usage.updated.
event_idstringRequired
Server-side event ID.
usageobjectRequired
Session usage.
secondsnumberRequired
Cumulative billing duration for the session (in seconds). This is the greater of 3 seconds and the elapsed session duration.
context_windowobjectOptional
Context usage.
usage_rationumberOptional
Token usage divided by the context limit. Results may be delayed.
{
  "type": "session.usage.updated",
  "event_id": "evt_usage",
  "usage": {
    "seconds": 32.5
  },
  "context_window": {
    "usage_ratio": 0.12
  }
}

session.closed

The session has ended. Stop sending events and release resources. To continue the conversation, establish a new connection and initialize a new session.
typestringRequired
Event type; fixed value: session.closed.
event_idstringRequired
Server-side event ID.
reasonstringRequired
Reason for closure. Possible values are close_requested, expired, content, remote_hangup, or connection_lost.
sessionobjectRequired
Configuration snapshot returned when the session closes.
idstringReturned with the snapshot.
Business session ID.
objectstringReturned with the snapshot.
Session object type.
statusstringReturned with the snapshot.
The status in the snapshot may still show active. Use the session.closed event to determine that the session has closed.
modelstringReturned with the snapshot.
Frontend speech model used for the session.
usageobjectRequired
Final usage metrics at session termination.
secondsnumberRequired
Cumulative billing duration for the session (in seconds). This is the greater of 3 seconds and the elapsed session duration.
{
  "type": "session.closed",
  "event_id": "evt_closed",
  "reason": "close_requested",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "status": "active",
    "model": "qwen-audio-4.0-realtime-preview"
  },
  "usage": {
    "seconds": 45.8
  }
}

error

Check the request and session status based on the error code. After receiving a close event, reestablish the connection.
typestringRequired
Event type; fixed value: error.
event_idstringRequired
Server-side event ID.
errorobjectRequired
Error details.
typestringRequired
invalid_request_error or server_error.
codestringRequired
Error code. For example, invalid_session_configuration or invalid_event_state.
messagestringRequired
Error description.
event_idstringOptional
Corresponds to the client’s requested event_id.
{
  "type": "error",
  "event_id": "evt_server_error",
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_session_configuration",
    "message": "Invalid session configuration",
    "event_id": "evt_update_client"
  }
}