{"id":228,"date":"2026-03-21T22:47:23","date_gmt":"2026-03-21T14:47:23","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/providers-openai\/"},"modified":"2026-03-21T23:08:54","modified_gmt":"2026-03-21T15:08:54","slug":"providers-openai","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/providers-openai\/","title":{"rendered":"OpenAI"},"content":{"rendered":"<h1>OpenAI<\/h1>\n<p>OpenAI \u4e3a GPT \u6a21\u578b\u63d0\u4f9b\u5f00\u53d1\u8005 API\u3002Codex \u652f\u6301<strong>ChatGPT \u767b\u5f55<\/strong>\u4ee5\u8fdb\u884c\u8ba2\u9605<br \/>\n\u8bbf\u95ee\uff0c\u4e5f\u652f\u6301<strong>API \u5bc6\u94a5<\/strong>\u767b\u5f55\u4ee5\u8fdb\u884c\u6309\u4f7f\u7528\u91cf\u8ba1\u8d39\u7684\u8bbf\u95ee\u3002Codex cloud \u9700\u8981 ChatGPT \u767b\u5f55\u3002<br \/>\nOpenAI \u660e\u786e\u652f\u6301\u5728 OpenClaw \u8fd9\u6837\u7684\u5916\u90e8\u5de5\u5177\/\u5de5\u4f5c\u6d41\u4e2d\u4f7f\u7528\u8ba2\u9605 OAuth\u3002<\/p>\n<h2>\u9009\u9879 A\uff1aOpenAI API \u5bc6\u94a5\uff08OpenAI Platform\uff09<\/h2>\n<p><strong>\u6700\u9002\u5408\uff1a<\/strong> \u76f4\u63a5 API \u8bbf\u95ee\u548c\u6309\u4f7f\u7528\u91cf\u8ba1\u8d39\u3002<br \/>\n\u4ece OpenAI \u63a7\u5236\u53f0\u83b7\u53d6\u4f60\u7684 API \u5bc6\u94a5\u3002<\/p>\n<h3>CLI \u8bbe\u7f6e<\/h3>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw onboard &#8211;auth-choice openai-api-key<\/p>\n<h1>or non-interactive<\/h1>\n<p>openclaw onboard &#8211;openai-api-key &#8220;$OPENAI_API_KEY&#8221;<\/p>\n<pre><code>\n### \u914d\u7f6e\u7247\u6bb5\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  env: { OPENAI_API_KEY: &quot;sk-...&quot; },\n  agents: { defaults: { model: { primary: &quot;openai\/gpt-5.4&quot; } } },\n}\n<\/code><\/pre>\n<p>OpenAI \u5f53\u524d\u7684 API \u6a21\u578b\u6587\u6863\u5c06 <code>gpt-5.4<\/code> \u548c <code>gpt-5.4-pro<\/code> \u5217\u4e3a\u76f4\u63a5<br \/>\nOpenAI API \u7528\u6cd5\u7684\u6a21\u578b\u3002OpenClaw \u4f1a\u901a\u8fc7 <code>openai\/*<\/code> Responses \u8def\u5f84\u8f6c\u53d1\u8fd9\u4e24\u8005\u3002<br \/>\nOpenClaw \u4f1a\u6709\u610f\u9690\u85cf\u8fc7\u65f6\u7684 <code>openai\/gpt-5.3-codex-spark<\/code> \u6761\u76ee\uff0c<br \/>\n\u56e0\u4e3a\u76f4\u63a5 OpenAI API \u8c03\u7528\u4f1a\u5728\u5b9e\u9645\u6d41\u91cf\u4e2d\u62d2\u7edd\u5b83\u3002<\/p>\n<p>OpenClaw <strong>\u4e0d\u4f1a<\/strong>\u5728\u76f4\u63a5 OpenAI<br \/>\nAPI \u8def\u5f84\u4e0a\u66b4\u9732 <code>openai\/gpt-5.3-codex-spark<\/code>\u3002<code>pi-ai<\/code> \u4ecd\u7136\u4e3a\u8be5\u6a21\u578b\u63d0\u4f9b\u5185\u7f6e\u6761\u76ee\uff0c\u4f46\u5f53\u524d\u5b9e\u9645 OpenAI API<br \/>\n\u8bf7\u6c42\u4f1a\u62d2\u7edd\u5b83\u3002\u5728 OpenClaw \u4e2d\uff0cSpark \u88ab\u89c6\u4e3a\u4ec5\u9650 Codex\u3002<\/p>\n<h2>\u9009\u9879 B\uff1aOpenAI Code\uff08Codex\uff09\u8ba2\u9605<\/h2>\n<p><strong>\u6700\u9002\u5408\uff1a<\/strong> \u4f7f\u7528 ChatGPT\/Codex \u8ba2\u9605\u8bbf\u95ee\uff0c\u800c\u4e0d\u662f API \u5bc6\u94a5\u3002<br \/>\nCodex cloud \u9700\u8981 ChatGPT \u767b\u5f55\uff0c\u800c Codex CLI \u652f\u6301 ChatGPT \u6216 API \u5bc6\u94a5\u767b\u5f55\u3002<\/p>\n<h3>CLI \u8bbe\u7f6e\uff08Codex OAuth\uff09<\/h3>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<\/p>\n<h1>Run Codex OAuth in the wizard<\/h1>\n<p>openclaw onboard &#8211;auth-choice openai-codex<\/p>\n<h1>Or run OAuth directly<\/h1>\n<p>openclaw models auth login &#8211;provider openai-codex<\/p>\n<pre><code>\n### \u914d\u7f6e\u7247\u6bb5\uff08Codex \u8ba2\u9605\uff09\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: { defaults: { model: { primary: &quot;openai-codex\/gpt-5.4&quot; } } },\n}\n<\/code><\/pre>\n<p>OpenAI \u5f53\u524d\u7684 Codex \u6587\u6863\u5c06 <code>gpt-5.4<\/code> \u5217\u4e3a\u5f53\u524d Codex \u6a21\u578b\u3002OpenClaw<br \/>\n\u4f1a\u5c06\u5176\u6620\u5c04\u4e3a <code>openai-codex\/gpt-5.4<\/code>\uff0c\u7528\u4e8e ChatGPT\/Codex OAuth\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684 Codex \u8d26\u6237\u6709\u6743\u4f7f\u7528 Codex Spark\uff0cOpenClaw \u4e5f\u652f\u6301\uff1a<\/p>\n<ul>\n<li><code>openai-codex\/gpt-5.3-codex-spark<\/code><\/li>\n<\/ul>\n<p>OpenClaw \u5c06 Codex Spark \u89c6\u4e3a\u4ec5\u9650 Codex\u3002\u5b83\u4e0d\u4f1a\u66b4\u9732\u76f4\u63a5\u7684<br \/>\n<code>openai\/gpt-5.3-codex-spark<\/code> API \u5bc6\u94a5\u8def\u5f84\u3002<\/p>\n<p>\u5f53 <code>pi-ai<\/code><br \/>\n\u53d1\u73b0 <code>openai-codex\/gpt-5.3-codex-spark<\/code> \u65f6\uff0cOpenClaw \u4e5f\u4f1a\u4fdd\u7559\u5b83\u3002\u8bf7\u5c06\u5176\u89c6\u4e3a\u4f9d\u8d56 entitlement \u4e14\u5904\u4e8e\u5b9e\u9a8c\u9636\u6bb5\uff1aCodex Spark \u4e0e GPT-5.4 <code>\/fast<\/code> \u5206\u5f00\uff0c\u662f\u5426\u53ef\u7528\u53d6\u51b3\u4e8e\u5df2\u767b\u5f55\u7684 Codex \/<br \/>\nChatGPT \u8d26\u6237\u3002<\/p>\n<h3>\u9ed8\u8ba4\u4f20\u8f93<\/h3>\n<p>OpenClaw \u4f7f\u7528 <code>pi-ai<\/code> \u8fdb\u884c\u6a21\u578b\u6d41\u5f0f\u4f20\u8f93\u3002\u5bf9\u4e8e <code>openai\/*<\/code> \u548c<br \/>\n<code>openai-codex\/*<\/code>\uff0c\u9ed8\u8ba4\u4f20\u8f93\u90fd\u662f <code>\"auto\"<\/code>\uff08\u4f18\u5148 WebSocket\uff0c\u7136\u540e\u56de\u9000\u5230 SSE\uff09\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u8bbe\u7f6e <code>agents.defaults.models.&lt;provider\/model&gt;.params.transport<\/code>\uff1a<\/p>\n<ul>\n<li><code>\"sse\"<\/code>\uff1a\u5f3a\u5236\u4f7f\u7528 SSE<\/li>\n<li><code>\"websocket\"<\/code>\uff1a\u5f3a\u5236\u4f7f\u7528 WebSocket<\/li>\n<li><code>\"auto\"<\/code>\uff1a\u5c1d\u8bd5 WebSocket\uff0c\u7136\u540e\u56de\u9000\u5230 SSE<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e <code>openai\/*<\/code>\uff08Responses API\uff09\uff0c\u5f53\u4f7f\u7528 WebSocket \u4f20\u8f93\u65f6\uff0c<br \/>\nOpenClaw \u8fd8\u4f1a\u9ed8\u8ba4\u542f\u7528 WebSocket \u9884\u70ed<br \/>\n\uff08<code>openaiWsWarmup: true<\/code>\uff09\u3002<\/p>\n<p>\u76f8\u5173 OpenAI \u6587\u6863\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/platform.openai.com\/docs\/guides\/realtime-websocket\">Realtime API with WebSocket<\/a><\/li>\n<li><a href=\"https:\/\/platform.openai.com\/docs\/guides\/streaming-responses\">Streaming API responses (SSE)<\/a><\/li>\n<\/ul>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  agents: {<br \/>\n    defaults: {<br \/>\n      model: { primary: &#8220;openai-codex\/gpt-5.4&#8221; },<br \/>\n      models: {<br \/>\n        &#8220;openai-codex\/gpt-5.4&#8221;: {<br \/>\n          params: {<br \/>\n            transport: &#8220;auto&#8221;,<br \/>\n          },<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n### OpenAI WebSocket \u9884\u70ed\n\nOpenAI \u6587\u6863\u5c06\u9884\u70ed\u63cf\u8ff0\u4e3a\u53ef\u9009\u3002OpenClaw \u5bf9\n`openai\/*` \u9ed8\u8ba4\u542f\u7528\u5b83\uff0c\u4ee5\u5728\u4f7f\u7528 WebSocket \u4f20\u8f93\u65f6\u51cf\u5c11\u9996\u6b21\u54cd\u5e94\u5ef6\u8fdf\u3002\n\n### \u7981\u7528\u9884\u70ed\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    defaults: {\n      models: {\n        &quot;openai\/gpt-5.4&quot;: {\n          params: {\n            openaiWsWarmup: false,\n          },\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<h3>\u663e\u5f0f\u542f\u7528\u9884\u70ed<\/h3>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  agents: {<br \/>\n    defaults: {<br \/>\n      models: {<br \/>\n        &#8220;openai\/gpt-5.4&#8221;: {<br \/>\n          params: {<br \/>\n            openaiWsWarmup: true,<br \/>\n          },<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n### OpenAI \u4f18\u5148\u5904\u7406\n\nOpenAI \u7684 API \u901a\u8fc7 `service_tier=priority` \u66b4\u9732\u4f18\u5148\u5904\u7406\u3002\u5728\nOpenClaw \u4e2d\uff0c\u8bbe\u7f6e `agents.defaults.models[&quot;openai\/&lt;model&gt;&quot;].params.serviceTier`\uff0c\u5373\u53ef\n\u5728\u76f4\u63a5 `openai\/*` Responses \u8bf7\u6c42\u4e2d\u900f\u4f20\u8be5\u5b57\u6bb5\u3002\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    defaults: {\n      models: {\n        &quot;openai\/gpt-5.4&quot;: {\n          params: {\n            serviceTier: &quot;priority&quot;,\n          },\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<p>\u652f\u6301\u7684\u503c\u4e3a <code>auto<\/code>\u3001<code>default<\/code>\u3001<code>flex<\/code> \u548c <code>priority<\/code>\u3002<\/p>\n<h3>OpenAI \u5feb\u901f\u6a21\u5f0f<\/h3>\n<p>OpenClaw \u4e3a <code>openai\/*<\/code> \u548c<br \/>\n<code>openai-codex\/*<\/code> \u4f1a\u8bdd\u516c\u5f00\u4e86\u5171\u4eab\u5feb\u901f\u6a21\u5f0f\u5f00\u5173\uff1a<\/p>\n<ul>\n<li>\u804a\u5929\/UI\uff1a<code>\/fast status|on|off<\/code><\/li>\n<li>\u914d\u7f6e\uff1a<code>agents.defaults.models[\"&lt;provider&gt;\/&lt;model&gt;\"].params.fastMode<\/code><\/li>\n<\/ul>\n<p>\u542f\u7528\u5feb\u901f\u6a21\u5f0f\u540e\uff0cOpenClaw \u4f1a\u5e94\u7528\u4f4e\u5ef6\u8fdf OpenAI \u914d\u7f6e\uff1a<\/p>\n<ul>\n<li>\u5f53\u8d1f\u8f7d\u672a\u660e\u786e\u6307\u5b9a reasoning \u65f6\uff0c\u8bbe\u7f6e <code>reasoning.effort = \"low\"<\/code><\/li>\n<li>\u5f53\u8d1f\u8f7d\u672a\u660e\u786e\u6307\u5b9a verbosity \u65f6\uff0c\u8bbe\u7f6e <code>text.verbosity = \"low\"<\/code><\/li>\n<li>\u5bf9\u76f4\u63a5\u53d1\u5f80 <code>api.openai.com<\/code> \u7684 <code>openai\/*<\/code> Responses \u8c03\u7528\u8bbe\u7f6e <code>service_tier = \"priority\"<\/code><\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  agents: {<br \/>\n    defaults: {<br \/>\n      models: {<br \/>\n        &#8220;openai\/gpt-5.4&#8221;: {<br \/>\n          params: {<br \/>\n            fastMode: true,<br \/>\n          },<br \/>\n        },<br \/>\n        &#8220;openai-codex\/gpt-5.4&#8221;: {<br \/>\n          params: {<br \/>\n            fastMode: true,<br \/>\n          },<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n\u4f1a\u8bdd\u8986\u76d6\u4f18\u5148\u4e8e\u914d\u7f6e\u3002\u5728\u4f1a\u8bdd UI \u4e2d\u6e05\u9664\u4f1a\u8bdd\u8986\u76d6\u540e\uff0c\n\u8be5\u4f1a\u8bdd\u4f1a\u6062\u590d\u4e3a\u914d\u7f6e\u7684\u9ed8\u8ba4\u503c\u3002\n\n### OpenAI Responses \u670d\u52a1\u7aef\u538b\u7f29\n\n\u5bf9\u4e8e\u76f4\u63a5 OpenAI Responses \u6a21\u578b\uff08\u4f7f\u7528 `api: &quot;openai-responses&quot;` \u7684 `openai\/*`\uff0c\n\u4e14 `baseUrl` \u6307\u5411 `api.openai.com`\uff09\uff0cOpenClaw \u73b0\u5728\u4f1a\u81ea\u52a8\u542f\u7528 OpenAI \u670d\u52a1\u7aef\n\u538b\u7f29\u8d1f\u8f7d\u63d0\u793a\uff1a\n\n* \u5f3a\u5236\u8bbe\u7f6e `store: true`\uff08\u9664\u975e\u6a21\u578b\u517c\u5bb9\u6027\u8bbe\u7f6e `supportsStore: false`\uff09\n* \u6ce8\u5165 `context_management: [{ type: &quot;compaction&quot;, compact_threshold: ... }]`\n\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c`compact_threshold` \u4e3a\u6a21\u578b `contextWindow` \u7684 `70%`\uff08\u6216\u5728\u4e0d\u53ef\u7528\u65f6\u4e3a `80000`\uff09\u3002\n\n### \u663e\u5f0f\u542f\u7528\u670d\u52a1\u7aef\u538b\u7f29\n\n\u5f53\u4f60\u60f3\u5728\u517c\u5bb9\u7684\nResponses \u6a21\u578b\u4e0a\u5f3a\u5236\u6ce8\u5165 `context_management` \u65f6\u4f7f\u7528\u6b64\u8bbe\u7f6e\uff08\u4f8b\u5982 Azure OpenAI Responses\uff09\uff1a\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    defaults: {\n      models: {\n        &quot;azure-openai-responses\/gpt-5.4&quot;: {\n          params: {\n            responsesServerCompaction: true,\n          },\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<h3>\u4f7f\u7528\u81ea\u5b9a\u4e49\u9608\u503c\u542f\u7528<\/h3>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  agents: {<br \/>\n    defaults: {<br \/>\n      models: {<br \/>\n        &#8220;openai\/gpt-5.4&#8221;: {<br \/>\n          params: {<br \/>\n            responsesServerCompaction: true,<br \/>\n            responsesCompactThreshold: 120000,<br \/>\n          },<br \/>\n        },<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n### \u7981\u7528\u670d\u52a1\u7aef\u538b\u7f29\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    defaults: {\n      models: {\n        &quot;openai\/gpt-5.4&quot;: {\n          params: {\n            responsesServerCompaction: false,\n          },\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<p><code>responsesServerCompaction<\/code> \u4ec5\u63a7\u5236 <code>context_management<\/code> \u6ce8\u5165\u3002<br \/>\n\u76f4\u63a5 OpenAI Responses \u6a21\u578b\u4ecd\u4f1a\u5f3a\u5236\u8bbe\u7f6e <code>store: true<\/code>\uff0c\u9664\u975e\u517c\u5bb9\u6027\u8bbe\u7f6e<br \/>\n\u4e86 <code>supportsStore: false<\/code>\u3002<\/p>\n<h2>\u8bf4\u660e<\/h2>\n<ul>\n<li>\u6a21\u578b\u5f15\u7528\u59cb\u7ec8\u4f7f\u7528 <code>provider\/model<\/code>\uff08\u53c2\u89c1 <a href=\"\/concepts\/models\">\/concepts\/models<\/a>\uff09\u3002<\/li>\n<li>\u8eab\u4efd\u9a8c\u8bc1\u8be6\u60c5\u548c\u590d\u7528\u89c4\u5219\u89c1 <a href=\"\/concepts\/oauth\">\/concepts\/oauth<\/a>\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>OpenAI OpenAI \u4e3a GPT \u6a21\u578b\u63d0\u4f9b\u5f00\u53d1\u8005 API\u3002Codex \u652f\u6301ChatGPT \u767b\u5f55\u4ee5\u8fdb\u884c\u8ba2\u9605 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=228"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":523,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/228\/revisions\/523"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}