跳转到主要内容
实时

LiveTranslate server events

WebSocket 服务端事件参考

qwen3.5-livetranslate-flash-realtime API 的服务端事件。
参考:语音翻译

error

服务端返回的错误。
Example
{
  "event_id": "event_RoUu4T8yExPMI37GKwaOC",
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_value",
    "message": "Invalid modalities: ['audio']. Supported combinations are: ['text'] and ['audio', 'text'].",
    "param": "session.modalities"
  }
}
string
body
事件 ID。
string
body
固定为 error
object
body
错误详情。

session.created

连接建立时发送,包含默认会话配置。
Example
{
  "event_id": "event_QxBGpjBDmDDQQWDtrqBKB",
  "type": "session.created",
  "session": {
    "id": "sess_OozZ1vtbPt2muDflHODIH",
    "object": "realtime.session",
    "model": "qwen3.5-livetranslate-flash-realtime",
    "modalities": [
      "text",
      "audio"
    ],
    "voice": "Cherry",
    "sample_rate": 16000,
    "input_audio_format": "pcm",
    "output_audio_format": "pcm",
    "input_audio_transcription": {
      "model": "qwen3-asr-flash-realtime",
      "language": "zh"
    },
    "turn_detection": {
      "type": "server_vad",
      "threshold": 0.2,
      "prefix_padding_ms": 300,
      "silence_duration_ms": 1000,
      "create_response": true,
      "interrupt_response": true
    },
    "translation": {
      "language": "en",
      "corpus": {
        "phrases": {
          "人工智能": "Artificial Intelligence",
          "机器学习": "Machine Learning"
        }
      }
    },
    "enable_voice_clone": true,
    "voice_clone_options": {
      "frequency": "once"
    }
  }
}
string
body
事件 ID。
string
body
固定为 session.created
object
body
会话配置。

session.updated

session.update 请求成功后发送。如果出错,服务端会返回 error 事件。
Example
{
  "event_id": "event_RmNPqjCeFFGRRXEusrCLA",
  "type": "session.updated",
  "session": {
    "id": "sess_OozZ1vtbPt2muDflHODIH",
    "object": "realtime.session",
    "model": "qwen3.5-livetranslate-flash-realtime",
    "modalities": [
      "text",
      "audio"
    ],
    "voice": "Ethan",
    "sample_rate": 16000,
    "input_audio_format": "pcm",
    "output_audio_format": "pcm",
    "translation": {
      "language": "en",
      "corpus": {
        "phrases": {
          "人工智能": "Artificial Intelligence",
          "机器学习": "Machine Learning"
        }
      }
    }
  }
}
string
body
事件 ID。
string
body
固定为 session.updated
object
body
会话配置。

session.finished

所有翻译完成后发送。 仅在您发送 session.finish 后触发。收到此事件后可以断开连接。
Example
{
  "event_id": "event_xxx",
  "type": "session.finished"
}
string
body
事件 ID。
string
body
固定为 session.finished

input_audio_buffer.speech_started

服务端检测到音频流中出现语音活动时发送。
Example
{
  "event_id": "event_xxx",
  "type": "input_audio_buffer.speech_started",
  "audio_start_ms": 1200
}
string
body
事件 ID。
string
body
固定为 input_audio_buffer.speech_started
integer
body
检测到语音起始位置的时间偏移(毫秒)。

input_audio_buffer.speech_stopped

服务端检测到语音片段结束时发送。
Example
{
  "event_id": "event_xxx",
  "type": "input_audio_buffer.speech_stopped",
  "audio_end_ms": 3400
}
string
body
事件 ID。
string
body
固定为 input_audio_buffer.speech_stopped
integer
body
检测到语音结束位置的时间偏移(毫秒)。

input_audio_buffer.committed

