Skip to main content
GET
/
v1
/
realtime
Realtime 接口
curl --request GET \
  --url https://api.example.com/v1/realtime

Documentation Index

Fetch the complete documentation index at: https://mercury-eab3b728.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Realtime 接口

Realtime 路由使用 WebSocket 连接,适合低延迟语音对话、实时事件流和双向交互场景。该路由会经过 TokenAuth、模型限流和渠道分发。

连接地址

wss://www.geeknow.top/v1/realtime

认证

Authorization: Bearer YOUR_API_KEY
若客户端不方便设置 WebSocket 请求头,可按自身网关配置使用支持的临时 token 或代理层注入认证头。

连接示例

const ws = new WebSocket("wss://www.geeknow.top/v1/realtime", [], {
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
  },
});

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "session.update",
    session: {
      modalities: ["text"],
      instructions: "你是一个实时语音助手。"
    }
  }));
};

ws.onmessage = (event) => {
  console.log(JSON.parse(event.data));
};

常见事件

event说明
session.update更新会话配置
conversation.item.create创建对话项
response.create触发模型响应
response.text.delta文本增量
response.done响应完成

相关接口