你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
语音实时 API 为使用 WebSocket 连接启用语音的应用程序提供实时双向通信。 此 API 支持高级功能,包括语音识别、文本到语音合成、头像流式处理、动画数据和全面的音频处理功能。
API 使用通过 WebSocket 连接发送的 JSON 格式事件来管理对话、音频流、虚拟形象交互和实时响应。 事件分为客户端事件(从客户端发送到服务器)和服务器事件(从服务器发送到客户端)。
主要功能
- 实时音频处理:支持多种音频格式,包括采用各种采样率的 PCM16 和 G.711 编解码器
- 高级语音选项:OpenAI 语音、Azure 自定义语音、Azure 标准语音和 Azure 个人语音
- 虚拟形象集成:基于 WebRTC 的头像流式处理视频、动画和 blendshapes
- 智能轮次检测:多个 VAD 选项,包括 Azure 语义 VAD 和服务器端检测
- 音频增强:内置降噪和回声取消
- 函数调用:用于增强聊天功能的工具集成
- 灵活的会话管理:可配置的形式、指令和响应参数
客户端事件
语音实时 API 支持以下可从客户端发送到服务器的客户端事件:
| 事件 / 活动 | Description |
|---|---|
| session.update | 更新会话配置,包括语音、形式、轮次检测和其他设置 |
| session.avatar.connect | 通过提供客户端 SDP 进行 WebRTC 协商来建立虚拟连接 |
| input_audio_buffer.append | 将音频字节追加到输入音频缓冲区 |
| input_audio_buffer.commit | 提交用于处理的输入音频缓冲区 |
| input_audio_buffer.clear | 清除输入音频缓冲区 |
| conversation.item.create | 向对话上下文添加新项 |
| conversation.item.retrieve | 从对话中检索特定项 |
| conversation.item.truncate | 截断助理音频消息 |
| conversation.item.delete | 从对话中删除项目 |
| response.create | 指示服务器通过模型推理创建响应 |
| response.cancel | 取消正在进行的响应 |
session.update
更新会话的配置。 可以随时发送此事件,以修改语音、形式、轮次检测、工具和其他会话参数等设置。 请注意,使用特定模型初始化会话后,无法将其更改为另一个模型。
事件结构
{
"type": "session.update",
"session": {
"modalities": ["text", "audio"],
"voice": {
"type": "openai",
"name": "alloy"
},
"instructions": "You are a helpful assistant. Be concise and friendly.",
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_sampling_rate": 24000,
"turn_detection": {
"type": "azure_semantic_vad",
"threshold": 0.5,
"prefix_padding_ms": 300,
"silence_duration_ms": 500
},
"temperature": 0.8,
"max_response_output_tokens": "inf"
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "session.update" |
| 会话 | RealtimeRequestSession | 包含要更新的字段的会话配置对象 |
Azure 自定义语音的示例
{
"type": "session.update",
"session": {
"voice": {
"type": "azure-custom",
"name": "my-custom-voice",
"endpoint_id": "12345678-1234-1234-1234-123456789012",
"temperature": 0.7,
"style": "cheerful"
},
"input_audio_noise_reduction": {
"type": "azure_deep_noise_suppression"
},
"avatar": {
"character": "lisa",
"customized": false,
"video": {
"resolution": {
"width": 1920,
"height": 1080
},
"bitrate": 2000000
}
}
}
}
session.avatar.connect
通过提供客户端的 SDP(会话说明协议)产品/服务进行 WebRTC 媒体协商来建立虚拟形象连接。 使用虚拟形象功能时,需要此事件。
事件结构
{
"type": "session.avatar.connect",
"client_sdp": "<client_sdp>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "session.avatar.connect" |
| client_sdp | 字符串 | 客户端的 SDP 产品/服务用于 WebRTC 连接建立 |
input_audio_buffer.append
将音频字节追加到输入音频缓冲区。
事件结构
{
"type": "input_audio_buffer.append",
"audio": "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA="
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "input_audio_buffer.append" |
| audio | 字符串 | Base64 编码的音频数据 |
input_audio_buffer.commit
提交用于处理的输入音频缓冲区。
事件结构
{
"type": "input_audio_buffer.commit"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "input_audio_buffer.commit" |
input_audio_buffer.clear
清除输入音频缓冲区。
事件结构
{
"type": "input_audio_buffer.clear"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "input_audio_buffer.clear" |
conversation.item.create
向聊天上下文添加新项。 这可以包括消息、函数调用和函数调用响应。 可以在对话历史记录中的特定位置插入项目。
事件结构
{
"type": "conversation.item.create",
"previous_item_id": "item_ABC123",
"item": {
"id": "item_DEF456",
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, how are you?"
}
]
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.create" |
| previous_item_id | 字符串 | 可选。 要在其后面插入此项的项的 ID。 如果未提供,则追加到末尾 |
| 项 | RealtimeConversationRequestItem | 要添加到对话的项目 |
音频内容示例
{
"type": "conversation.item.create",
"item": {
"type": "message",
"role": "user",
"content": [
{
"type": "input_audio",
"audio": "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=",
"transcript": "Hello there"
}
]
}
}
函数调用示例
{
"type": "conversation.item.create",
"item": {
"type": "function_call",
"name": "get_weather",
"call_id": "call_123",
"arguments": "{\"location\": \"San Francisco\", \"unit\": \"celsius\"}"
}
}
conversation.item.retrieve
从对话历史记录中检索特定项。 这对于在消除噪音和 VAD 后检查已处理的音频非常有用。
事件结构
{
"type": "conversation.item.retrieve",
"item_id": "item_ABC123"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.retrieve" |
| item_id | 字符串 | 要检索的项的 ID |
conversation.item.truncate
截断助理消息的音频内容。 这对于在特定时间点停止播放以及将服务器的了解与客户端状态同步非常有用。
事件结构
{
"type": "conversation.item.truncate",
"item_id": "item_ABC123",
"content_index": 0,
"audio_end_ms": 5000
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.truncate" |
| item_id | 字符串 | 要截断的助理消息项的 ID |
| content_index | 整数 | 要截断的内容部件的索引 |
| audio_end_ms | 整数 | 截断音频的持续时间(以毫秒为单位) |
conversation.item.delete
从对话历史记录中删除项目。
事件结构
{
"type": "conversation.item.delete",
"item_id": "item_ABC123"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.delete" |
| item_id | 字符串 | 要删除的项的 ID |
response.create
指示服务器通过模型推理创建响应。 此事件可以指定替代会话默认值的特定于响应的配置。
事件结构
{
"type": "response.create",
"response": {
"modalities": ["text", "audio"],
"instructions": "Be extra helpful and detailed.",
"voice": {
"type": "openai",
"name": "alloy"
},
"output_audio_format": "pcm16",
"temperature": 0.7,
"max_response_output_tokens": 1000
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.create" |
| response | RealtimeResponseOptions | 替代会话默认值的可选响应配置 |
工具选项示例
{
"type": "response.create",
"response": {
"modalities": ["text"],
"tools": [
{
"type": "function",
"name": "get_current_time",
"description": "Get the current time",
"parameters": {
"type": "object",
"properties": {}
}
}
],
"tool_choice": "get_current_time",
"temperature": 0.3
}
}
动画示例
{
"type": "response.create",
"response": {
"modalities": ["audio", "animation"],
"animation": {
"model_name": "default",
"outputs": ["blendshapes", "viseme_id"]
},
"voice": {
"type": "azure-custom",
"name": "my-expressive-voice",
"endpoint_id": "12345678-1234-1234-1234-123456789012",
"style": "excited"
}
}
}
response.cancel
取消正在进行的响应。 这会立即停止响应生成和相关音频输出。
事件结构
{
"type": "response.cancel"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.cancel" |
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.retrieve. |
| item_id | 字符串 | 要检索的项的 ID。 |
| event_id | 字符串 | 事件的 ID。 |
RealtimeClientEventConversationItemTruncate
客户端 conversation.item.truncate 事件用于截断上一条助理消息的音频。 服务器生成的音频速度比实时快,因此当用户中断以截断发送到客户端但尚未播放的音频时,此事件非常有用。 服务器对音频的理解与客户端的播放是同步的。
截断音频会删除服务器端文本脚本,以确保上下文中不存在用户不知道的文本。
如果客户端事件成功,服务器将响应事件 conversation.item.truncated 。
事件结构
{
"type": "conversation.item.truncate",
"item_id": "<item_id>",
"content_index": 0,
"audio_end_ms": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.truncate. |
| item_id | 字符串 | 要截断的助理消息项的 ID。 只能截断助理消息项。 |
| content_index | 整数 | 要截断的内容部件的索引。 将此属性设置为“0”。 |
| audio_end_ms | 整数 | 非独占持续时间,最长截断音频(以毫秒为单位)。 如果audio_end_ms大于实际音频持续时间,服务器将响应错误。 |
RealtimeClientEventInputAudioBufferAppend
客户端 input_audio_buffer.append 事件用于将音频字节追加到输入音频缓冲区。 音频缓冲区是可以写入到稍后提交的临时存储。
在服务器 VAD(语音活动检测)模式下,音频缓冲区用于检测语音,服务器决定何时提交。 禁用服务器 VAD 后,客户端可以选择每个事件中最多放置 15 MiB 的音频量。 例如,从客户端流式传输较小的区块可以让 VAD 响应更迅速。
与其他大多数客户端事件不同,服务器不会向客户端 input_audio_buffer.append 事件发送确认响应。
事件结构
{
"type": "input_audio_buffer.append",
"audio": "<audio>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.append. |
| audio | 字符串 | Base64 编码的音频字节。 此值必须采用会话配置中字段指定的 input_audio_format 格式。 |
RealtimeClientEventInputAudioBufferClear
客户端 input_audio_buffer.clear 事件用于清除缓冲区中的音频字节。
服务器使用事件 input_audio_buffer.cleared 进行响应。
事件结构
{
"type": "input_audio_buffer.clear"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.clear. |
RealtimeClientEventInputAudioBufferCommit
客户端 input_audio_buffer.commit 事件用于提交用户输入音频缓冲区,该缓冲区在会话中创建新的用户消息项。 如果 input_audio_transcription 为会话配置了音频,则会转录音频。
在服务器 VAD 模式下,客户端不需要发送此事件,服务器会自动提交音频缓冲区。 如果没有服务器 VAD,客户端必须提交音频缓冲区才能创建用户消息项。 如果输入音频缓冲区为空,则此客户端事件将生成错误。
提交输入音频缓冲区不会从模型创建响应。
服务器使用事件 input_audio_buffer.committed 进行响应。
事件结构
{
"type": "input_audio_buffer.commit"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.commit. |
RealtimeClientEventResponseCancel
客户端 response.cancel 事件用于取消正在进行的响应。
服务器将使用状态为 <
事件结构
{
"type": "response.cancel"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.cancel. |
RealtimeClientEventResponseCreate
客户端 response.create 事件用于指示服务器通过模型推理创建响应。 在服务器 VAD 模式下配置会话时,服务器会自动创建响应。
响应至少包括一个 item,并且可以有两个,在这种情况下,第二个是函数调用。 这些项目将追加到对话历史记录中。
服务器使用事件 response.created 、一个或多个项和内容事件(如 conversation.item.created 和 response.content_part.added)进行响应,最后一个 response.done 事件指示响应已完成。
事件结构
{
"type": "response.create"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.create. |
| response | RealtimeResponseOptions | 响应选项。 |
RealtimeClientEventSessionUpdate
客户端 session.update 事件用于更新会话的默认配置。 客户端可以随时发送此事件来更新会话配置,并且任何字段都可以随时更新,语音除外。
仅更新存在的字段。 若要清除字段(例如 instructions),请传递一个空字符串。
服务器使用 session.updated 包含完整有效配置的事件进行响应。
事件结构
{
"type": "session.update"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 session.update. |
| 会话 | RealtimeRequestSession | 会话配置。 |
服务器事件
语音实时 API 将以下服务器事件发送到客户端,以传达状态、响应和数据:
session.created
成功建立新会话时发送。 这是连接到 API 后收到的第一个事件。
事件结构
{
"type": "session.created",
"session": {
"id": "sess_ABC123DEF456",
"object": "realtime.session",
"model": "gpt-realtime",
"modalities": ["text", "audio"],
"instructions": "You are a helpful assistant.",
"voice": {
"type": "openai",
"name": "alloy"
},
"input_audio_format": "pcm16",
"output_audio_format": "pcm16",
"input_audio_sampling_rate": 24000,
"turn_detection": {
"type": "azure_semantic_vad",
"threshold": 0.5,
"prefix_padding_ms": 300,
"silence_duration_ms": 500
},
"temperature": 0.8,
"max_response_output_tokens": "inf"
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "session.created" |
| 会话 | RealtimeResponseSession | 创建的会话对象 |
session.updated
成功更新会话配置以响应 session.update 客户端事件时发送。
事件结构
{
"type": "session.updated",
"session": {
"id": "sess_ABC123DEF456",
"voice": {
"type": "azure-custom",
"name": "my-voice",
"endpoint_id": "12345678-1234-1234-1234-123456789012"
},
"temperature": 0.7,
"avatar": {
"character": "lisa",
"customized": false
}
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "session.updated" |
| 会话 | RealtimeResponseSession | 更新的会话对象 |
session.avatar.connecting
指示正在建立虚拟形象 WebRTC 连接。 此事件在响应 session.avatar.connect 客户端事件时发送。
事件结构
{
"type": "session.avatar.connecting",
"server_sdp": "<server_sdp>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "session.avatar.connecting" |
conversation.item.created
在通过客户端 conversation.item.create 事件或响应生成过程中自动将新项添加到会话时发送。
事件结构
{
"type": "conversation.item.created",
"previous_item_id": "item_ABC123",
"item": {
"id": "item_DEF456",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, how are you?"
}
]
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.created" |
| previous_item_id | 字符串 | 在其中插入此项的项的 ID |
| 项 | RealtimeConversationResponseItem | 创建的对话项 |
音频项的示例
{
"type": "conversation.item.created",
"item": {
"id": "item_GHI789",
"type": "message",
"status": "completed",
"role": "user",
"content": [
{
"type": "input_audio",
"audio": null,
"transcript": "What's the weather like today?"
}
]
}
}
conversation.item.retrieved
发送响应 conversation.item.retrieve 客户端事件,提供请求的对话项。
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.created" |
| 项 | RealtimeConversationResponseItem | 创建的对话项 |
conversation.item.truncated
当客户端截断具有事件的早期助理音频消息项conversation.item.truncated时,将返回服务器conversation.item.truncate事件。 此事件用于将服务器对音频的理解与客户端的播放同步。
此事件截断音频并删除服务器端文本脚本,以确保用户不知道的上下文中没有文本。
事件结构
{
"type": "conversation.item.truncated",
"item_id": "<item_id>",
"content_index": 0,
"audio_end_ms": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.truncated. |
| item_id | 字符串 | 截断的助理消息项的 ID。 |
| content_index | 整数 | 截断的内容部件的索引。 |
| audio_end_ms | 整数 | 音频截断的持续时间(以毫秒为单位)。 |
conversation.item.deleted
在响应 conversation.item.delete 客户端事件时发送,确认已从会话中删除指定项。
事件结构
{
"type": "conversation.item.deleted",
"item_id": "item_ABC123"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "conversation.item.deleted" |
| item_id | 字符串 | 已删除项的 ID |
response.created
在新的响应生成开始时发送。 这是响应序列中的第一个事件。
事件结构
{
"type": "response.created",
"response": {
"id": "resp_ABC123",
"object": "realtime.response",
"status": "in_progress",
"status_details": null,
"output": [],
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0
}
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.created" |
| response | RealtimeResponse | 创建的响应对象 |
response.done
完成响应生成时发送。 此事件包含包含所有输出项和使用情况统计信息的最终响应。
事件结构
{
"type": "response.done",
"response": {
"id": "resp_ABC123",
"object": "realtime.response",
"status": "completed",
"status_details": null,
"output": [
{
"id": "item_DEF456",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
]
}
],
"usage": {
"total_tokens": 87,
"input_tokens": 52,
"output_tokens": 35,
"input_token_details": {
"cached_tokens": 0,
"text_tokens": 45,
"audio_tokens": 7
},
"output_token_details": {
"text_tokens": 15,
"audio_tokens": 20
}
}
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.done" |
| response | RealtimeResponse | 已完成的响应对象 |
response.output_item.added
在生成过程中将新的输出项添加到响应时发送。
事件结构
{
"type": "response.output_item.added",
"response_id": "resp_ABC123",
"output_index": 0,
"item": {
"id": "item_DEF456",
"object": "realtime.item",
"type": "message",
"status": "in_progress",
"role": "assistant",
"content": []
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.output_item.added" |
| response_id | 字符串 | 此项目所属的响应的 ID |
| output_index | 整数 | 响应输出数组中项的索引 |
| 项 | RealtimeConversationResponseItem | 已添加的输出项 |
response.output_item.done
输出项完成时发送。
事件结构
{
"type": "response.output_item.done",
"response_id": "resp_ABC123",
"output_index": 0,
"item": {
"id": "item_DEF456",
"object": "realtime.item",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
]
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.output_item.done" |
| response_id | 字符串 | 此项目所属的响应的 ID |
| output_index | 整数 | 响应输出数组中项的索引 |
| 项 | RealtimeConversationResponseItem | 已完成的输出项 |
response.content_part.added
当在响应生成过程中将新内容部件添加到助理消息项时,将返回服务器 response.content_part.added 事件。
事件结构
{
"type": "response.content_part.added",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"part": {
"type": "text",
"text": ""
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.content_part.added" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 此内容部件所属的项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 项中此内容部件的索引 |
| 部件 | RealtimeContentPart | 已添加的内容部件 |
response.content_part.done
当内容部件在助理消息项中完成流式处理时,将返回服务器 response.content_part.done 事件。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.content_part.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"part": {
"type": "text",
"text": "Hello! I'm doing well, thank you for asking."
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.content_part.done" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 此内容部件所属的项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 项中此内容部件的索引 |
| 部件 | RealtimeContentPart | 已完成的内容部件 |
response.text.delta
从模型流式处理文本内容。 在模型生成文本时以增量方式发送。
事件结构
{
"type": "response.text.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"delta": "Hello! I'm"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.text.delta" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| delta | 字符串 | 增量文本内容 |
response.text.done
在文本内容生成完成时发送。
事件结构
{
"type": "response.text.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.text.done" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| 文本消息 | 字符串 | 完整文本内容 |
response.audio.delta
从模型流式传输音频内容。 音频以 base64 编码的数据的形式提供。
事件结构
{
"type": "response.audio.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"delta": "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA="
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.audio.delta" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| delta | 字符串 | Base64 编码的音频数据区块 |
response.audio.done
当音频内容生成完成时发送。
事件结构
{
"type": "response.audio.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.audio.done" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
response.audio_transcript.delta
生成的音频内容的流式处理脚本。
事件结构
{
"type": "response.audio_transcript.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"delta": "Hello! I'm doing"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.audio_transcript.delta" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| delta | 字符串 | 增量脚本文本 |
response.audio_transcript.done
当音频脚本生成完成时发送。
事件结构
{
"type": "response.audio_transcript.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"transcript": "Hello! I'm doing well, thank you for asking. How can I help you today?"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "response.audio_transcript.done" |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| 脚本 | 字符串 | 完整的脚本文本 |
conversation.item.input_audio_transcription.completed
服务器 conversation.item.input_audio_transcription.completed 事件是写入音频缓冲区的语音听录的结果。
当客户端或服务器(模式) server_vad 提交输入音频缓冲区时,将开始听录。 脚本在创建响应时异步运行,因此此事件可以在响应事件之前或之后运行。
实时 API 模型以本机方式接受音频,因此输入听录是在单独的语音识别模型上运行的单独进程,例如 whisper-1。 因此,脚本可能会从模型的解释中略有不同,应被视为粗略的指南。
事件结构
{
"type": "conversation.item.input_audio_transcription.completed",
"item_id": "<item_id>",
"content_index": 0,
"transcript": "<transcript>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.input_audio_transcription.completed. |
| item_id | 字符串 | 包含音频的用户消息项的 ID。 |
| content_index | 整数 | 包含音频的内容部件的索引。 |
| 脚本 | 字符串 | 转录的文本。 |
conversation.item.input_audio_transcription.delta
配置输入音频听录时,将返回服务器 conversation.item.input_audio_transcription.delta 事件,并且正在进行用户消息的听录请求。 此事件提供部分听录结果,因为它们可用。
事件结构
{
"type": "conversation.item.input_audio_transcription.delta",
"item_id": "<item_id>",
"content_index": 0,
"delta": "<delta>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.input_audio_transcription.delta. |
| item_id | 字符串 | 用户消息项的 ID。 |
| content_index | 整数 | 包含音频的内容部件的索引。 |
| delta | 字符串 | 增量听录文本。 |
conversation.item.input_audio_transcription.failed
配置输入音频听录时,将返回服务器 conversation.item.input_audio_transcription.failed 事件,并且用户消息的听录请求失败。 此事件与其他 error 事件分开,以便客户端能够标识相关项。
事件结构
{
"type": "conversation.item.input_audio_transcription.failed",
"item_id": "<item_id>",
"content_index": 0,
"error": {
"code": "<code>",
"message": "<message>",
"param": "<param>"
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 conversation.item.input_audio_transcription.failed. |
| item_id | 字符串 | 用户消息项的 ID。 |
| content_index | 整数 | 包含音频的内容部件的索引。 |
| 错误 | 对象 | 听录错误的详细信息。 请参阅下一个表中的嵌套属性。 |
错误属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 错误的类型。 |
| 代码 | 字符串 | 错误代码(如果有)。 |
| 消息 | 字符串 | 用户可读的错误消息。 |
| param | 字符串 | 与错误相关的参数(如果有)。 |
response.animation_blendshapes.delta
当模型生成动画混合图形数据作为响应的一部分时,将返回服务器 response.animation_blendshapes.delta 事件。 此事件提供增量混合图形数据,因为它可用。
事件结构
{
"type": "response.animation_blendshapes.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"frame_index": 0,
"frames": [
[0.0, 0.1, 0.2, ..., 1.0]
...
]
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.animation_blendshapes.delta. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| frame_index | 整数 | 此批帧中第一帧的索引 |
| 框架 | float 数组的数组 | blendshape 帧的数组,每个帧都是 blendshape 值的数组 |
response.animation_blendshapes.done
当模型完成生成动画混合图形数据作为响应的一部分时,将返回服务器 response.animation_blendshapes.done 事件。
事件结构
{
"type": "response.animation_blendshapes.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.animation_blendshapes.done. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
response.audio_timestamp.delta
当模型生成音频时间戳数据作为响应的一部分时,将返回服务器 response.audio_timestamp.delta 事件。 此事件提供输出音频和文本对齐的增量时间戳数据,因为它变得可用。
事件结构
{
"type": "response.audio_timestamp.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"audio_offset_ms": 0,
"audio_duration_ms": 500,
"text": "Hello",
"timestamp_type": "word"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio_timestamp.delta. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| audio_offset_ms | 整数 | 从音频开始开始的音频偏移量(以毫秒为单位) |
| audio_duration_ms | 整数 | 音频段的持续时间(以毫秒为单位) |
| 文本消息 | 字符串 | 与此音频时间戳对应的文本段 |
| timestamp_type | 字符串 | 时间戳类型,目前仅支持“word” |
response.audio_timestamp.done
当音频时间戳生成完成时发送。
事件结构
{
"type": "response.audio_timestamp.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio_timestamp.done. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
response.animation_viseme.delta
当模型在响应过程中生成动画 viseme 数据时,将返回服务器 response.animation_viseme.delta 事件。 此事件在可用时提供增量 viseme 数据。
事件结构
{
"type": "response.animation_viseme.delta",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0,
"audio_offset_ms": 0,
"viseme_id": 1
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.animation_viseme.delta. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
| audio_offset_ms | 整数 | 从音频开始开始的音频偏移量(以毫秒为单位) |
| viseme_id | 整数 | 对应于用于动画的嘴形状的视线 ID |
response.animation_viseme.done
当模型完成作为响应的一部分生成动画视觉数据时,将返回服务器 response.animation_viseme.done 事件。
事件结构
{
"type": "response.animation_viseme.done",
"response_id": "resp_ABC123",
"item_id": "item_DEF456",
"output_index": 0,
"content_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.animation_viseme.done. |
| response_id | 字符串 | 响应的 ID |
| item_id | 字符串 | 项的 ID |
| output_index | 整数 | 响应中项的索引 |
| content_index | 整数 | 内容部件的索引 |
当模型在响应过程中生成动画 viseme 数据时,将返回服务器 response.animation_viseme.delta 事件。 此事件在可用时提供增量 viseme 数据。
错误
发生错误时会返回服务器 error 事件,这可能是客户端问题或服务器问题。 大多数错误都是可恢复的,会话保持打开状态。
事件结构
{
"type": "error",
"error": {
"code": "<code>",
"message": "<message>",
"param": "<param>",
"event_id": "<event_id>"
}
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 error. |
| 错误 | 对象 | 错误的详细信息。 请参阅下一个表中的嵌套属性。 |
错误属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 错误的类型。 例如,“invalid_request_error”和“server_error”是错误类型。 |
| 代码 | 字符串 | 错误代码(如果有)。 |
| 消息 | 字符串 | 用户可读的错误消息。 |
| param | 字符串 | 与错误相关的参数(如果有)。 |
| event_id | 字符串 | 导致错误的客户端事件的 ID(如果适用)。 |
input_audio_buffer.cleared
当客户端使用input_audio_buffer.cleared事件清除输入音频缓冲区时,将返回服务器input_audio_buffer.clear事件。
事件结构
{
"type": "input_audio_buffer.cleared"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.cleared. |
input_audio_buffer.committed
当客户端提交输入音频缓冲区或在服务器 VAD 模式下自动提交时,将返回服务器 input_audio_buffer.committed 事件。 该 item_id 属性是创建的用户消息项的 ID。 因此, conversation.item.created 事件也会发送到客户端。
事件结构
{
"type": "input_audio_buffer.committed",
"previous_item_id": "<previous_item_id>",
"item_id": "<item_id>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.committed. |
| previous_item_id | 字符串 | 在其之后插入新项的上一项的 ID。 |
| item_id | 字符串 | 创建的用户消息项的 ID。 |
input_audio_buffer.speech_started
input_audio_buffer.speech_started在音频缓冲区中检测到语音时,服务器事件以模式返回server_vad。 只要音频添加到缓冲区(除非检测到语音),此事件可能会发生。
注释
客户端可能希望使用此事件来中断音频播放或向用户提供视觉反馈。
客户端应在语音停止时收到 input_audio_buffer.speech_stopped 事件。 该 item_id 属性是语音停止时创建的用户消息项的 ID。
item_id除非客户端在 VAD 激活期间手动提交音频缓冲区,否则该事件也包含在input_audio_buffer.speech_stopped事件中。
事件结构
{
"type": "input_audio_buffer.speech_started",
"audio_start_ms": 0,
"item_id": "<item_id>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.speech_started. |
| audio_start_ms | 整数 | 在首次检测到语音时,会话期间写入缓冲区的所有音频的开始时间的毫秒数。 此属性对应于发送到模型的音频的开头,因此包括在 prefix_padding_ms 会话中配置的音频。 |
| item_id | 字符串 | 语音停止时创建的用户消息项的 ID。 |
input_audio_buffer.speech_stopped
服务器在音频缓冲区中检测到语音结束时,以模式返回input_audio_buffer.speech_stopped服务器server_vad事件。
服务器还会发送一个 conversation.item.created 事件,其中包含从音频缓冲区创建的用户消息项。
事件结构
{
"type": "input_audio_buffer.speech_stopped",
"audio_end_ms": 0,
"item_id": "<item_id>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 input_audio_buffer.speech_stopped. |
| audio_end_ms | 整数 | 会话在语音停止时启动的毫秒数。 此属性对应于发送到模型的音频的末尾,因此包括在 min_silence_duration_ms 会话中配置的音频。 |
| item_id | 字符串 | 创建的用户消息项的 ID。 |
rate_limits.updated
rate_limits.updated服务器事件在响应开始时发出,以指示更新的速率限制。
创建响应时,某些令牌将保留给输出令牌。 此处显示的速率限制反映预留,然后在响应完成后相应地进行调整。
事件结构
{
"type": "rate_limits.updated",
"rate_limits": [
{
"name": "<name>",
"limit": 0,
"remaining": 0,
"reset_seconds": 0
}
]
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 rate_limits.updated. |
| rate_limits | RealtimeRateLimitsItem 数组 | 速率限制信息的列表。 |
response.audio.delta
更新模型生成的音频时,将返回服务器 response.audio.delta 事件。
事件结构
{
"type": "response.audio.delta",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0,
"delta": "<delta>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio.delta. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
| delta | 字符串 | Base64 编码的音频数据增量。 |
response.audio.done
模型生成的音频完成后,将返回服务器 response.audio.done 事件。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.audio.done",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio.done. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
response.audio_transcript.delta
更新音频输出的模型生成的听录时,将返回服务器 response.audio_transcript.delta 事件。
事件结构
{
"type": "response.audio_transcript.delta",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0,
"delta": "<delta>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio_transcript.delta. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
| delta | 字符串 | 脚本增量。 |
response.audio_transcript.done
当音频输出的模型生成的听录完成流式处理时,将返回服务器 response.audio_transcript.done 事件。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.audio_transcript.done",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0,
"transcript": "<transcript>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.audio_transcript.done. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
| 脚本 | 字符串 | 音频的最终脚本。 |
response.function_call_arguments.delta
更新模型生成的函数调用参数时,将返回服务器 response.function_call_arguments.delta 事件。
事件结构
{
"type": "response.function_call_arguments.delta",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"call_id": "<call_id>",
"delta": "<delta>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.function_call_arguments.delta. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 函数调用项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| call_id | 字符串 | 函数调用的 ID。 |
| delta | 字符串 | 参数增量为 JSON 字符串。 |
response.function_call_arguments.done
当模型生成的函数调用参数完成流式处理时,将返回服务器 response.function_call_arguments.done 事件。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.function_call_arguments.done",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"call_id": "<call_id>",
"arguments": "<arguments>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.function_call_arguments.done. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 函数调用项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| call_id | 字符串 | 函数调用的 ID。 |
| arguments | 字符串 | 最终参数作为 JSON 字符串。 |
response.output_item.added
在响应生成期间创建新项时,将返回服务器 response.output_item.added 事件。
事件结构
{
"type": "response.output_item.added",
"response_id": "<response_id>",
"output_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.output_item.added. |
| response_id | 字符串 | 项所属的响应的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| 项 | RealtimeConversationResponseItem | 已添加的项。 |
response.output_item.done
当项完成流式处理时,将返回服务器 response.output_item.done 事件。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.output_item.done",
"response_id": "<response_id>",
"output_index": 0
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.output_item.done. |
| response_id | 字符串 | 项所属的响应的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| 项 | RealtimeConversationResponseItem | 完成流式处理的项目。 |
response.text.delta
更新模型生成的文本时,将返回服务器 response.text.delta 事件。 文本对应于 text 助理消息项的内容部分。
事件结构
{
"type": "response.text.delta",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0,
"delta": "<delta>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.text.delta. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
| delta | 字符串 | 文本增量。 |
response.text.done
当模型生成的文本完成流式处理时,将返回服务器 response.text.done 事件。 文本对应于 text 助理消息项的内容部分。
当响应中断、不完整或取消时,也会返回此事件。
事件结构
{
"type": "response.text.done",
"response_id": "<response_id>",
"item_id": "<item_id>",
"output_index": 0,
"content_index": 0,
"text": "<text>"
}
属性
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 事件类型必须为 response.text.done. |
| response_id | 字符串 | 响应的 ID。 |
| item_id | 字符串 | 项的 ID。 |
| output_index | 整数 | 响应中输出项的索引。 |
| content_index | 整数 | 项内容数组中内容部件的索引。 |
| 文本消息 | 字符串 | 最终文本内容。 |
Components
音频格式
RealtimeAudioFormat
用于输入音频的基本音频格式。
允许的值:
-
pcm16- 16 位 PCM 音频格式 -
g711_ulaw- G.711 μ法律音频格式 -
g711_alaw- G.711 A-law 音频格式
RealtimeOutputAudioFormat
用于具有特定采样率的输出音频的音频格式。
允许的值:
-
pcm16- 默认采样率为 16 位 PCM 音频格式(24kHz) -
pcm16_8000hz- 16 位 PCM 音频格式,采用 8kHz 采样率 -
pcm16_16000hz- 16 位 PCM 音频格式,采样率为 16kHz -
g711_ulaw- G.711 μ-law (mu-law) 音频格式,采用 8kHz 采样率 -
g711_alaw- G.711 A-law 音频格式(采用 8kHz 采样率)
RealtimeAudioInputTranscriptionSettings
输入音频转录的配置。
| 领域 | 类型 | Description |
|---|---|---|
| 模型 | 字符串 | 听录模型。 支持:whisper-1、、gpt-4o-transcribe、 gpt-4o-mini-transcribeazure-speech |
| 语言 | 字符串 | BCP-47(例如, en-US例如,)或 ISO-639-1(例如, en)中的可选语言代码,或具有自动检测的多语言(例如, en,zh例如)。 |
| custom_speech | 对象 | 自定义语音模型的可选配置,仅适用于 azure-speech 模型。 |
| phrase_list | 字符串[] | 用于偏差识别的短语提示的可选列表,仅适用于 azure-speech 模型。 |
| 提示 | 字符串 | 用于指导听录的可选提示文本,仅适用于whisper-1gpt-4o-transcribe和gpt-4o-mini-transcribe模型。 |
RealtimeInputAudioNoiseReductionSettings
输入音频降噪的配置。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "azure_deep_noise_suppression" |
RealtimeInputAudioEchoCancellationSettings
服务器端音频处理的回声取消配置。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "server_echo_cancellation" |
语音配置
RealtimeVoice
所有支持的语音配置的联合。
这可以是:
RealtimeOpenAIVoice
具有显式类型字段的 OpenAI 语音配置。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "openai" |
| 姓名 | 字符串 | OpenAI 语音名称:alloy、、ash、balladcoralecho、sage、、 shimmerverse |
RealtimeAzureVoice
Azure 语音配置的基数。 这是不同类型的区分联合:
RealtimeAzureCustomVoice
Azure 自定义语音配置(首选用于自定义语音)。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "azure-custom" |
| 姓名 | 字符串 | 语音名称(不能为空) |
| endpoint_id | 字符串 | 终结点 ID (不能为空) |
| 温度 | 数字 | 可选。 温度介于 0.0 和 1.0 之间 |
| custom_lexicon_url | 字符串 | 可选。 自定义词典的 URL |
| prefer_locales | 字符串[] | 可选。 首选区域设置 |
| 区域设置 | 字符串 | 可选。 区域设置规范 |
| 样式 | 字符串 | 可选。 语音样式 |
| 投 | 字符串 | 可选。 音调调整 |
| 率 | 字符串 | 可选。 语音速率调整 |
| volume | 字符串 | 可选。 音量调整 |
示例:
{
"type": "azure-custom",
"name": "my-custom-voice",
"endpoint_id": "12345678-1234-1234-1234-123456789012",
"temperature": 0.7,
"style": "cheerful",
"locale": "en-US"
}
RealtimeAzureStandardVoice
Azure 标准语音配置。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "azure-standard" |
| 姓名 | 字符串 | 语音名称(不能为空) |
| 温度 | 数字 | 可选。 温度介于 0.0 和 1.0 之间 |
| custom_lexicon_url | 字符串 | 可选。 自定义词典的 URL |
| prefer_locales | 字符串[] | 可选。 首选区域设置 |
| 区域设置 | 字符串 | 可选。 区域设置规范 |
| 样式 | 字符串 | 可选。 语音样式 |
| 投 | 字符串 | 可选。 音调调整 |
| 率 | 字符串 | 可选。 语音速率调整 |
| volume | 字符串 | 可选。 音量调整 |
RealtimeAzurePersonalVoice
Azure 个人语音配置。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "azure-personal" |
| 姓名 | 字符串 | 语音名称(不能为空) |
| 温度 | 数字 | 可选。 温度介于 0.0 和 1.0 之间 |
| 模型 | 字符串 | 基础神经模型:DragonLatestNeural、、 PhoenixLatestNeuralPhoenixV2Neural |
轮次检测
RealtimeTurnDetection
轮次检测的配置。 这是支持多个 VAD 类型的歧视联合。
RealtimeServerVad
基于 VAD 的基本轮次检测。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "server_vad" |
| 阈值 | 数字 | 可选。 激活阈值 (0.0-1.0) |
| prefix_padding_ms | 整数 | 可选。 语音开始前的音频填充 |
| silence_duration_ms | 整数 | 可选。 用于检测语音结束的静音持续时间 |
| end_of_utterance_detection | RealtimeEOUDetection | 可选。 言语结束检测配置 |
| auto_truncate | 布尔 | 可选。 中断时自动截断(默认值:false) |
RealtimeAzureSemanticVad
Azure 语义 VAD(默认变体)。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "azure_semantic_vad" |
| 阈值 | 数字 | 可选。 激活阈值 |
| prefix_padding_ms | 整数 | 可选。 语音前的音频填充 |
| silence_duration_ms | 整数 | 可选。 语音结束的静音持续时间 |
| end_of_utterance_detection | RealtimeEOUDetection | 可选。 EOU 检测配置 |
| neg_threshold | 数字 | 可选。 负阈值 |
| speech_duration_ms | 整数 | 可选。 最小语音持续时间 |
| window_size | 整数 | 可选。 分析窗口大小 |
| distinct_ci_phones | 整数 | 可选。 不同的 CI 手机要求 |
| require_vowel | 布尔 | 可选。 在语音中要求元音 |
| remove_filler_words | 布尔 | 可选。 删除填充词(默认值:false) |
| 语言 | 字符串[] | 可选。 支持的语言 |
| auto_truncate | 布尔 | 可选。 中断时自动截断(默认值:false) |
RealtimeEOUDetection
Azure 言语结束(EOU)可以指示最终用户何时停止说话,同时允许自然暂停。 话语结束检测可以显著减少过早的谈话结束信号,而无需增加用户可察觉的延迟。
| 领域 | 类型 | Description |
|---|---|---|
| 模型 | 字符串 | 支持 semantic_detection_v1 英语或 semantic_detection_v1_multilingual 支持英语、西班牙语、法语、意大利语、德语(DE)、日语、葡萄牙语、中文、朝鲜语、印地语 |
| threshold_level | 字符串 | 可选。 检测阈值级别(lowmediumhigh和default),默认值为default |
| timeout_ms | 数字 | 等待更多用户语音的最长时间(以毫秒为单位)。 默认值为 1000 毫秒。 |
虚拟形象配置
RealtimeAvatarConfig
虚拟形象流式处理和行为的配置。
| 领域 | 类型 | Description |
|---|---|---|
| ice_servers | RealtimeIceServer[] | 可选。 WebRTC 的 ICE 服务器 |
| 字符 | 字符串 | 虚拟形象的字符名称或 ID |
| 样式 | 字符串 | 可选。 阿凡达风格(情感语气,说话风格) |
| 定制 | 布尔 | 是否自定义头像 |
| 视频 | RealtimeVideoParams | 可选。 视频配置 |
RealtimeIceServer
WebRTC 连接协商的 ICE 服务器配置。
| 领域 | 类型 | Description |
|---|---|---|
| 网址 | 字符串[] | ICE 服务器 URL (TURN 或 STUN 终结点) |
| 用户名 | 字符串 | 可选。 身份验证用户名 |
| 凭据 | 字符串 | 可选。 身份验证凭据 |
RealtimeVideoParams
虚拟形象的视频流式处理参数。
| 领域 | 类型 | Description |
|---|---|---|
| 比特率 | 整数 | 可选。 每秒比特率(默认值:2000000) |
| 编解码器 | 字符串 | 可选。 视频编解码器,当前仅 h264 (默认值: h264) |
| 剪切 | RealtimeVideoCrop | 可选。 裁剪设置 |
| 分辨率 | RealtimeVideoResolution | 可选。 解决方法设置 |
RealtimeVideoCrop
视频裁剪矩形定义。
| 领域 | 类型 | Description |
|---|---|---|
| top_left | integer[] | 左上角 [x, y], 非负整数 |
| bottom_right | integer[] | 右下角 [x, y], 非负整数 |
RealtimeVideoResolution
视频分辨率规范。
| 领域 | 类型 | Description |
|---|---|---|
| width | 整数 | 宽度(以像素为单位)(必须为 > 0) |
| 身高 | 整数 | 高度(以像素为单位)(必须为 > 0) |
动画配置
RealtimeAnimation
动画输出的配置,包括 blendshapes 和 visemes。
| 领域 | 类型 | Description |
|---|---|---|
| model_name | 字符串 | 可选。 动画模型名称(默认值: "default") |
| outputs | RealtimeAnimationOutputType[] | 可选。 输出类型(默认值: ["blendshapes"]) |
RealtimeAnimationOutputType
要输出的动画数据类型。
允许的值:
-
blendshapes- 面部混合图形数据 -
viseme_id- Viseme 标识符数据
会话配置
RealtimeRequestSession
事件中使用的 session.update 会话配置对象。
| 领域 | 类型 | Description |
|---|---|---|
| 模型 | 字符串 | 可选。 要使用的模型名称 |
| modalities | RealtimeModality[] | 可选。 会话支持的模式。 例如,“modalities”: [“text”, “audio”] 是启用文本和音频形式的默认设置。 若要仅启用文本,请设置“modalities”: [“text”。 若要启用虚拟形象输出,请设置“modalities”:[“text”、“audio”、“avatar”。 不能仅启用音频。 |
| 动画 | RealtimeAnimation | 可选。 动画配置 |
| 语音 | RealtimeVoice | 可选。 语音配置 |
| 指示 | 字符串 | 可选。 模型的系统说明。 如果使用 OpenAI 语音,但不适用于 Azure 语音,则说明可以指导输出音频。 |
| input_audio_sampling_rate | 整数 | 可选。 Hz 中的输入音频采样率(默认值:24000 for pcm16、8000 for g711_ulaw 和 g711_alaw) |
| input_audio_format | RealtimeAudioFormat | 可选。 输入音频格式(默认值: pcm16) |
| output_audio_format | RealtimeOutputAudioFormat | 可选。 输出音频格式(默认值: pcm16) |
| input_audio_noise_reduction | RealtimeInputAudioNoiseReductionSettings | 输入音频降噪的配置。 这可以设置为 null 以关闭。 降噪会筛选添加到输入音频缓冲区的音频,然后再将其发送到 VAD 和模型。 筛选音频可以通过改进输入音频的感知来提高 VAD 和轮次检测准确性(减少误报)和模型性能。 此属性可为 null。 |
| input_audio_echo_cancellation | RealtimeInputAudioEchoCancellationSettings | 输入音频回声取消的配置。 这可以设置为 null 以关闭。 此服务端回声取消可以通过减少回声和混响的影响来帮助提高输入音频的质量。 此属性可为 null。 |
| input_audio_transcription | RealtimeAudioInputTranscriptionSettings | 输入音频听录的配置。 默认情况下,配置为 null(off)。 输入音频转录不是模型本身的功能,因为模型可以直接处理音频。 听录通过 /audio/transcriptions 终结点异步运行,应被视为输入音频内容的指南,而不是模型听到的内容。 有关听录服务的其他指导,客户端可以选择设置语言并提示听录。此属性可为 null。 |
| turn_detection | RealtimeTurnDetection | 会话的轮次检测设置。 这可以设置为 null 以关闭。 此属性可为 null。 |
| tools | RealtimeTool 数组 | 可用于会话的模型的工具。 |
| tool_choice | RealtimeToolChoice | 会话的工具选择。 允许的值: auto、 none和 required。 否则,可以指定要使用的函数的名称。 |
| 温度 | 数字 | 模型的采样温度。 允许的温度值限制为 [0.6, 1.2]。 默认值为 0.8。 |
| max_response_output_tokens | 整数或“inf” | 每个助理响应的最大输出令牌数,包括工具调用。 指定介于 1 和 4096 之间的整数来限制输出令牌。 否则,请将值设置为“inf”以允许最大令牌数。 例如,若要将输出令牌限制为 1000,请设置 "max_response_output_tokens": 1000。 若要允许最大令牌数,请设置 "max_response_output_tokens": "inf"。默认为 "inf"。 |
| 化身 | RealtimeAvatarConfig | 可选。 虚拟形象配置 |
| output_audio_timestamp_types | RealtimeAudioTimestampType[] | 可选。 输出音频的时间戳类型 |
RealtimeModality
支持的会话形式。
允许的值:
-
text- 文本输入/输出 -
audio- 音频输入/输出 -
animation- 动画输出 -
avatar- 虚拟形象视频输出
RealtimeAudioTimestampType
音频响应内容支持的输出时间戳类型。
允许的值:
-
word- 输出音频中每字的时间戳
工具配置
RealtimeTool
函数调用的工具定义。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "function" |
| 姓名 | 字符串 | 函数名称 |
| 描述 | 字符串 | 函数说明和用法指南 |
| parameters | 对象 | 函数参数作为 JSON 架构对象 |
RealtimeToolChoice
工具选择策略。
这可以是:
-
"auto"- 让模型选择 -
"none"- 不使用工具 -
"required"- 必须使用工具 -
{ "type": "function", "name": "function_name" }- 使用特定函数
RealtimeConversationResponseItem
这是一种联合类型,可以是下列类型之一:
RealtimeConversationUserMessageItem
用户消息项。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 项的唯一 ID。 |
| 类型 | 字符串 | 必须是 "message" |
| 对象 | 字符串 | 必须是 "conversation.item" |
| 角色 | 字符串 | 必须是 "user" |
| 内容 | RealtimeInputTextContentPart[] | 消息的内容。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeConversationAssistantMessageItem
助理消息项。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 项的唯一 ID。 |
| 类型 | 字符串 | 必须是 "message" |
| 对象 | 字符串 | 必须是 "conversation.item" |
| 角色 | 字符串 | 必须是 "assistant" |
| 内容 | RealtimeOutputTextContentPart[] 或 RealtimeOutputAudioContentPart[] | 消息的内容。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeConversationSystemMessageItem
系统消息项。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 项的唯一 ID。 |
| 类型 | 字符串 | 必须是 "message" |
| 对象 | 字符串 | 必须是 "conversation.item" |
| 角色 | 字符串 | 必须是 "system" |
| 内容 | RealtimeInputTextContentPart[] | 消息的内容。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeConversationFunctionCallItem
函数调用请求项。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 项的唯一 ID。 |
| 类型 | 字符串 | 必须是 "function_call" |
| 对象 | 字符串 | 必须是 "conversation.item" |
| 姓名 | 字符串 | 要调用的函数名称。 |
| arguments | 字符串 | 函数调用的参数为 JSON 字符串。 |
| call_id | 字符串 | 函数调用的唯一 ID。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeConversationFunctionCallOutputItem
函数调用响应项。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 项的唯一 ID。 |
| 类型 | 字符串 | 必须是 "function_call_output" |
| 对象 | 字符串 | 必须是 "conversation.item" |
| 姓名 | 字符串 | 调用的函数的名称。 |
| 输出 | 字符串 | 函数调用的输出。 |
| call_id | 字符串 | 函数调用的唯一 ID。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeItemStatus
对话项的状态。
允许的值:
-
in_progress- 当前正在处理 -
completed- 成功完成 -
incomplete- 不完整(中断或失败)
RealtimeContentPart
消息中的内容部件。
RealtimeInputTextContentPart
文本内容部件。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "input_text" |
| 文本消息 | 字符串 | 文本内容 |
RealtimeOutputTextContentPart
文本内容部件。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "text" |
| 文本消息 | 字符串 | 文本内容 |
RealtimeInputAudioContentPart
音频内容部分。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "input_audio" |
| audio | 字符串 | 可选。 Base64 编码的音频数据 |
| 脚本 | 字符串 | 可选。 音频脚本 |
RealtimeOutputAudioContentPart
音频内容部分。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 必须是 "audio" |
| audio | 字符串 | Base64 编码的音频数据 |
| 脚本 | 字符串 | 可选。 音频脚本 |
响应对象
RealtimeResponse
表示模型推理响应的响应对象。
| 领域 | 类型 | Description |
|---|---|---|
| id | 字符串 | 可选。 响应 ID |
| 对象 | 字符串 | 可选。 始终为 "realtime.response" |
| 状态 | RealtimeResponseStatus | 可选。 响应状态 |
| 状态详情 | RealtimeResponseStatusDetails | 可选。 状态详细信息 |
| 输出 | RealtimeConversationResponseItem[] | 可选。 输出项 |
| 使用情况 | RealtimeUsage | 可选。 令牌使用情况统计信息 |
| conversation_id | 字符串 | 可选。 关联的会话 ID |
| 语音 | RealtimeVoice | 可选。 用于响应的语音 |
| modalities | 字符串[] | 可选。 使用的模态 |
| output_audio_format | RealtimeOutputAudioFormat | 可选。 使用的音频格式 |
| 温度 | 数字 | 可选。 使用的温度 |
| max_response_output_tokens | 整数或“inf” | 可选。 使用的最大令牌数 |
RealtimeResponseStatus
响应状态值。
允许的值:
-
in_progress- 正在生成响应 -
completed- 响应成功完成 -
cancelled- 响应已取消 -
incomplete- 响应不完整(中断) -
failed- 响应失败并出现错误
RealtimeUsage
令牌使用情况统计信息。
| 领域 | 类型 | Description |
|---|---|---|
| total_tokens | 整数 | 已用令牌总数 |
| input_tokens | 整数 | 使用的输入令牌数 |
| output_tokens | 整数 | 生成的输出令牌 |
| input_token_details | TokenDetails | 输入令牌细分 |
| output_token_details | TokenDetails | 输出令牌细分 |
TokenDetails
详细的令牌使用情况细分。
| 领域 | 类型 | Description |
|---|---|---|
| cached_tokens | 整数 | 可选。 使用的缓存令牌 |
| text_tokens | 整数 | 可选。 使用的文本令牌 |
| audio_tokens | 整数 | 可选。 使用的音频令牌 |
错误处理
RealtimeErrorDetails
错误信息对象。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 错误类型(例如, "invalid_request_error", "server_error") |
| 代码 | 字符串 | 可选。 特定错误代码 |
| 消息 | 字符串 | 人工可读错误说明 |
| param | 字符串 | 可选。 与错误相关的参数 |
| event_id | 字符串 | 可选。 导致错误的客户端事件的 ID |
RealtimeConversationRequestItem
使用 RealtimeConversationRequestItem 对象通过 conversation.item.create 事件在会话中创建新项。
这是一种联合类型,可以是下列类型之一:
RealtimeSystemMessageItem
系统消息项。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: message |
| 角色 | 字符串 | 消息的角色。 允许的值: system |
| 内容 | RealtimeInputTextContentPart 的数组 | 消息的内容。 |
| id | 字符串 | 项的唯一 ID。 客户端可以指定 ID 来帮助管理服务器端上下文。 如果客户端未提供 ID,服务器将生成一个 ID。 |
RealtimeUserMessageItem
用户消息项。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: message |
| 角色 | 字符串 | 消息的角色。 允许的值: user |
| 内容 | RealtimeInputTextContentPart 或 RealtimeInputAudioContentPart 的数组 | 消息的内容。 |
| id | 字符串 | 项的唯一 ID。 客户端可以指定 ID 来帮助管理服务器端上下文。 如果客户端未提供 ID,服务器将生成一个 ID。 |
RealtimeAssistantMessageItem
助理消息项。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: message |
| 角色 | 字符串 | 消息的角色。 允许的值: assistant |
| 内容 | RealtimeOutputTextContentPart 的数组 | 消息的内容。 |
RealtimeFunctionCallItem
函数调用项。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: function_call |
| 姓名 | 字符串 | 要调用的函数名称。 |
| arguments | 字符串 | 函数调用的参数为 JSON 字符串。 |
| call_id | 字符串 | 函数调用项的 ID。 |
| id | 字符串 | 项的唯一 ID。 客户端可以指定 ID 来帮助管理服务器端上下文。 如果客户端未提供 ID,服务器将生成一个 ID。 |
RealtimeFunctionCallOutputItem
函数调用输出项。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: function_call_output |
| call_id | 字符串 | 函数调用项的 ID。 |
| 输出 | 字符串 | 函数调用的输出,这是具有函数结果的自由格式字符串,也可能为空。 |
| id | 字符串 | 项的唯一 ID。 如果客户端未提供 ID,服务器将生成一个 ID。 |
RealtimeFunctionTool
实时终结点使用的函数工具的定义。
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 工具的类型。 允许的值: function |
| 姓名 | 字符串 | 函数的名称。 |
| 描述 | 字符串 | 函数的说明,包括使用指南。 例如,“使用此函数获取当前时间。 |
| parameters | 对象 | 函数的参数,格式为 JSON 对象。 |
RealtimeItemStatus
允许的值:
in_progresscompletedincomplete
RealtimeResponseAudioContentPart
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 内容部件的类型。 允许的值: audio |
| 脚本 | 字符串 | 音频的脚本。 此属性可为 null。 |
RealtimeResponseFunctionCallItem
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: function_call |
| 姓名 | 字符串 | 函数调用项的名称。 |
| call_id | 字符串 | 函数调用项的 ID。 |
| arguments | 字符串 | 函数调用项的参数。 |
| 状态 | RealtimeItemStatus | 项目的状态。 |
RealtimeResponseFunctionCallOutputItem
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | 字符串 | 项的类型。 允许的值: function_call_output |
| call_id | 字符串 | 函数调用项的 ID。 |
| 输出 | 字符串 | 函数调用项的输出。 |
RealtimeResponseOptions
| 领域 | 类型 | Description |
|---|---|---|
| modalities | 数组 | 会话支持的形式。 允许的值: text、 audio例如, "modalities": ["text", "audio"] 启用文本和音频形式的默认设置。 若要仅启用文本,请设置 "modalities": ["text"]。 不能仅启用音频。 |
| 指示 | 字符串 | 指导模型响应的说明(系统消息)。 |
| 语音 | RealtimeVoice | 用于会话的模型响应的语音。 在会话中为模型的音频响应使用语音后,无法更改语音。 |
| tools | RealtimeTool 数组 | 可用于会话的模型的工具。 |
| tool_choice | RealtimeToolChoice | 会话的工具选择。 |
| 温度 | 数字 | 模型的采样温度。 允许的温度值限制为 [0.6, 1.2]。 默认值为 0.8。 |
| max_response_output_tokens | 整数或“inf” | 每个助理响应的最大输出令牌数,包括工具调用。 指定介于 1 和 4096 之间的整数来限制输出令牌。 否则,请将值设置为“inf”以允许最大令牌数。 例如,若要将输出令牌限制为 1000,请设置 "max_response_output_tokens": 1000。 若要允许最大令牌数,请设置 "max_response_output_tokens": "inf"。默认为 "inf"。 |
| 对话 | 字符串 | 控制将响应添加到哪个对话。 支持的值为 auto 和 none。auto值(或不设置此属性)可确保将响应的内容添加到会话的默认会话中。将此属性设置为 none 创建带外响应,其中不会将项目添加到默认对话。 默认为 "auto" |
| 元数据 | 映射 | 最多可以附加到对象的 16 个键值对集。 这对以结构化格式存储对象相关的附加信息很有用。 键的最大长度为 64 个字符,值的最大长度为 512 个字符。 例如: metadata: { topic: "classification" } |
RealtimeResponseSession
该 RealtimeResponseSession 对象表示实时 API 中的会话。 它用于某些服务器事件,例如:
| 领域 | 类型 | Description |
|---|---|---|
| 对象 | 字符串 | 会话对象。 允许的值: realtime.session |
| id | 字符串 | 会话的唯一 ID。 |
| 模型 | 字符串 | 用于会话的模型。 |
| modalities | 数组 | 会话支持的形式。 允许的值: text、 audio例如, "modalities": ["text", "audio"] 启用文本和音频形式的默认设置。 若要仅启用文本,请设置 "modalities": ["text"]。 不能仅启用音频。 |
| 指示 | 字符串 | 指导模型的文本和音频响应的说明(系统消息)。 下面是一些示例说明,可帮助指导文本和音频响应的内容和格式: "instructions": "be succinct""instructions": "act friendly""instructions": "here are examples of good responses"下面是一些帮助指导音频行为的示例说明: "instructions": "talk quickly""instructions": "inject emotion into your voice""instructions": "laugh frequently"虽然模型可能并不总是遵循这些说明,但它们提供有关所需行为的指导。 |
| 语音 | RealtimeVoice | 用于会话的模型响应的语音。 在会话中为模型的音频响应使用语音后,无法更改语音。 |
| input_audio_sampling_rate | 整数 | 输入音频的采样率。 |
| input_audio_format | RealtimeAudioFormat | 输入音频的格式。 |
| output_audio_format | RealtimeAudioFormat | 输出音频的格式。 |
| input_audio_transcription | RealtimeAudioInputTranscriptionSettings | 音频输入听录的设置。 此属性可为 null。 |
| turn_detection | RealtimeTurnDetection | 会话的轮次检测设置。 此属性可为 null。 |
| tools | RealtimeTool 数组 | 可用于会话的模型的工具。 |
| tool_choice | RealtimeToolChoice | 会话的工具选择。 |
| 温度 | 数字 | 模型的采样温度。 允许的温度值限制为 [0.6, 1.2]。 默认值为 0.8。 |
| max_response_output_tokens | 整数或“inf” | 每个助理响应的最大输出令牌数,包括工具调用。 指定介于 1 和 4096 之间的整数来限制输出令牌。 否则,请将值设置为“inf”以允许最大令牌数。 例如,若要将输出令牌限制为 1000,请设置 "max_response_output_tokens": 1000。 若要允许最大令牌数,请设置 "max_response_output_tokens": "inf"。 |
RealtimeResponseStatusDetails
| 领域 | 类型 | Description |
|---|---|---|
| 类型 | RealtimeResponseStatus | 响应的状态。 |
RealtimeRateLimitsItem
| 领域 | 类型 | Description |
|---|---|---|
| 姓名 | 字符串 | 此项包含相关信息的速率限制属性名称。 |
| limit | 整数 | 此速率限制属性的最大配置限制。 |
| remaining | 整数 | 针对此速率限制属性配置的限制可用的剩余配额。 |
| reset_seconds | 数字 | 剩余时间(以秒为单位)直到重置此速率限制属性。 |
相关资源
- 试用 语音在线快速入门
- 试用语音实时代理快速入门
- 详细了解 如何使用语音实时 API