开源推荐
morning
GitHub 热门项目:openai-realtime-console
2026-05-26
1 阅读
GitHub Trending
GitHub 项目:openai-realtime-console
仓库地址:https://github.com/openai/openai-realtime-console
星级:3583 | 作者:openai
项目描述:使用 Realtime API 检查、构建和调试 React 应用程序
===================================================
自述文件内容:
# OpenAI 实时控制台
这是一个示例应用程序,展示如何将 [OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime) 与 [WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc) 结合使用。
## 安装与使用
在开始之前,您需要一个 OpenAI API 密钥 - [在此处的仪表板中创建一个](https://platform.openai.com/settings/api-keys)。从示例文件创建一个 `.env` 文件并在其中设置您的 API 密钥:
````bash
cp .env.example .env
````
在本地运行此应用程序需要安装 [Node.js](https://nodejs.org/)。使用以下命令安装应用程序的依赖项:
````bash
npm 安装
````
使用以下命令启动应用程序服务器:
````bash
npm 运行开发
````
这应该在 [http://localhost:3000](http://localhost:3000) 上启动控制台应用程序。
此应用程序是一个最小模板,它使用 [express](https://expressjs.com/) 为 [`/client`](./client) 文件夹中包含的 React 前端提供服务。服务器配置为使用 [vite](https://vitejs.dev/) 构建 React 前端。
此应用程序展示了如何通过 WebRTC 数据通道发送和接收实时 API 事件以及配置客户端函数调用。您还可以使用 UI 中的日志记录面板查看客户端和服务器事件的 JSON 负载。
有关更全面的示例,请参阅使用 Next.js 构建的 [OpenAI Realtime Agents](https://github.com/openai/openai-realtime-agents) 演示,该演示使用受 [OpenAI Swarm](https://github.com/openai/swarm) 启发的代理架构。
## 以前的 WebSockets 版本
该应用程序的先前版本在客户端上使用 WebSockets(不推荐在浏览器中使用)[可以在此处找到](https://github.com/openai/openai-realtime-console/tree/websockets)。
## 许可证
麻省理工学院