Manual 模式(turn_detectionnull)下,客户端发送 input_audio_buffer.commit 事件后,服务端返回此事件进行确认,并自动开始生成翻译响应。
Example
{
  "event_id": "event_xxx",
  "type": "input_audio_buffer.committed"
}
string
body
本次事件唯一标识符。
string
body
固定为 input_audio_buffer.committed

input_audio_buffer.cleared

客户端发送 input_audio_buffer.clear 事件后,服务端返回此事件进行确认,表示已清空缓冲区中尚未提交的音频数据。
Example
{
  "event_id": "event_xxx",
  "type": "input_audio_buffer.cleared"
}
string
body
本次事件唯一标识符。
string
body
固定为 input_audio_buffer.cleared

conversation.item.created

当对话中创建新的消息项时,服务端返回此事件。以下场景会触发此事件:
  • 服务端开始生成翻译响应时,创建对应的 assistant 消息项(此时 content 为空数组,内容随流式响应逐步填充)。
  • Manual 模式下,客户端发送 input_audio_buffer.commit 事件后,服务端会额外创建一个对应用户输入音频的消息项(content 中包含 {"type": "input_audio"})。
对于同一个 VAD 片段,服务端会分别创建语音识别结果和翻译结果消息项。语音识别结果消息项的 item.id 与翻译结果事件的 previous_item_id 相同。客户端可据此关联原文和译文,并同时展示。
Example
{
  "event_id": "event_xxx",
  "type": "conversation.item.created",
  "previous_item_id": "item_asr_xxx",
  "item": {
    "id": "item_translation_xxx",
    "object": "realtime.item",
    "type": "message",
    "status": "in_progress",
    "role": "assistant",
    "content": []
  }
}
string
body
本次事件唯一标识符。
string
body
固定为 conversation.item.created
string
body
前一消息项的唯一标识符。对于翻译结果事件,该值与同一 VAD 片段的语音识别结果消息项 item.id 相同。
object
body
消息项信息。

response.created

服务端开始生成新响应时发送。
Example
{
  "event_id": "event_L8hHVI5jYis6BzAjnPWJh",
  "type": "response.created",
  "response": {
    "id": "resp_P79OOMs8LnrXVpiIHUCKR",
    "object": "realtime.response",
    "conversation_id": "conv_UFClXtYkRkFXrs48y8pmK",
    "status": "in_progress",
    "modalities": [
      "text",
      "audio"
    ],
    "voice": "Cherry",
    "output_audio_format": "pcm",
    "output": []
  }
}
string
body
事件 ID。
string
body
固定为 response.created
object
body
响应对象。

response.done

响应生成完成时发送。response 对象包含所有输出项,但不包含原始音频数据。
Example
{
  "event_id": "event_CNea8oXNipVanSg2VIzkO",
  "type": "response.done",
  "response": {
    "id": "resp_TfhYTqej692vsGA2jNEtH",
    "object": "realtime.response",
    "conversation_id": "conv_ZtyLfKVm8XqLwYRlsuDih",
    "status": "completed",
    "modalities": [
      "text",
      "audio"
    ],
    "voice": "Cherry",
    "output_audio_format": "pcm",
    "output": [
      {
        "id": "item_MKtkMwN9RtcyE9eJShyWy",
        "object": "realtime.item",
        "type": "message",
        "status": "completed",
        "role": "assistant",
        "content": [
          {
            "type": "audio",
            "transcript": "Hello? "
          }
        ]
      }
    ],
    "usage": {
      "total_tokens": 56,
      "input_tokens": 47,
      "output_tokens": 9,
      "input_tokens_details": {
        "text_tokens": 20,
        "audio_tokens": 27
      },
      "output_tokens_details": {
        "text_tokens": 2,
        "audio_tokens": 7
      }
    }
  }
}
string
body
事件 ID。
string
body
固定为 response.done
object
body
响应对象。

response.text.text

