跳转到主要内容
实时

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",
    "input_audio_format": "pcm",
    "output_audio_format": "pcm",
    "translation": {
      "language": "en",
      "corpus": {
        "phrases": {
          "人工智能": "Artificial Intelligence",
          "机器学习": "Machine Learning"
        }
      }
    }
  }
}
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
检测到语音结束位置的时间偏移(毫秒)。

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"
}
string
body
事件 ID。
string
body
固定为 conversation.item.input_audio_transcription.text
string
body
消息项 ID。
integer
body
固定为 0。
string
body
已确认的识别文本。
string
body
待确认的识别文本,可能被后续事件修正。
string
body
检测到的源语言。

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"
}
string
body
事件 ID。
string
body
固定为 conversation.item.input_audio_transcription.completed
string
body
消息项 ID。
integer
body
固定为 0。
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
内容部分。