会话更新

发送此事件以更新会话的默认配置。客户可以 随时发送此事件以更新会话配置,以及任何 字段可能随时更新,但 “voice” 除外。服务器将响应 替换为session.updated事件,该事件显示完整的有效配置。 只有存在的字段才会更新,因此清除 字段(如 “instructions” )用于传递空字符串。source

用于标识此事件的可选客户端生成的 ID。source

事件类型必须为session.update.source

实时会话对象配置。source

对象 session.update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
    "event_id": "event_123",
    "type": "session.update",
    "session": {
        "modalities": ["text", "audio"],
        "instructions": "You are a helpful assistant.",
        "voice": "sage",
        "input_audio_format": "pcm16",
        "output_audio_format": "pcm16",
        "input_audio_transcription": {
            "model": "whisper-1"
        },
        "turn_detection": {
            "type": "server_vad",
            "threshold": 0.5,
            "prefix_padding_ms": 300,
            "silence_duration_ms": 500
        },
        "tools": [
            {
                "type": "function",
                "name": "get_weather",
                "description": "Get the current weather...",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "location": { "type": "string" }
                    },
                    "required": ["location"]
                }
            }
        ],
        "tool_choice": "auto",
        "temperature": 0.8,
        "max_response_output_tokens": "inf"
    }
}