纯文本模式下,模型增量生成文本时发送。
Example
{
  "event_id": "event_B1lIeyOXR7qJMEExbqtTG",
  "type": "response.text.text",
  "response_id": "resp_B1lIdtjF4Noqpn5NOjznj",
  "item_id": "item_B1lIdJsAJlJiFs8ztWpJt",
  "output_index": 0,
  "content_index": 0,
  "text": "How are"
}
string
body
事件 ID。
string
body
固定为 response.text.text
string
body
增量文本片段。
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。

response.text.done

纯文本输出完成时发送。
响应被中断、未完成或取消时也会发送此事件。
Example
{
  "event_id": "event_B1lIeE2Nac33zn5V7h2mm",
  "type": "response.text.done",
  "response_id": "resp_B1lIdtjF4Noqpn5NOjznj",
  "item_id": "item_B1lIdJsAJlJiFs8ztWpJt",
  "output_index": 0,
  "content_index": 0,
  "text": "How can I assist you today?"
}
string
body
事件 ID。
string
body
固定为 response.text.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
完整文本输出。

response.audio.delta

模型增量生成音频数据时发送。
Example
{
  "event_id": "event_B1osWMZBtrEQbiIwW0qHQ",
  "type": "response.audio.delta",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
  "output_index": 0,
  "content_index": 0,
  "delta": "UklGRnoGAABXQVZFZm10IBAAAAAB..."
}
string
body
事件 ID。
string
body
固定为 response.audio.delta
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
Base64 编码的音频数据片段。

response.audio.done

音频生成完成时发送。
响应被中断、未完成或取消时也会发送此事件。此事件不包含完整音频数据。
Example
{
  "event_id": "event_B1osWMWoDRYyITDyNYcBu",
  "type": "response.audio.done",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
  "output_index": 0,
  "content_index": 0
}
string
body
事件 ID。
string
body
固定为 response.audio.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。

conversation.item.input_audio_transcription.text

流式返回源语言的语音识别结果。需要设置 input_audio_transcription.model
Example
{
  "event_id": "event_xxx",
  "type": "conversation.item.input_audio_transcription.text",
  "item_id": "item_xxx",
  "content_index": 0,
  "text": "",
  "stash": "The weather is really nice today",
  "language": "en",
  "emotion": "neutral"
}
string
body
事件 ID。
string
body
固定为 conversation.item.input_audio_transcription.text
string
body
消息项 ID。
integer
body
固定为 0。
string
body
已确认的识别文本。
string
body
待确认的识别文本,可能被后续事件修正。
string
body
检测到的源语言。
string
body
被识别音频的情感。支持的情感如下:
  • surprised:惊讶
  • neutral:平静
  • happy:愉快
  • sad:悲伤
  • disgusted:厌恶
  • angry:愤怒
  • fearful:恐惧

conversation.item.input_audio_transcription.completed

语音识别完成时发送,包含最终识别结果。需要设置 input_audio_transcription.model
Example
{
  "event_id": "event_xxx",
  "type": "conversation.item.input_audio_transcription.completed",
  "item_id": "item_xxx",
  "content_index": 0,
  "transcript": "The weather is really nice today, let's go for a walk in the park.",
  "language": "en",
  "emotion": ""
}
string
body
事件 ID。
string
body
固定为 conversation.item.input_audio_transcription.completed
string
body
消息项 ID。
integer
body
固定为 0。
string
body
源语言的最终识别结果。
string
body
检测到的源语言。
string
body
被识别音频的情感。支持的情感如下:
  • surprised:惊讶
  • neutral:平静
  • happy:愉快
  • sad:悲伤
  • disgusted:厌恶
  • angry:愤怒
  • fearful:恐惧

conversation.item.input_audio_transcription.failed

当输入了音频但识别失败时,服务端发送该事件。与其他 error 事件分开处理,便于客户端识别相关的具体项目。
Example
{
  "event_id": "event_xxx",
  "type": "conversation.item.input_audio_transcription.failed",
  "item_id": "item_xxx",
  "content_index": 0,
  "error": {
    "code": "xxx",
    "message": "xxx",
    "param": "xxx"
  }
}
string
body
本次事件唯一标识符。
string
body
固定为 conversation.item.input_audio_transcription.failed
string
body
关联的对话项 ID。
integer
body
包含音频的内容部分的索引。
string
body
错误代码。
string
body
错误消息。

