curl --location -g --request POST 'ws://{{DOMAIN}}/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01' \
--header 'OpenAI-Beta: realtime=v1' \
--header 'Authorization: Bearer {{api-key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"event_id": "event_123",
"type": "session.update",
"session": {
"modalities": [
"text",
"audio"
],
"instructions": "Your knowledge cutoff is 2023-10. You are a helpful assistant.",
"voice": "alloy",
"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": 200
},
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "获取指定城市的当前天气。",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称"
},
"unit": {
"type": "string",
"enum": [
"c",
"f"
],
"default": "c"
}
},
"required": [
"city"
]
}
}
],
"tool_choice": "auto",
"temperature": 0.8,
"max_output_tokens": 1024
}
}'