{"id":17671,"date":"2025-01-08T14:46:40","date_gmt":"2025-01-08T06:46:40","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=17671"},"modified":"2025-01-08T14:46:40","modified_gmt":"2025-01-08T06:46:40","slug":"openai-realtime-api-nextjsainextjs","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/ja\/openai-realtime-api-nextjsainextjs\/","title":{"rendered":"OpenAI Realtime API Next.js\uff1a\u6784\u5efa\u5b9e\u65f6\u8bed\u97f3\u5bf9\u8bddAI\u5e94\u7528\u7684Next.js\u6a21\u677f"},"content":{"rendered":"<p>OpenAI Realtime API Next.js \u662f\u4e00\u4e2a\u57fa\u4e8eNext.js\u6846\u67b6\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u5b9e\u65f6\u8bed\u97f3AI\u5e94\u7528\u3002\u8be5\u9879\u76ee\u96c6\u6210\u4e86OpenAI\u7684\u5b9e\u65f6API\u548cWebRTC\u6280\u672f\uff0c\u63d0\u4f9b\u4e86\u73b0\u4ee3\u5316\u7684UI\u7ec4\u4ef6\u548c\u5de5\u5177\u8c03\u7528\u529f\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e2a\u6a21\u677f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u652f\u6301\u5b9e\u65f6\u97f3\u9891\u5bf9\u8bdd\u7684\u8bed\u97f3AI\u5e94\u7528\uff0c\u5e76\u5b9e\u73b0\u591a\u8bed\u8a00\u672c\u5730\u5316\u3002\u9879\u76ee\u8fd8\u5305\u542b\u4e25\u683c\u7684TypeScript\u7c7b\u578b\u5b89\u5168\u548ceslint\u89c4\u5219\uff0c\u786e\u4fdd\u4ee3\u7801\u8d28\u91cf\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<div id=\"attachment_17672\" style=\"width: 1025px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-17672\" class=\"wp-image-17672 size-full\" title=\"OpenAI Realtime API Next.js\uff1a\u6784\u5efa\u5b9e\u65f6\u8bed\u97f3\u5bf9\u8bddAI\u5e94\u7528\u7684Next.js\u6a21\u677f-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/01\/1ca65620ddf8dfa.png\" alt=\"OpenAI Realtime API Next.js\uff1a\u6784\u5efa\u5b9e\u65f6\u8bed\u97f3\u5bf9\u8bddAI\u5e94\u7528\u7684Next.js\u6a21\u677f-1\" width=\"1015\" height=\"827\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/01\/1ca65620ddf8dfa.png 1015w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/01\/1ca65620ddf8dfa-300x244.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/01\/1ca65620ddf8dfa-768x626.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/01\/1ca65620ddf8dfa-15x12.png 15w\" sizes=\"auto, (max-width: 1015px) 100vw, 1015px\" \/><p id=\"caption-attachment-17672\" class=\"wp-caption-text\">\u5728\u7ebf\u6f14\u793a\uff1ahttps:\/\/openai-rt-shadcn.vercel.app\/<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>Next.js\u6846\u67b6<\/strong>\uff1a\u4f7f\u7528Next.js\u8fdb\u884c\u670d\u52a1\u5668\u7aef\u6e32\u67d3\u548cAPI\u8def\u7531\u3002<\/li>\n<li><strong>\u73b0\u4ee3\u5316UI<\/strong>\uff1a\u91c7\u7528Tailwind CSS\u548cFramer Motion\u8fdb\u884c\u52a8\u753b\u8bbe\u8ba1\uff0c\u4f7f\u7528shadcn\/ui\u7ec4\u4ef6\u3002<\/li>\n<li><strong>WebRTC\u652f\u6301<\/strong>\uff1a\u63d0\u4f9b\u4e00\u4e2a\u62bd\u8c61WebRTC\u5904\u7406\u7684hook\uff0c\u7b80\u5316\u5b9e\u65f6\u97f3\u9891\u5bf9\u8bdd\u7684\u5b9e\u73b0\u3002<\/li>\n<li><strong>\u5de5\u5177\u8c03\u7528<\/strong>\uff1a\u5305\u542b\u4e94\u4e2a\u793a\u4f8b\u51fd\u6570\uff0c\u5c55\u793a\u5ba2\u6237\u7aef\u5de5\u5177\u4e0e\u5b9e\u65f6API\u7684\u7ed3\u5408\u4f7f\u7528\u3002<\/li>\n<li><strong>\u591a\u8bed\u8a00\u672c\u5730\u5316<\/strong>\uff1a\u652f\u6301\u9009\u62e9\u5e94\u7528\u5b57\u7b26\u4e32\u548c\u8bed\u97f3\u4ee3\u7406\u7684\u8bed\u8a00\uff08\u82f1\u8bed\u3001\u897f\u73ed\u7259\u8bed\u3001\u6cd5\u8bed\u3001\u4e2d\u6587\uff09\u3002<\/li>\n<li><strong>\u7c7b\u578b\u5b89\u5168<\/strong>\uff1a\u4f7f\u7528TypeScript\u5e76\u9075\u5faa\u4e25\u683c\u7684eslint\u89c4\u5219\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u514b\u9686\u4ed3\u5e93<\/strong><\/li>\n<\/ol>\n<pre><code>   git clone https:\/\/github.com\/cameronking4\/openai-realtime-api-nextjs.git\r\ncd openai-realtime-api-nextjs\r\n<\/code><\/pre>\n<ol start=\"2\">\n<li><strong>\u73af\u5883\u8bbe\u7f6e<\/strong> \u5728\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a<code>.env<\/code>\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4f60\u7684OpenAI API\u5bc6\u94a5\uff1a<\/li>\n<\/ol>\n<pre><code>   OPENAI_API_KEY=your-openai-api-key\r\n<\/code><\/pre>\n<ol start=\"3\">\n<li><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong> \u5982\u679c\u4f7f\u7528Node.js\uff1a<\/li>\n<\/ol>\n<pre><code>   npm install\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528Deno\uff1a<\/p>\n<pre><code>   deno install\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li><strong>\u8fd0\u884c\u5e94\u7528<\/strong> \u5982\u679c\u4f7f\u7528Node.js\uff1a<\/li>\n<\/ol>\n<pre><code>   npm run dev\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528Deno\uff1a<\/p>\n<pre><code>   deno task start\r\n<\/code><\/pre>\n<p>\u5e94\u7528\u5c06\u8fd0\u884c\u5728<code>http:\/\/localhost:3000<\/code>\u3002<\/p>\n<h3>\u4f7f\u7528\u8bf4\u660e<\/h3>\n<ol>\n<li><strong>\u6253\u5f00\u5e94\u7528<\/strong> \u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00<code>http:\/\/localhost:3000<\/code>\u3002<\/li>\n<li><strong>\u9009\u62e9\u8bed\u97f3<\/strong> \u9009\u62e9\u4e00\u4e2a\u8bed\u97f3\u5e76\u5f00\u59cb\u97f3\u9891\u4f1a\u8bdd\u3002<\/li>\n<li><strong>\u5de5\u5177\u8c03\u7528<\/strong> \u9879\u76ee\u63d0\u4f9b\u4e86\u4e94\u4e2a\u793a\u4f8b\u51fd\u6570\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5728\u5ba2\u6237\u7aef\u8c03\u7528\u5de5\u5177\uff1a\n<ul>\n<li><code>getCurrentTime<\/code>\uff1a\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3002<\/li>\n<li><code>partyMode<\/code>\uff1a\u5207\u6362\u5230\u6d3e\u5bf9\u6a21\u5f0f\u3002<\/li>\n<li><code>changeBackground<\/code>\uff1a\u66f4\u6539\u80cc\u666f\u3002<\/li>\n<li><code>launchWebsite<\/code>\uff1a\u542f\u52a8\u7f51\u7ad9\u3002<\/li>\n<li><code>copyToClipboard<\/code>\uff1a\u590d\u5236\u5230\u526a\u8d34\u677f\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u591a\u8bed\u8a00\u652f\u6301<\/strong> \u901a\u8fc7\u9009\u62e9\u4e0d\u540c\u7684\u8bed\u8a00\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5e94\u7528\u5b57\u7b26\u4e32\u548c\u8bed\u97f3\u4ee3\u7406\u7684\u591a\u8bed\u8a00\u672c\u5730\u5316\u3002<\/li>\n<\/ol>\n<h3>\u90e8\u7f72\u5230Vercel<\/h3>\n<ol>\n<li><strong>\u4e00\u952e\u90e8\u7f72<\/strong> \u901a\u8fc7Vercel\u5e73\u53f0\uff0c\u53ef\u4ee5\u4e00\u952e\u90e8\u7f72\u8be5\u5e94\u7528\u3002<\/li>\n<li><strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong> \u5728Vercel\u7684\u9879\u76ee\u8bbe\u7f6e\u4e2d\uff0c\u6dfb\u52a0\u4f60\u7684OpenAI API\u5bc6\u94a5\u3002<\/li>\n<\/ol>\n<h3>\u8bb8\u53ef\u8bc1<\/h3>\n<p>\u8be5\u9879\u76ee\u57fa\u4e8eMIT\u8bb8\u53ef\u8bc1\u5f00\u6e90\uff0c\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u9605LICENSE\u6587\u4ef6\u3002<\/p>\n<h3>\u81f4\u8c22<\/h3>\n<p>\u611f\u8c22OpenAI\u63d0\u4f9b\u7684API\u548c\u6a21\u578b\uff0cNext.js\u6846\u67b6\uff0cTailwind CSS\u7684\u6837\u5f0f\u8bbe\u8ba1\uff0c\u4ee5\u53caSimon Willison\u7684\u535a\u5ba2\u63d0\u4f9b\u7684\u7075\u611f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenAI Realtime API Next.js \u662f\u4e00\u4e2a\u57fa\u4e8eNext.js\u6846\u67b6\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u5b9e\u65f6\u8bed\u97f3AI\u5e94\u7528\u3002\u8be5\u9879\u76ee\u96c6\u6210\u4e86OpenAI\u7684\u5b9e\u65f6API\u548cWebRTC\u6280\u672f\uff0c\u63d0\u4f9b\u4e86\u73b0\u4ee3\u5316\u7684UI\u7ec4\u4ef6\u548c\u5de5\u5177\u8c03\u7528\u529f\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u8fd9&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61586,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,374],"class_list":["post-17671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-duandaoduanyuyinzhubei"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/17671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/comments?post=17671"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/17671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media\/61586"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media?parent=17671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/categories?post=17671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/tags?post=17671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}