AI SDK 7.0.179 让浏览器用短期令牌直连 Gateway Live WebSocket,但工具仍由客户端委派
Vercel 于 11 月 20 日发布 AI SDK 7.0.179。Gateway 现在把 openai/gpt-live-1 与 gpt-live-1.1 路由到连续 Live 会话,而不是会返回 invalid_model 的 turn-based realtime 路由;应用服务器可生成绑定 Live 路由的短期客户端密钥,浏览器随后直接建立 PCM16 WebSocket 会话,不再必须经过应用自建音频 relay。
为什么值得关注
实时语音生成式 UI 的延迟、成本和故障面高度依赖传输路径。短期令牌把长效 Gateway 密钥留在服务端,同时移除应用音频中继;但浏览器因此直接持有一条连续会话连接,界面必须明确会话状态、最终用量、麦克风权限、令牌失效和客户端委派动作的边界。
技术细节
gateway.experimental_realtime() 会对已知 Live 模型返回连续模型,使用 session-start、双向 PCM16 音频、context-append 和带最终 usage 的 session-close;其他模型可用 api:'live' 显式选择,api:'realtime' 则强制旧路由。getToken() 为 Live 模型生成带 routeKind:'live' 的短期密钥。experimental_useRealtime 可在模型声明 client-secret-websocket 且实现 WebSocket 配置时使用 api.token 直连。实现会在浏览器用户手势内预热播放,再获取设置并开通连接;不被 Live 路由接受的工具、turn detection、provider/context 选项和 client events 会提前抛出明确错误。
适合哪些读者
构建实时语音生成式 UI、浏览器音频会话、Gateway 短期凭证、客户端工具委派或会话用量展示的前端与代理平台团队。
原始来源
- Vercel AI SDK 7.0.179 release and implementation commit ↗github.com
- Gateway Live WebSocket implementation, tests, and limits ↗github.com
修订与更正记录 (1)
— A new immutable release adds a distinct continuous-session transport and credential boundary for realtime generative UI; the official implementation documents supported routes, rejected options, measured bundle cost, end-to-end checks, and untested paths.