response.audio_transcript.text

输出包含音频时,实时流式返回翻译文本。
Example
{
  "event_id": "event_xxx",
  "type": "response.audio_transcript.text",
  "response_id": "resp_xxx",
  "item_id": "item_xxx",
  "output_index": 0,
  "content_index": 0,
  "text": "Hello,",
  "stash": " who are you?"
}
string
body
事件 ID。
string
body
固定为 response.audio_transcript.text
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
已确认的翻译片段。
string
body
追加在 text 之后的临时文本,构成部分翻译结果。服务端通过 response.audio_transcript.text 事件持续更新 textstash,直到 response.audio_transcript.done 事件返回最终翻译结果(transcript 字段)。

response.audio_transcript.done

音频输出的翻译文本生成完成时发送。
Example
{
  "event_id": "event_VN4Q4GJugLcc1S23viW8E",
  "type": "response.audio_transcript.done",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "item_id": "item_JvJauNH2CTXb1D9WV6pD4",
  "output_index": 0,
  "content_index": 0,
  "transcript": "How can I assist you today?"
}
string
body
事件 ID。
string
body
固定为 response.audio_transcript.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
string
body
最终翻译文本。

response.output_item.added

响应生成过程中创建新输出项时发送。
Example
{
  "event_id": "event_B4O5yPt3Gjnjy5eYH3plG",
  "type": "response.output_item.added",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "output_index": 0,
  "item": {
    "id": "item_OFaPGtzfWCPyGzxnuEX9i",
    "object": "realtime.item",
    "type": "message",
    "status": "in_progress",
    "role": "assistant",
    "content": []
  }
}
string
body
事件 ID。
string
body
固定为 response.output_item.added
string
body
响应 ID。
integer
body
固定为 0。
object
body
输出项。

response.output_item.done

输出项完成时发送。
Example
{
  "event_id": "event_XkiwbYTBC9Wcdwy6uYJ2G",
  "type": "response.output_item.done",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "output_index": 0,
  "item": {
    "id": "item_JvJauNH2CTXb1D9WV6pD4",
    "object": "realtime.item",
    "type": "message",
    "status": "completed",
    "role": "assistant",
    "content": [
      {
        "type": "audio",
        "text": "Hello, I am a large language model developed by Alibaba Cloud. My name is Qwen. How can I help you?"
      }
    ]
  }
}
string
body
事件 ID。
string
body
固定为 response.output_item.done
string
body
响应 ID。
integer
body
固定为 0。
object
body
输出项。

response.content_part.added

新的内容部分开始时发送。
Example
{
  "event_id": "event_J2UixwYKZsXg7c9YXZetL",
  "type": "response.content_part.added",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "item_id": "item_OFaPGtzfWCPyGzxnuEX9i",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": ""
  }
}
string
body
事件 ID。
string
body
固定为 response.content_part.added
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
object
body
内容部分。

response.content_part.done

内容部分完成时发送。
Example
{
  "event_id": "event_VN4Q4GJugLcc1S23viW8E",
  "type": "response.content_part.done",
  "response_id": "resp_P79OOMs8LnrXVpiIHUCKR",
  "item_id": "item_JvJauNH2CTXb1D9WV6pD4",
  "output_index": 0,
  "content_index": 0,
  "part": {
    "type": "audio",
    "text": "Hello, I am a large language model developed by Alibaba Cloud. My name is Qwen. How can I help you?"
  }
}
string
body
事件 ID。
string
body
固定为 response.content_part.done
string
body
响应 ID。
string
body
消息项 ID。
integer
body
固定为 0。
integer
body
固定为 0。
object
body
内容部分。