Configure a session, send audio, and return task results.
Send JSON events by controlling the WebSocket. For connection and authentication, see WebSocket integration.
session.update
Configure a session. The service confirms that the configuration has taken effect via session.updated. With pure WebSocket integration, audio can be sent immediately after this step. For WebRTC and AOQ, you must wait for their respective media connections to become ready.
typestringRequiredEvent type; fixed value: session.update.
event_idstringRequiredClient event ID. Non-empty; maximum length: 128 characters.
sessionobjectRequiredSession configuration.
View child fields
modelstringRequiredFrontend speech model ID used for the session. Options: qwen-audio-4.0-realtime-preview or qwen-audio-3.1-realtime-flash.
For duplex conversations, use qwen-audio-4.0-realtime-preview and set turn_detection.type to duplex.
instructionsstringOptionalIf you omit session.instructions in the initial session configuration, the frontend model uses its built-in instructions. Providing session.instructions replaces them.
modalitiesarrayOptionalOutput modality. Default includes audio and text.
voicestringOptionalSystem voice ID used by the frontend model. Default value: yunshu.
| Voice name | Voice ID |
|---|---|
| 云舒 | yunshu |
| 小满 | xiaoman |
| 晚风 | wanfeng |
| 青柚 | qingyou |
| 破晓 | poxiao |
| 麦芽 | maiya |
| 乌龙 | wulong |
| 雪松 | xuesong |
turn_detectionobjectOptionalTurn detection configuration.
View child fields
typestringRequiredSet to duplex for duplex conversations, and select qwen-audio-4.0-realtime-preview as the frontend model.
input_audio_formatstringOptionalInput format. Pure WebSocket uses pcm, defaulting to 16 kHz, mono PCM16LE.
output_audio_formatstringOptionalOutput format. Pure WebSocket uses pcm, defaulting to 24 kHz, mono PCM16LE.
toolsarray[object]OptionalFrontend functions executable by the application. Default: empty array.
View child fields
typestringTool type. Use function for a custom function.
namestringFunction name.
descriptionstringWhat the function does.
parametersobjectFunction parameters defined using JSON Schema.
View child fields
typestringParameter structure. Use object for an object.
propertiesobjectTypes and constraints of parameters, keyed by the names defined by your application.
requiredarray[string]Names of the required parameters.
additionalPropertiesboolean | objectControls whether undeclared parameters are allowed. Set to false to reject them.
delegationobjectRequiredTask execution method.
View child fields
typestringRequiredclient: Task executed by the application. responses: Backend Responses model invoked by the service.
responsesobjectConditionally requiredRequired in Responses mode. Model Studio passes the settings documented here to the backend model. See the Responses API for the tool definition format.
View child fields
modelstringRequiredBackend Responses model ID for handling delegated tasks, e.g., qwen4-max.
instructionsstringOptionalTask instructions for the backend model in Responses mode. Model Studio supplies no built-in backend instructions.
toolsarray[object]OptionalDeclares tools available for the backend model. The structure of each tool depends on its type. The fields below apply to custom functions (type is function).
View child fields
typestringTool type. Use function for a custom function.
namestringFunction name.
descriptionstringWhat the function does.
parametersobjectFunction parameters defined using JSON Schema.
View child fields
typestringParameter structure. Use object for an object.
propertiesobjectTypes and constraints of parameters, keyed by the names defined by your application.
requiredarray[string]Names of the required parameters.
additionalPropertiesboolean | objectControls whether undeclared parameters are allowed. Set to false to reject them.
transportobjectOptionalUses WebSocket if omitted or an empty object is passed.
View child fields
typestringConditionally requiredSpecify the transport method explicitly. websocket uses WebSocket, rtc uses WebRTC, and aoq uses AOQ.
sdpstringConditionally requiredRequired when type is rtc. Pass the Offer SDP generated by the client. See WebRTC integration.
aoqobjectOptionalAOQ configuration.
View child fields
ws_audiobooleanOptionalWhether to deliver downstream audio via WebSocket in addition. Default is false.
Client mode
{
"type": "session.update",
"event_id": "evt_update_client",
"session": {
"model": "qwen-audio-4.0-realtime-preview",
"modalities": [
"text",
"audio"
],
"turn_detection": {
"type": "duplex"
},
"delegation": {
"type": "client"
}
}
}
Responses mode
{
"type": "session.update",
"event_id": "evt_update_responses",
"session": {
"model": "qwen-audio-4.0-realtime-preview",
"modalities": [
"text",
"audio"
],
"turn_detection": {
"type": "duplex"
},
"delegation": {
"type": "responses",
"responses": {
"model": "qwen4-max"
}
}
}
}
session.input_audio.append
Sends one frame of audio in a pure WebSocket session. Audio is sent via AOQ in AOQ sessions.
typestringRequiredEvent type; fixed value: session.input_audio.append.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
audiostringRequiredBase64-encoded 16 kHz, 16-bit, mono PCM16LE.
{
"type": "session.input_audio.append",
"audio": "AAAAAA=="
}
session.input_audio.mute
Mutes audio input. The service returns session.input_audio.muted.
typestringRequiredEvent type; fixed value: session.input_audio.mute.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
{
"type": "session.input_audio.mute",
"event_id": "evt_mute"
}
session.input_audio.unmute
Resumes audio input. The service returns session.input_audio.unmuted.
typestringRequiredEvent type; fixed value: session.input_audio.unmute.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
{
"type": "session.input_audio.unmute",
"event_id": "evt_unmute"
}
session.item.create
Input user text or return the result of a frontend function. The application executes the function at most once per call_id.
typestringRequiredEvent type; fixed value: session.item.create.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
itemobjectFill according to purpose.Session content to be written.
View child fields
typestringRequiredEnter message or function_call_output.
rolestringFill according to type.Example for message: user.
contentarrayFill according to type.Content of message.
View child fields
typestringRequiredEnter input_text for text input.
textstringRequiredUser text.
call_idstringFill according to type.Frontend function call ID corresponding to function_call_output.
outputstringFill according to type.String result of function_call_output.
Return function result
{
"type": "session.item.create",
"event_id": "evt_function_result",
"item": {
"type": "function_call_output",
"call_id": "call_stock",
"output": "{\"stock\":7}"
}
}
Input text
{
"type": "session.item.create",
"event_id": "evt_user_message",
"item": {
"role": "user",
"type": "message",
"content": [
{
"type": "input_text",
"text": "请查询雨伞库存。"
}
]
}
}
session.thinking.append
Update task progress. The service returns session.thinking.appended.
typestringRequiredEvent type; fixed value: session.thinking.append.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
delegation_idstringRequiredUse the ID from session.delegation.created received over the current connection.
contentstringRequiredTask progress.
start_msnumberOptionalStart time on the session timeline, in milliseconds.
end_msnumberOptionalEnd time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
{
"type": "session.thinking.append",
"event_id": "evt_thinking",
"delegation_id": "task_stock",
"content": "正在查询库存。"
}
session.instruction.append
Provides questions requiring user input. The service returns session.instructions.appended.
typestringRequiredEvent type; fixed value: session.instruction.append.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
delegation_idstringRequiredUse the ID from session.delegation.created received over the current connection.
task_idstringOptionalTypically omitted.
contentstringRequiredInformation requiring user input.
start_msnumberOptionalStart time on the session timeline, in milliseconds.
end_msnumberOptionalEnd time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
{
"type": "session.instruction.append",
"event_id": "evt_instruction",
"delegation_id": "task_stock",
"content": "请问要查哪种商品的库存?"
}
session.commentary.append
Returns the task result handled by this connection, or submits user text. The service returns session.commentary.appended.
typestringRequiredEvent type; fixed value: session.commentary.append.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
delegation_idstringRequired when returning a task result.Use the ID from session.delegation.created received over the current connection.
contentstringOptionalTask result or user text.
start_msnumberOptionalStart time on the session timeline, in milliseconds.
end_msnumberOptionalEnd time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
errorobjectOptionalTask error message.
Return task result.
{
"type": "session.commentary.append",
"event_id": "evt_stock_result",
"delegation_id": "task_stock",
"content": "库存还有七把雨伞。"
}
Input text
{
"type": "session.commentary.append",
"event_id": "evt_user_text",
"content": "请查询雨伞库存。"
}
response.item.create
Add backend input in Responses mode. Then send response.create to trigger generation.
typestringRequiredEvent type; fixed value: response.item.create.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
itemobjectRequiredBackend input. Supports message and function_call_output.
View child fields
typestringRequiredInput item type.
rolestringFill according to type.Example for message: user.
contentarrayFill according to type.User message content.
View child fields
typestringRequiredEnter input_text for text input.
textstringRequiredUser text.
call_idstringFunction call ID for function_call_output. Use the call_id returned in the backend event.
outputstringFunction result as a string for function_call_output.
Input text
{
"type": "response.item.create",
"event_id": "evt_backend_item",
"item": {
"role": "user",
"type": "message",
"content": [
{
"type": "input_text",
"text": "请查询雨伞库存。"
}
]
}
}
Return a backend function result
{
"type": "response.item.create",
"event_id": "evt_backend_output",
"item": {
"type": "function_call_output",
"call_id": "call_stock_001",
"output": "{\"stock\":7}"
}
}
response.create
Initiate a new backend task. The service returns backend events via response.event. When explicitly initiated, the service returns backend events directly; only auto-delegated workflows send session.delegation.created.
typestringRequiredEvent type; fixed value: response.create.
event_idstringOptionalClient event ID. Non-empty; maximum length: 128 characters.
responseobjectOptionalPass backend generation configuration. For configuration format, see Responses API.
{
"type": "response.create",
"event_id": "evt_backend_create"
}
session.close
Terminate the session. The service returns session.closed.
typestringRequiredEvent type; fixed value: session.close.
event_idstringRequiredClient event ID. Non-empty; maximum length: 128 characters.
{
"type": "session.close",
"event_id": "evt_close"
}