实时 WebSocket 连接
GET /v1/realtime
建立 WebSocket 连接用于实时对话。
注意: 这是一个 WebSocket 端点,需要使用 WebSocket 协议连接。
连接 URL 示例: wss://api.example.com/v1/realtime?model=gpt-4o-realtime
基本信息
| 项目 | 内容 |
|---|---|
| Base URL | https://www.yunzhuhub.cn |
| 标签 | Realtime |
| Operation ID | createRealtimeSession |
认证
- BearerAuth:使用 Bearer Token 认证。 格式:
Authorization: Bearer sk-xxxxxx
密钥安全
请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。
参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
model | query | string | 否 | 要使用的模型 |
请求体
此接口没有请求体。
请求示例
以下示例只用于复制到本地终端,不会从文档站发送请求。
bash
curl --request GET 'https://www.yunzhuhub.cn/v1/realtime' \
--header 'Authorization: Bearer <YOUR_API_KEY>'响应
101 WebSocket 协议切换
400 请求错误
json
{
"title": "ErrorResponse",
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "错误信息"
},
"type": {
"type": "string",
"description": "错误类型"
},
"param": {
"type": "string",
"description": "相关参数",
"nullable": true
},
"code": {
"type": "string",
"description": "错误代码",
"nullable": true
}
}
}
}
}