{"id":1255,"date":"2023-02-25T08:38:58","date_gmt":"2023-02-25T00:38:58","guid":{"rendered":"https:\/\/www.aqwu.net\/wp\/?p=1255"},"modified":"2023-02-25T16:23:14","modified_gmt":"2023-02-25T08:23:14","slug":"openai-api%ef%bc%9a2-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/www.aqwu.net\/wp\/?p=1255","title":{"rendered":"OpenAI API \u5f00\u59cb\u4f7f\u7528\uff1a2.\u5feb\u901f\u5165\u95e8"},"content":{"rendered":"\n<p>OpenAI\u5df2\u7ecf\u8bad\u7ec3\u4e86\u975e\u5e38\u64c5\u957f\u7406\u89e3\u548c\u751f\u6210\u6587\u672c\u7684\u5c16\u7aef\u8bed\u8a00\u6a21\u578b\u3002\u6211\u4eec\u7684API\u63d0\u4f9b\u5bf9\u8fd9\u4e9b\u6a21\u578b\u7684\u8bbf\u95ee\uff0c\u53ef\u7528\u4e8e\u89e3\u51b3\u51e0\u4e4e\u4efb\u4f55\u6d89\u53ca\u5904\u7406\u8bed\u8a00\u7684\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/platform.openai.com\/docs\/quickstart\">\u5feb\u901f\u5165\u95e8\u6559\u7a0b &#8211; OpenAI API<\/a><\/p>\n\n\n\n<p>\u5728\u672c\u5feb\u901f\u5165\u95e8\u6559\u7a0b\u4e2d\uff0c\u4f60\u5c06\u751f\u6210\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u5c06 API \u7528\u4e8e\u4efb\u4f55\u4efb\u52a1\u7684\u57fa\u7840\u5173\u952e\u6982\u5ff5\u548c\u6280\u672f\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5185\u5bb9\u751f\u6210\uff08Content generation\uff09<\/li>\n\n\n\n<li>\u7efc\u8ff0\uff08Summarization\uff09<\/li>\n\n\n\n<li>\u5f52\u7c7b\uff08Classification\uff09\u3001\u5206\u7c7b\uff08categorization\uff09\u548c\u6587\u672c\u60c5\u611f\u5206\u6790\u5206\u6790\uff08sentiment analysis\uff09<\/li>\n\n\n\n<li>\u6570\u636e\u63d0\u53d6\uff08Data extraction\uff09<\/li>\n\n\n\n<li>\u7ffb\u8bd1\uff08Translation\uff09<\/li>\n\n\n\n<li>\u66f4\u591a\uff01<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/introduction\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/introduction\">\u4ecb\u7ecd<\/a><\/h2>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/completions\">\u5b8c\u6210<\/a>\u7aef\u70b9\u662f\u6211\u4eec API \u7684\u6838\u5fc3\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u7075\u6d3b\u548c\u5f3a\u5927\u7684\u7b80\u5355\u63a5\u53e3\u3002\u60a8\u8f93\u5165\u4e00\u4e9b\u6587\u672c\u4f5c\u4e3a<strong>\u63d0\u793a<\/strong>\uff0cAPI \u5c06\u8fd4\u56de\u4e00\u4e2a\u6587\u672c<strong>\u8865\u5168<\/strong>\uff0c\u5c1d\u8bd5\u5339\u914d\u60a8\u4e3a\u5176\u63d0\u4f9b\u7684\u4efb\u4f55\u6307\u4ee4\u6216\u4e0a\u4e0b\u6587\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Prompt<\/td><td>Write a tagline for an ice cream shop.(\u4e3a\u51b0\u6dc7\u6dcb\u5e97\u5199\u4e00\u4e2a\u6807\u8bed.)<\/td><\/tr><tr><td>Completion<\/td><td>We serve up smiles with every scoop!(\u6211\u4eec\u7528\u6bcf\u4e00\u52fa\u63d0\u4f9b\u5fae\u7b11\uff01)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u628a\u5b83\u770b\u4f5c\u662f\u4e00\u4e2a\u975e\u5e38\u9ad8\u7ea7\u7684\u81ea\u52a8\u5b8c\u6210\u2014\u2014\u6a21\u578b\u5904\u7406\u4f60\u7684\u6587\u672c\u63d0\u793a\uff0c\u5e76\u5c1d\u8bd5\u9884\u6d4b\u63a5\u4e0b\u6765\u6700\u6709\u53ef\u80fd\u53d1\u751f\u7684\u4e8b\u60c5\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/start-with-an-instruction\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/start-with-an-instruction\">1\u4ece\u6307\u4ee4\u5f00\u59cb<\/a><\/h2>\n\n\n\n<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u60a8\u8981\u521b\u5efa\u4e00\u4e2a\u5ba0\u7269\u540d\u79f0\u751f\u6210\u5668\u3002\u4ece\u5934\u5f00\u59cb\u60f3\u51fa\u540d\u5b57\u5f88\u96be\uff01<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4e00\u4e2a\u63d0\u793a\uff0c\u660e\u786e\u60a8\u60f3\u8981\u4ec0\u4e48\u3002\u8ba9\u6211\u4eec\u4ece\u4e00\u4e2a\u6307\u4ee4\u5f00\u59cb\u3002<strong>\u63d0\u4ea4\u6b64\u63d0\u793a<\/strong> \u4ee5\u751f\u6210\u60a8\u7684\u7b2c\u4e00\u4e2a\u5b8c\u6210\u3002\u200d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"131\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-42.png\" alt=\"\" class=\"wp-image-1259\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-42.png 780w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-42-300x50.png 300w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-42-768x129.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/figure>\n\n\n\n<p>\u4e0d\u9519\uff01\u73b0\u5728\uff0c\u5c1d\u8bd5\u4f7f\u60a8\u7684\u8bf4\u660e\u66f4\u5177\u4f53\u3002\u200d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"771\" height=\"134\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-43.png\" alt=\"\" class=\"wp-image-1260\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-43.png 771w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-43-300x52.png 300w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-43-768x133.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/figure>\n\n\n\n<p>\u5982\u60a8\u6240\u89c1\uff0c\u5728\u63d0\u793a\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7b80\u5355\u7684\u5f62\u5bb9\u8bcd\u4f1a\u66f4\u6539\u7ed3\u679c\u5b8c\u6210\u3002\u8bbe\u8ba1\u63d0\u793a\u672c\u8d28\u4e0a\u662f\u201c\u7f16\u7a0b\u201d\u6a21\u578b\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/add-some-examples\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/add-some-examples\">2\u6dfb\u52a0\u4e00\u4e9b\u793a\u4f8b<\/a><\/h2>\n\n\n\n<p>\u5236\u5b9a\u597d\u7684\u8bf4\u660e\u5bf9\u4e8e\u83b7\u5f97\u826f\u597d\u7684\u7ed3\u679c\u5f88\u91cd\u8981\uff0c\u4f46\u6709\u65f6\u5b83\u4eec\u8fd8\u4e0d\u591f\u3002\u8ba9\u6211\u4eec\u5c1d\u8bd5\u4f7f\u60a8\u7684\u6307\u4ee4\u66f4\u52a0\u590d\u6742\u3002\u200d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"188\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-44.png\" alt=\"\" class=\"wp-image-1261\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-44.png 785w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-44-300x72.png 300w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-44-768x184.png 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e2a\u5b8c\u6210\u5e76\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002\u8fd9\u4e9b\u540d\u5b57\u975e\u5e38\u901a\u7528\uff0c\u4f3c\u4e4e\u6a21\u578b\u6ca1\u6709\u63a5\u53d7\u6211\u4eec\u6307\u4ee4\u4e2d\u7684\u9a6c\u90e8\u5206\u3002\u8ba9\u6211\u4eec\u770b\u770b\u6211\u4eec\u662f\u5426\u53ef\u4ee5\u8ba9\u5b83\u63d0\u51fa\u4e00\u4e9b\u66f4\u76f8\u5173\u7684\u5efa\u8bae\u3002<\/p>\n\n\n\n<p>\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\uff0c\u663e\u793a<em>\u548c<\/em>\u544a\u8bc9\u6a21\u578b\u4f60\u60f3\u8981\u4ec0\u4e48\u5f88\u6709\u5e2e\u52a9\u3002\u5728\u63d0\u793a\u4e2d\u6dfb\u52a0\u793a\u4f8b\u6709\u52a9\u4e8e\u4f20\u8fbe\u6a21\u5f0f\u6216\u7ec6\u5fae\u5dee\u522b\u3002\u5c1d\u8bd5\u63d0\u4ea4\u6b64\u63d0\u793a\uff0c\u5176\u4e2d\u5305\u62ec\u51e0\u4e2a\u793a\u4f8b\u3002\u200d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"779\" height=\"296\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-45.png\" alt=\"\" class=\"wp-image-1262\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-45.png 779w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-45-300x114.png 300w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-45-768x292.png 768w\" sizes=\"auto, (max-width: 779px) 100vw, 779px\" \/><\/figure>\n\n\n\n<p>\u597d\uff01\u4e3a\u7ed9\u5b9a\u8f93\u5165\u6dfb\u52a0\u6211\u4eec\u671f\u671b\u7684\u8f93\u51fa\u793a\u4f8b\u6709\u52a9\u4e8e\u6a21\u578b\u63d0\u4f9b\u6211\u4eec\u6b63\u5728\u5bfb\u627e\u7684\u540d\u79f0\u7c7b\u578b\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/adjust-your-settings\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/adjust-your-settings\">3\u8c03\u6574\u60a8\u7684\u8bbe\u7f6e<\/a><\/h2>\n\n\n\n<p>\u63d0\u793a\u8bbe\u8ba1\u5e76\u4e0d\u662f\u60a8\u53ef\u4ee5\u4f7f\u7528\u7684\u552f\u4e00\u5de5\u5177\u3002\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u8bbe\u7f6e\u6765\u63a7\u5236\u5b8c\u6210\u3002\u6700\u91cd\u8981\u7684\u8bbe\u7f6e\u4e4b\u4e00\u79f0\u4e3a<strong>\u6e29\u5ea6<\/strong>\u3002<\/p>\n\n\n\n<p>\u60a8\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\uff0c\u5982\u679c\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\u591a\u6b21\u63d0\u4ea4\u76f8\u540c\u7684\u63d0\u793a\uff0c\u5219\u6a21\u578b\u5c06\u59cb\u7ec8\u8fd4\u56de\u76f8\u540c\u6216\u975e\u5e38\u76f8\u4f3c\u7684\u5b8c\u6210\u3002\u8fd9\u662f\u56e0\u4e3a\u60a8\u7684\u6e29\u5ea6\u8bbe\u7f6e\u4e3a&nbsp;<strong>0<\/strong>\u3002<\/p>\n\n\n\n<p>\u5c1d\u8bd5\u5728\u6e29\u5ea6\u8bbe\u7f6e\u4e3a&nbsp;<strong>1<\/strong>&nbsp;\u7684\u60c5\u51b5\u4e0b\u91cd\u65b0\u63d0\u4ea4\u76f8\u540c\u7684\u63d0\u793a\u51e0\u6b21\u3002\u200d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"326\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-47.png\" alt=\"\" class=\"wp-image-1264\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-47.png 778w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-47-300x126.png 300w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-47-768x322.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure>\n\n\n\n<p>\u770b\u770b\u53d1\u751f\u4e86\u4ec0\u4e48\uff1f\u5f53\u6e29\u5ea6\u9ad8\u4e8e 0 \u65f6\uff0c\u63d0\u4ea4\u76f8\u540c\u7684\u63d0\u793a\u6bcf\u6b21\u4f1a\u5bfc\u81f4\u4e0d\u540c\u7684\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u8bf7\u8bb0\u4f4f\uff0c\u8be5\u6a21\u578b\u9884\u6d4b\u54ea\u4e9b\u6587\u672c\u6700\u6709\u53ef\u80fd\u8ddf\u968f\u5176\u524d\u9762\u7684\u6587\u672c\u3002\u6e29\u5ea6\u662f\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684\u503c\uff0c\u5b9e\u8d28\u4e0a\u5141\u8bb8\u60a8\u63a7\u5236\u6a21\u578b\u5728\u8fdb\u884c\u8fd9\u4e9b\u9884\u6d4b\u65f6\u7684\u7f6e\u4fe1\u5ea6\u3002\u964d\u4f4e\u6e29\u5ea6\u610f\u5473\u7740\u98ce\u9669\u66f4\u5c0f\uff0c\u5b8c\u6210\u5c06\u66f4\u52a0\u51c6\u786e\u548c\u786e\u5b9a\u3002\u6e29\u5ea6\u5347\u9ad8\u5c06\u5bfc\u81f4\u66f4\u591a\u6837\u5316\u7684\u5b8c\u6210\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"852\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-48.png\" alt=\"\" class=\"wp-image-1265\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-48.png 752w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-48-265x300.png 265w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/figure>\n\n\n\n<p>\u5bf9\u4e8e\u60a8\u7684\u5ba0\u7269\u540d\u5b57\u751f\u6210\u5668\uff0c\u60a8\u53ef\u80fd\u5e0c\u671b\u80fd\u591f\u751f\u6210\u5f88\u591a\u540d\u5b57\u521b\u610f\u30020.6\u7684\u4e2d\u7b49\u6e29\u5ea6\u5e94\u8be5\u6548\u679c\u5f88\u597d\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/build-your-application\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/build-your-application\">4\u6784\u5efa\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f<\/a><\/h2>\n\n\n\n<p>NODE.JS  PYTHON (FLASK)<\/p>\n\n\n\n<p>\u73b0\u5728\u60a8\u5df2\u7ecf\u627e\u5230\u4e86\u4e00\u4e2a\u5f88\u597d\u7684\u63d0\u793a\u548c\u8bbe\u7f6e\uff0c\u60a8\u53ef\u4ee5\u6784\u5efa\u60a8\u7684\u5ba0\u7269\u540d\u5b57\u751f\u6210\u5668\u4e86\uff01\u6211\u4eec\u7f16\u5199\u4e86\u4e00\u4e9b\u4ee3\u7801\u6765\u5e2e\u52a9\u4f60\u5165\u95e8 &#8211; \u6309\u7167\u4ee5\u4e0b\u8bf4\u660e\u4e0b\u8f7d\u4ee3\u7801\u5e76\u8fd0\u884c\u5e94\u7528\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/setup\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/setup\">\u8bbe\u7f6e<\/a><\/h3>\n\n\n\n<p>\u5982\u679c\u60a8\u6ca1\u6709\u5b89\u88c5 Node.js\uff0c\u8bf7<a href=\"https:\/\/nodejs.org\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u4ece\u6b64\u5904\u5b89\u88c5\u5b83<\/a>\u3002\u7136\u540e\u901a\u8fc7\u514b\u9686<a href=\"https:\/\/github.com\/openai\/openai-quickstart-node\" target=\"_blank\" rel=\"noreferrer noopener\">\u6b64\u5b58\u50a8\u5e93<\/a>\u4e0b\u8f7d\u4ee3\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/openai\/openai-quickstart-node.git<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u60a8\u4e0d\u60f3\u4f7f\u7528 git\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6b64&nbsp;<a href=\"https:\/\/github.com\/openai\/openai-quickstart-node\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noreferrer noopener\">zip \u6587\u4ef6<\/a>\u4e0b\u8f7d\u4ee3\u7801\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/add-your-api-key\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/add-your-api-key\">\u6dfb\u52a0\u60a8\u7684 API \u5bc6\u94a5<\/a><\/h3>\n\n\n\n<p>\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\u5e76\u590d\u5236\u793a\u4f8b\u73af\u5883\u53d8\u91cf\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd openai-quickstart-node\ncp .env.example .env<\/code><\/pre>\n\n\n\n<p>\u590d\u5236\u60a8\u7684\u79c1\u6709 API \u5bc6\u94a5\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u4e2d\u7684 \u3002\u5982\u679c\u60a8\u5c1a\u672a\u521b\u5efa\u5bc6\u94a5\uff0c\u53ef\u4ee5\u5728\u4e0b\u9762\u6267\u884c\u6b64\u64cd\u4f5c\u3002<code>OPENAI_API_KEY<\/code><code>.env<\/code><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5bc6\u94a5<\/th><th>\u521b\u5efa<\/th><th>\u4e0a\u6b21\u4f7f\u7528<\/th><th><\/th><\/tr><\/thead><tbody><tr><td>SK-&#8230;ry1t<\/td><td>2023\u5e742\u670819\u65e5<\/td><td>2023\u5e742\u670819\u65e5<\/td><td>\u200d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u521b\u5efa\u65b0\u7684\u5bc6\u94a5<\/p>\n\n\n\n<p><strong>\u91cd\u8981\u63d0\u793a\uff1a\u4f7f\u7528 Javascript \u65f6\uff0c\u6240\u6709 API \u8c03\u7528\u90fd\u5e94\u4ec5\u5728\u670d\u52a1\u5668\u7aef\u8fdb\u884c\uff0c\u56e0\u4e3a\u5728\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u4ee3\u7801\u4e2d\u8fdb\u884c\u8c03\u7528\u5c06\u66b4\u9732\u60a8\u7684 API \u5bc6\u94a5\u3002\u6709\u5173\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff0c<a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/authentication\">\u8bf7\u53c2\u9605\u6b64\u5904<\/a>\u3002<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/run-the-app\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/run-the-app\">\u8fd0\u884c\u5e94\u7528<\/a><\/h3>\n\n\n\n<p>\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5b89\u88c5\u4f9d\u8d56\u9879\u5e76\u8fd0\u884c\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install\nnpm run dev<\/code><\/pre>\n\n\n\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00&nbsp;<a href=\"http:\/\/localhost:3000\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:3000<\/a>\uff0c\u60a8\u5e94\u8be5\u4f1a\u770b\u5230\u5ba0\u7269\u540d\u79f0\u751f\u6210\u5668\uff01<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/understand-the-code\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/understand-the-code\">\u7406\u89e3\u4ee3\u7801<\/a><\/h3>\n\n\n\n<p>\u5728\u6587\u4ef6\u5939\u4e2d\u6253\u5f00\u3002\u5728\u5e95\u90e8\uff0c\u60a8\u5c06\u770b\u5230\u751f\u6210\u6211\u4eec\u4e0a\u9762\u4f7f\u7528\u7684\u63d0\u793a\u7684\u51fd\u6570\u3002\u7531\u4e8e\u7528\u6237\u5c06\u8f93\u5165\u5176\u5ba0\u7269\u7684\u52a8\u7269\u7c7b\u578b\uff0c\u56e0\u6b64\u5b83\u4f1a\u52a8\u6001\u4ea4\u6362\u63d0\u793a\u4e2d\u6307\u5b9a\u52a8\u7269\u7684\u90e8\u5206\u3002<code>generate.js<\/code><code>openai-quickstart-node\/pages\/api<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function generatePrompt(animal) {\n  const capitalizedAnimal = animal&#91;0].toUpperCase() + animal.slice(1).toLowerCase();\n  return `Suggest three names for an animal that is a superhero.\n\nAnimal: Cat\nNames: Captain Sharpclaw, Agent Fluffball, The Incredible Feline\nAnimal: Dog\nNames: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot\nAnimal: ${capitalizedAnimal}\nNames:`;\n}<\/code><\/pre>\n\n\n\n<p>\u5728 \u7684\u7b2c 9 \u884c\u4e2d\uff0c\u60a8\u5c06\u770b\u5230\u53d1\u9001\u5b9e\u9645 API \u8bf7\u6c42\u7684\u4ee3\u7801\u3002\u5982\u4e0a\u6240\u8ff0\uff0c\u5b83\u4f7f\u7528\u6e29\u5ea6\u4e3a 0.6 \u7684<a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/completions\">\u5b8c\u6210<\/a>\u7ec8\u7ed3\u70b9\u3002<code>generate.js<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const completion = await openai.createCompletion({\n  model: \"text-davinci-003\",\n  prompt: generatePrompt(req.body.animal),\n  temperature: 0.6,\n});<\/code><\/pre>\n\n\n\n<p>\u5c31\u662f\u8fd9\u6837\uff01\u60a8\u73b0\u5728\u5e94\u8be5\u5b8c\u5168\u4e86\u89e3\u60a8\u7684\uff08\u8d85\u7ea7\u82f1\u96c4\uff09\u5ba0\u7269\u540d\u5b57\u751f\u6210\u5668\u5982\u4f55\u4f7f\u7528 OpenAI API\uff01<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/closing\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/closing\">\u5173\u95ed<\/a><\/h2>\n\n\n\n<p>\u8fd9\u4e9b\u6982\u5ff5\u548c\u6280\u672f\u5c06\u5927\u5927\u6709\u52a9\u4e8e\u60a8\u6784\u5efa\u81ea\u5df1\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u53ea\u5c55\u793a\u4e86\u53ef\u80fd\u6027\u7684\u4e00\u5c0f\u90e8\u5206\uff01\u5b8c\u6210\u7aef\u70b9\u8db3\u591f\u7075\u6d3b\uff0c\u53ef\u4ee5\u89e3\u51b3\u51e0\u4e4e\u4efb\u4f55\u8bed\u8a00\u5904\u7406\u4efb\u52a1\uff0c\u5305\u62ec\u5185\u5bb9\u751f\u6210\u3001\u6458\u8981\u3001\u8bed\u4e49\u641c\u7d22\u3001\u4e3b\u9898\u6807\u8bb0\u3001\u60c5\u7eea\u5206\u6790\u7b49\u7b49\u3002<\/p>\n\n\n\n<p>\u8981\u8bb0\u4f4f\u7684\u4e00\u4e2a\u9650\u5236\u662f\uff0c\u5bf9\u4e8e\u5927\u591a\u6570<strong>\u6a21\u578b<\/strong>\uff0c\u5355\u4e2a API \u8bf7\u6c42\u5728\u63d0\u793a\u548c\u5b8c\u6210\u4e4b\u95f4\u6700\u591a\u53ea\u80fd\u5904\u7406 2\uff0c048 \u4e2a\u4ee4\u724c\uff08\u5927\u7ea6 1\uff0c500 \u4e2a\u5355\u8bcd\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"295\" src=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-49.png\" alt=\"\" class=\"wp-image-1266\" srcset=\"https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-49.png 735w, https:\/\/www.aqwu.net\/wp\/wp-content\/uploads\/2023\/02\/\u56fe\u7247-49-300x120.png 300w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/figure>\n\n\n\n<p>\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u4efb\u52a1\uff0c\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\u81ea\u5df1\u5e0c\u671b\u80fd\u591f\u63d0\u4f9b\u6bd4\u5355\u4e2a\u63d0\u793a\u6240\u80fd\u5bb9\u7eb3\u7684\u66f4\u591a\u7684\u793a\u4f8b\u6216\u4e0a\u4e0b\u6587\u3002<a href=\"https:\/\/platform.openai.com\/docs\/guides\/fine-tuning\">\u5fae\u8c03 API<\/a>&nbsp;\u662f\u6b64\u7c7b\u66f4\u9ad8\u7ea7\u4efb\u52a1\u7684\u7edd\u4f73\u9009\u62e9\u3002<strong>\u5fae\u8c03<\/strong>\u5141\u8bb8\u60a8\u63d0\u4f9b\u6570\u767e\u751a\u81f3\u6570\u5343\u4e2a\u793a\u4f8b\uff0c\u4ee5\u9488\u5bf9\u60a8\u7684\u7279\u5b9a\u7528\u4f8b\u81ea\u5b9a\u4e49\u6a21\u578b\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/next-steps\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/quickstart\/next-steps\">\u540e\u7eed\u6b65\u9aa4<\/a><\/h2>\n\n\n\n<p>\u8981\u83b7\u5f97\u7075\u611f\u5e76\u4e86\u89e3\u6709\u5173\u4e3a\u4e0d\u540c\u4efb\u52a1\u8bbe\u8ba1\u63d0\u793a\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9605\u8bfb\u6211\u4eec\u7684<a href=\"https:\/\/platform.openai.com\/docs\/guides\/completion\">\u5b8c\u6210\u6307\u5357<\/a>\u3002<\/li>\n\n\n\n<li>\u6d4f\u89c8\u6211\u4eec\u7684<a href=\"https:\/\/platform.openai.com\/examples\">\u793a\u4f8b\u63d0\u793a<\/a>\u5e93\u3002<\/li>\n\n\n\n<li>\u5f00\u59cb\u5728<a href=\"https:\/\/platform.openai.com\/playground\">\u64cd\u573a<\/a>\u4e0a\u505a\u5b9e\u9a8c\u3002<\/li>\n\n\n\n<li>\u5728\u5f00\u59cb\u6784\u5efa\u65f6\uff0c\u8bf7\u8bb0\u4f4f\u6211\u4eec\u7684<a href=\"https:\/\/platform.openai.com\/docs\/usage-policies\">\u4f7f\u7528\u7b56\u7565<\/a>\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>OpenAI\u5df2\u7ecf\u8bad\u7ec3\u4e86\u975e\u5e38\u64c5\u957f\u7406\u89e3\u548c\u751f\u6210\u6587\u672c\u7684\u5c16\u7aef\u8bed\u8a00\u6a21\u578b\u3002\u6211\u4eec\u7684API\u63d0\u4f9b\u5bf9\u8fd9\u4e9b\u6a21\u578b\u7684\u8bbf\u95ee\uff0c\u53ef\u7528\u4e8e\u89e3\u51b3\u51e0\u4e4e\u4efb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[289,312,43],"tags":[242,314],"class_list":["post-1255","post","type-post","status-publish","format-standard","hentry","category-gpt","category-openai","category-infoarticle","tag-chatgpt","tag-openai-api"],"views":1030,"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1255"}],"version-history":[{"count":3,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1255\/revisions"}],"predecessor-version":[{"id":1310,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1255\/revisions\/1310"}],"wp:attachment":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}