{"id":1719,"date":"2026-06-10T16:48:25","date_gmt":"2026-06-10T08:48:25","guid":{"rendered":"https:\/\/www.imaseo.com\/blog\/?p=1719"},"modified":"2026-06-02T16:06:52","modified_gmt":"2026-06-02T08:06:52","slug":"2026-codex-gpt-api-tutorial","status":"publish","type":"post","link":"https:\/\/www.imaseo.com\/blog\/ai-tools\/2026-codex-gpt-api-tutorial","title":{"rendered":"2026 \u6700\u65b0 Codex \u5bf9\u63a5 GPT API \u5b8c\u6574\u6559\u7a0b\uff1a\u57fa\u4e8e token173 \u914d\u7f6e\uff0c\u96f6\u57fa\u7840\u600e\u4e48\u4e0a\u624b\uff1f"},"content":{"rendered":"<p>2026 \u6700\u65b0 Codex \u5bf9\u63a5 GPT API \u5b8c\u6574\u6559\u7a0b\uff1a\u57fa\u4e8e token173 \u914d\u7f6e\uff0c\u96f6\u57fa\u7840\u600e\u4e48\u4e0a\u624b\uff1f<\/p>\n<p>\u60f3\u5728 2026 \u5e74\u7528 Codex \u5199\u4ee3\u7801\uff0c\u5374\u5361\u5728 API \u914d\u7f6e\u4e0a\uff1f\u672c\u6587\u7528\u6700\u76f4\u767d\u7684\u6b65\u9aa4\uff0c\u5e26\u4f60 10 \u5206\u949f\u5185\u8dd1\u901a token173 \u7684 GPT \u63a5\u53e3\uff0c\u5f7b\u5e95\u544a\u522b 401\u3001invalid_api_key \u7b49\u62a5\u9519\u3002<\/p>\n<h2>\u4e3a\u4ec0\u4e48\u9009\u62e9 token173 \u4f5c\u4e3a Codex \u7684 API \u6e90\uff1f<\/h2>\n<ul>\n<li>\u989d\u5ea6\u5145\u8db3\uff1a\u652f\u6301\u300c\u65e0\u9650\u989d\u5ea6\u300d\u8bbe\u7f6e\uff0c\u57fa\u672c\u4e0d\u7528\u62c5\u5fc3\u7528\u5b8c\u3002  <\/li>\n<li>\u5206\u7ec4\u4e13\u5c5e\uff1a\u53ea\u6709\u628a\u4ee4\u724c\u653e\u5728\u300ccodex\u4e13\u5c5e\u300d\u5206\u7ec4\uff0c\u624d\u80fd\u88ab Codex \u6b63\u786e\u8bc6\u522b\u3002  <\/li>\n<li>\u96f6\u57fa\u7840\u53cb\u597d\uff1a\u65e0\u9700\u81ea\u5efa\u4e2d\u8f6c\u6216\u5199\u8f6c\u53d1\u811a\u672c\uff0c\u65b0\u624b\u590d\u5236\u7c98\u8d34\u5373\u53ef\u3002<\/li>\n<\/ul>\n<h2>\u51c6\u5907\u5de5\u4f5c\uff083 \u5206\u949f\uff09<\/h2>\n<ol>\n<li>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95ee token173.com \u5e76\u6ce8\u518c\/\u767b\u5f55\u3002  <\/li>\n<li>\u786e\u4fdd\u7535\u8111\u5df2\u5b89\u88c5 Node.js 22+ \u4e0e npm 10+\uff08Windows\/macOS\/Linux \u901a\u7528\uff09\u3002  <\/li>\n<li>\u5b89\u88c5 Codex \u5168\u5c40\u547d\u4ee4\uff1a<br \/>\n<code>bash<br \/>\n   npm install -g @openai\/codex<\/code><\/li>\n<li>\u9a8c\u8bc1\u5b89\u88c5\uff1a<br \/>\n<code>bash<br \/>\n   codex --version<\/code><br \/>\n   \u82e5\u80fd\u6b63\u5e38\u8f93\u51fa\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ol>\n<h2>\u83b7\u53d6\u5e76\u914d\u7f6e API \u4ee4\u724c<\/h2>\n<h3>1. \u521b\u5efa token173 \u4ee4\u724c<\/h3>\n<ul>\n<li>\u8fdb\u5165\u300c\u63a7\u5236\u53f0 \u2192 API \u4ee4\u724c\u300d\u3002  <\/li>\n<li>\u70b9\u51fb\u300c\u6dfb\u52a0\u4ee4\u724c\u300d\u3002  <\/li>\n<li>\u4ee4\u724c\u5206\u7ec4<strong>\u5fc5\u987b<\/strong>\u9009\u300ccodex\u4e13\u5c5e\u300d\u3002  <\/li>\n<li>\u4ee4\u724c\u540d\u79f0\u968f\u610f\u586b\u5199\u3002  <\/li>\n<li>\u989d\u5ea6\u5efa\u8bae\u8bbe\u4e3a\u300c\u65e0\u9650\u989d\u5ea6\u300d\u3002  <\/li>\n<li>\u5176\u4f59\u9009\u9879\u4fdd\u6301\u9ed8\u8ba4\uff0c\u70b9\u51fb\u4fdd\u5b58\u3002  <\/li>\n<li>\u590d\u5236\u751f\u6210\u7684 <code>sk-<\/code> \u5f00\u5934\u5bc6\u94a5\uff0c\u7a0d\u540e\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h3>2. \u653e\u7f6e\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>Windows \u7528\u6237\u8def\u5f84\uff1a<code>C:\\Users\\\u4f60\u7684\u7528\u6237\u540d\\.codex<\/code><br \/>\nmacOS\/Linux \u7528\u6237\u8def\u5f84\uff1a<code>~\/.codex<\/code><\/p>\n<p>\u5982\u679c\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c\u624b\u52a8\u65b0\u5efa\u5373\u53ef\u3002\u76ee\u5f55\u5185\u521b\u5efa\u4e24\u4e2a\u6587\u4ef6\uff1a<\/p>\n<p><strong>auth.json<\/strong><\/p>\n<pre><code class=\"language-json\">{\n  &quot;OPENAI_API_KEY&quot;: &quot;sk-xxx&quot;\n}\n<\/code><\/pre>\n<blockquote>\n<p>\u628a <code>sk-xxx<\/code> \u66ff\u6362\u6210\u4f60\u5728 token173 \u751f\u6210\u7684\u771f\u5b9e\u5bc6\u94a5\u3002<\/p>\n<\/blockquote>\n<p><strong>config.toml<\/strong><\/p>\n<pre><code class=\"language-toml\">model\nname = &quot;gpt-4o&quot;\n\napi\nbase_url = &quot;https:\/\/api.token173.com\/v1&quot;\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u540e\u5373\u53ef\u5173\u95ed\u6587\u4ef6\u3002<\/p>\n<h2>\u9996\u6b21\u542f\u52a8\u4e0e\u6a21\u5f0f\u9009\u62e9<\/h2>\n<p>\u5728\u4efb\u610f\u9879\u76ee\u76ee\u5f55\u4e0b\u6267\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">codex\n<\/code><\/pre>\n<p>\u9996\u6b21\u4f1a\u5f39\u51fa\u4e09\u79cd\u6a21\u5f0f\uff1a<br \/>\n&#8211; Suggest\uff1a\u4ec5\u7ed9\u51fa\u4fee\u6539\u5efa\u8bae\uff0c\u4e0d\u6539\u6587\u4ef6\u3002<br \/>\n&#8211; Auto Edit\uff1a\u81ea\u52a8\u4fee\u6539\u6587\u4ef6\uff0c\u4f46\u4e0d\u6267\u884c\u547d\u4ee4\u3002<br \/>\n&#8211; Full Auto\uff1a\u5b8c\u5168\u81ea\u52a8\u5316\uff0c\u9002\u5408\u5feb\u901f\u539f\u578b\u3002<\/p>\n<p>\u6309\u4e0a\u4e0b\u952e\u9009\u62e9\uff0c\u56de\u8f66\u786e\u8ba4\u3002\u4e4b\u540e\u5373\u53ef\u5728\u7ec8\u7aef\u6216 VSCode \u7ec8\u7aef\u91cc\u76f4\u63a5\u7528\u81ea\u7136\u8bed\u8a00\u5199\u4ee3\u7801\u3002<\/p>\n<h2>\u5e38\u89c1\u62a5\u9519\u901f\u67e5<\/h2>\n<div style=\"overflow-x:auto; -webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%; border-collapse:collapse; border:1px solid ddd; margin:20px 0;\">\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\"ead style=\"background-color:f7f7f7; font-weight:bold;\">\n<tr>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u62a5\u9519\u4fe1\u606f<\/th>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u53ef\u80fd\u539f\u56e0<\/th>\n<th style=\"border:1px solid ddd; padding:10px; text-align:left;\" style=\"background-color:f7f7f7; font-weight:bold;\">\u89e3\u51b3\u65b9\u6cd5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">401 invalid_api_key<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u5bc6\u94a5\u672a\u66ff\u6362\u6216\u5206\u7ec4\u9519\u8bef<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u68c0\u67e5 auth.json \u4e0e\u5206\u7ec4\u8bbe\u7f6e<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">model not found<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">config.toml \u6a21\u578b\u540d\u9519\u8bef<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u6539\u4e3a gpt-4o \u6216 gpt-4-turbo<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">ECONNREFUSED<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">base_url \u62fc\u5199\u9519\u8bef<\/td>\n<td style=\"border:1px solid ddd; padding:10px; text-align:left;\">\u786e\u8ba4 https:\/\/api.token173.com\/v1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>\u66f4\u65b0\u4e0e\u5378\u8f7d<\/h2>\n<pre><code class=\"language-bash\"> \u66f4\u65b0\u5230\u6700\u65b0\u7248\nnpm update -g @openai\/codex\n\n \u5378\u8f7d\nnpm uninstall -g @openai\/codex\n<\/code><\/pre>\n<h2>\u7ed3\u8bed<\/h2>\n<p>\u6309\u7167\u4ee5\u4e0a\u6b65\u9aa4\u64cd\u4f5c\uff0c\u96f6\u57fa\u7840\u7528\u6237\u4e5f\u80fd\u5728 2026 \u5e74\u7a33\u5b9a\u4f7f\u7528 Codex + token173 GPT API\u3002\u914d\u7f6e\u4e00\u6b21\uff0c\u957f\u671f\u4eab\u53d7\u9ad8\u989d\u5ea6\u3001\u4e0d\u5c01\u53f7\u7684 AI \u7f16\u7a0b\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2026 \u6700\u65b0 Codex \u5bf9\u63a5 GPT API \u5b8c\u6574\u6559\u7a0b\uff1a\u57fa\u4e8e token173 \u914d\u7f6e\uff0c\u96f6\u57fa\u7840\u600e\u4e48\u4e0a\u624b\uff1f \u60f3\u5728 202\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1719","post","type-post","status-publish","format-standard","hentry","category-ai-tools"],"_links":{"self":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1719","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/comments?post=1719"}],"version-history":[{"count":1,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1719\/revisions"}],"predecessor-version":[{"id":1720,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/posts\/1719\/revisions\/1720"}],"wp:attachment":[{"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/media?parent=1719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/categories?post=1719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.imaseo.com\/blog\/wp-json\/wp\/v2\/tags?post=1719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}