{"id":227,"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-ollama\/"},"modified":"2026-03-21T23:08:53","modified_gmt":"2026-03-21T15:08:53","slug":"providers-ollama","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/providers-ollama\/","title":{"rendered":"Ollama"},"content":{"rendered":"<h1>Ollama<\/h1>\n<p>Ollama \u662f\u4e00\u4e2a\u672c\u5730 LLM \u8fd0\u884c\u65f6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5728\u81ea\u5df1\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u5f00\u6e90\u6a21\u578b\u3002OpenClaw \u96c6\u6210\u4e86 Ollama \u7684\u539f\u751f API\uff08<code>\/api\/chat<\/code>\uff09\uff0c\u652f\u6301\u6d41\u5f0f\u4f20\u8f93\u548c\u5de5\u5177\u8c03\u7528\uff0c\u5e76\u4e14\u5728\u4f60\u9009\u62e9\u4f7f\u7528 <code>OLLAMA_API_KEY<\/code>\uff08\u6216\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\uff09\u4e14\u672a\u5b9a\u4e49\u663e\u5f0f <code>models.providers.ollama<\/code> \u6761\u76ee\u65f6\uff0c\u53ef\u4ee5\u81ea\u52a8\u53d1\u73b0\u672c\u5730 Ollama \u6a21\u578b\u3002<\/p>\n<p>\n  <strong>\u8fdc\u7a0b Ollama \u7528\u6237\uff1a<\/strong> \u4e0d\u8981\u5728 OpenClaw \u4e2d\u4f7f\u7528 <code>\/v1<\/code> \u7684 OpenAI \u517c\u5bb9 URL\uff08<code>http:\/\/host:11434\/v1<\/code>\uff09\u3002\u8fd9\u4f1a\u7834\u574f\u5de5\u5177\u8c03\u7528\uff0c\u800c\u4e14\u6a21\u578b\u53ef\u80fd\u4f1a\u628a\u539f\u59cb\u5de5\u5177 JSON \u5f53\u4f5c\u7eaf\u6587\u672c\u8f93\u51fa\u3002\u8bf7\u6539\u7528\u539f\u751f Ollama API URL\uff1a<code>baseUrl: \"http:\/\/host:11434\"<\/code>\uff08\u4e0d\u8981\u52a0 <code>\/v1<\/code>\uff09\u3002\n<\/p>\n<h2>\u5feb\u901f\u5f00\u59cb<\/h2>\n<h3>\u65b0\u624b\u5f15\u5bfc\u5411\u5bfc\uff08\u63a8\u8350\uff09<\/h3>\n<p>\u901a\u8fc7\u8bbe\u7f6e\u5411\u5bfc\u914d\u7f6e Ollama \u662f\u6700\u5feb\u7684\u65b9\u6cd5\uff1a<\/p>\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<\/p>\n<pre><code>\n\u4ece\u63d0\u4f9b\u5546\u5217\u8868\u4e2d\u9009\u62e9 **Ollama**\u3002\u5411\u5bfc\u5c06\u4f1a\uff1a\n\n1. \u8be2\u95ee\u4f60\u7684 Ollama base URL\uff0c\u4e5f\u5c31\u662f\u53ef\u4ee5\u8bbf\u95ee\u4f60\u7684\u5b9e\u4f8b\u7684\u5730\u5740\uff08\u9ed8\u8ba4 `http:\/\/127.0.0.1:11434`\uff09\u3002\n2. \u8ba9\u4f60\u9009\u62e9 **Cloud + Local**\uff08\u4e91\u7aef\u6a21\u578b\u548c\u672c\u5730\u6a21\u578b\uff09\u6216 **Local**\uff08\u4ec5\u672c\u5730\u6a21\u578b\uff09\u3002\n3. \u5982\u679c\u4f60\u9009\u62e9 **Cloud + Local** \u4e14\u5c1a\u672a\u767b\u5f55 ollama.com\uff0c\u5219\u6253\u5f00\u6d4f\u89c8\u5668\u767b\u5f55\u6d41\u7a0b\u3002\n4. \u53d1\u73b0\u53ef\u7528\u6a21\u578b\u5e76\u5efa\u8bae\u9ed8\u8ba4\u503c\u3002\n5. \u5982\u679c\u6240\u9009\u6a21\u578b\u672c\u5730\u4e0d\u53ef\u7528\uff0c\u5219\u81ea\u52a8\u62c9\u53d6\u5b83\u3002\n\n\u4e5f\u652f\u6301\u975e\u4ea4\u4e92\u6a21\u5f0f\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw onboard --non-interactive \n  --auth-choice ollama \n  --accept-risk\n<\/code><\/pre>\n<p>\u4e5f\u53ef\u4ee5\u9009\u62e9\u6307\u5b9a\u81ea\u5b9a\u4e49 base URL \u6216\u6a21\u578b\uff1a<\/p>\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;non-interactive<br \/>\n  &#8211;auth-choice ollama<br \/>\n  &#8211;custom-base-url &#8220;http:\/\/ollama-host:11434&#8221;<br \/>\n  &#8211;custom-model-id &#8220;qwen3.5:27b&#8221;<br \/>\n  &#8211;accept-risk<\/p>\n<pre><code>\n### \u624b\u52a8\u8bbe\u7f6e\n\n1. \u5b89\u88c5 Ollama\uff1a[https:\/\/ollama.com\/download](https:\/\/ollama.com\/download)\n\n2. \u5982\u679c\u4f60\u60f3\u8fdb\u884c\u672c\u5730\u63a8\u7406\uff0c\u5148\u62c9\u53d6\u4e00\u4e2a\u672c\u5730\u6a21\u578b\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nollama pull glm-4.7-flash\n# \u6216\nollama pull gpt-oss:20b\n# \u6216\nollama pull llama3.3\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u5982\u679c\u4f60\u4e5f\u60f3\u4f7f\u7528\u4e91\u7aef\u6a21\u578b\uff0c\u8bf7\u5148\u767b\u5f55\uff1a<\/li>\n<\/ol>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nollama signin<\/p>\n<pre><code>\n4. \u8fd0\u884c\u65b0\u624b\u5f15\u5bfc\u5e76\u9009\u62e9 `Ollama`\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw onboard\n<\/code><\/pre>\n<ul>\n<li><code>Local<\/code>\uff1a\u4ec5\u672c\u5730\u6a21\u578b<\/li>\n<li><code>Cloud + Local<\/code>\uff1a\u672c\u5730\u6a21\u578b\u52a0\u4e91\u7aef\u6a21\u578b<\/li>\n<li>\u4e91\u7aef\u6a21\u578b\u5982 <code>kimi-k2.5:cloud<\/code>\u3001<code>minimax-m2.5:cloud<\/code> \u548c <code>glm-5:cloud<\/code> <strong>\u4e0d\u9700\u8981<\/strong> \u672c\u5730\u6267\u884c <code>ollama pull<\/code><\/li>\n<\/ul>\n<p>OpenClaw \u5f53\u524d\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u672c\u5730\u9ed8\u8ba4\uff1a<code>glm-4.7-flash<\/code><\/li>\n<li>\u4e91\u7aef\u9ed8\u8ba4\uff1a<code>kimi-k2.5:cloud<\/code>\u3001<code>minimax-m2.5:cloud<\/code>\u3001<code>glm-5:cloud<\/code><\/li>\n<\/ul>\n<ol start=\"5\">\n<li>\u5982\u679c\u4f60\u66f4\u559c\u6b22\u624b\u52a8\u8bbe\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4e3a OpenClaw \u542f\u7528 Ollama\uff08\u4efb\u610f\u503c\u90fd\u53ef\u4ee5\uff1bOllama \u4e0d\u9700\u8981\u771f\u5b9e key\uff09\uff1a<\/li>\n<\/ol>\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>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h1>\n<p>export OLLAMA_API_KEY=&#8221;ollama-local&#8221;<\/p>\n<h1>\u6216\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e<\/h1>\n<p>openclaw config set models.providers.ollama.apiKey &#8220;ollama-local&#8221;<\/p>\n<pre><code>\n6. \u67e5\u770b\u6216\u5207\u6362\u6a21\u578b\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nopenclaw models list\nopenclaw models set ollama\/glm-4.7-flash\n<\/code><\/pre>\n<ol start=\"7\">\n<li>\u6216\u8005\u5728\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u9ed8\u8ba4\u503c\uff1a<\/li>\n<\/ol>\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;ollama\/glm-4.7-flash&#8221; },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n## \u6a21\u578b\u53d1\u73b0\uff08\u9690\u5f0f\u63d0\u4f9b\u5546\uff09\n\n\u5f53\u4f60\u8bbe\u7f6e `OLLAMA_API_KEY`\uff08\u6216\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\uff09\uff0c\u5e76\u4e14**\u672a**\u5b9a\u4e49 `models.providers.ollama` \u65f6\uff0cOpenClaw \u4f1a\u4ece `http:\/\/127.0.0.1:11434` \u4e0a\u7684\u672c\u5730 Ollama \u5b9e\u4f8b\u53d1\u73b0\u6a21\u578b\uff1a\n\n* \u67e5\u8be2 `\/api\/tags`\n* \u5728\u53ef\u7528\u65f6\uff0c\u5c3d\u529b\u901a\u8fc7 `\/api\/show` \u67e5\u627e `contextWindow`\n* \u901a\u8fc7\u6a21\u578b\u540d\u79f0\u542f\u53d1\u5f0f\u89c4\u5219\u6807\u8bb0 `reasoning`\uff08`r1`\u3001`reasoning`\u3001`think`\uff09\n* \u5c06 `maxTokens` \u8bbe\u7f6e\u4e3a OpenClaw \u4f7f\u7528\u7684\u9ed8\u8ba4 Ollama \u6700\u5927 token \u4e0a\u9650\n* \u5c06\u6240\u6709\u6210\u672c\u8bbe\u7f6e\u4e3a `0`\n\n\u8fd9\u6837\u65e0\u9700\u624b\u52a8\u7ef4\u62a4\u6a21\u578b\u6761\u76ee\uff0c\u540c\u65f6\u53c8\u80fd\u8ba9\u76ee\u5f55\u4e0e\u672c\u5730 Ollama \u5b9e\u4f8b\u4fdd\u6301\u4e00\u81f4\u3002\n\n\u67e5\u770b\u6709\u54ea\u4e9b\u53ef\u7528\u6a21\u578b\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nollama list\nopenclaw models list\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u65b0\u6a21\u578b\u65f6\uff0c\u53ea\u9700\u901a\u8fc7 Ollama \u62c9\u53d6\u5b83\uff1a<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nollama pull mistral<\/p>\n<pre><code>\n\u65b0\u6a21\u578b\u4f1a\u88ab\u81ea\u52a8\u53d1\u73b0\uff0c\u5e76\u53ef\u7acb\u5373\u4f7f\u7528\u3002\n\n\u5982\u679c\u4f60\u663e\u5f0f\u8bbe\u7f6e\u4e86 `models.providers.ollama`\uff0c\u5219\u4f1a\u8df3\u8fc7\u81ea\u52a8\u53d1\u73b0\uff0c\u4f60\u5fc5\u987b\u624b\u52a8\u5b9a\u4e49\u6a21\u578b\uff08\u89c1\u4e0b\u6587\uff09\u3002\n\n## \u914d\u7f6e\n\n### \u57fa\u672c\u8bbe\u7f6e\uff08\u9690\u5f0f\u53d1\u73b0\uff09\n\n\u542f\u7528 Ollama \u7684\u6700\u7b80\u5355\u65b9\u5f0f\u662f\u901a\u8fc7\u73af\u5883\u53d8\u91cf\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nexport OLLAMA_API_KEY=&quot;ollama-local&quot;\n<\/code><\/pre>\n<h3>\u663e\u5f0f\u8bbe\u7f6e\uff08\u624b\u52a8\u6a21\u578b\uff09<\/h3>\n<p>\u4ee5\u4e0b\u60c5\u51b5\u9002\u5408\u4f7f\u7528\u663e\u5f0f\u914d\u7f6e\uff1a<\/p>\n<ul>\n<li>Ollama \u8fd0\u884c\u5728\u5176\u4ed6\u4e3b\u673a\/\u7aef\u53e3\u4e0a\u3002<\/li>\n<li>\u4f60\u60f3\u5f3a\u5236\u6307\u5b9a\u7279\u5b9a\u7684\u4e0a\u4e0b\u6587\u7a97\u53e3\u6216\u6a21\u578b\u5217\u8868\u3002<\/li>\n<li>\u4f60\u5e0c\u671b\u5b8c\u5168\u624b\u52a8\u5b9a\u4e49\u6a21\u578b\u3002<\/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  models: {<br \/>\n    providers: {<br \/>\n      ollama: {<br \/>\n        baseUrl: &#8220;http:\/\/ollama-host:11434&#8221;,<br \/>\n        apiKey: &#8220;ollama-local&#8221;,<br \/>\n        api: &#8220;ollama&#8221;,<br \/>\n        models: [<br \/>\n          {<br \/>\n            id: &#8220;gpt-oss:20b&#8221;,<br \/>\n            name: &#8220;GPT-OSS 20B&#8221;,<br \/>\n            reasoning: false,<br \/>\n            input: [&#8220;text&#8221;],<br \/>\n            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },<br \/>\n            contextWindow: 8192,<br \/>\n            maxTokens: 8192 * 10<br \/>\n          }<br \/>\n        ]<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<pre><code>\n\u5982\u679c\u8bbe\u7f6e\u4e86 `OLLAMA_API_KEY`\uff0c\u4f60\u53ef\u4ee5\u5728\u63d0\u4f9b\u5546\u6761\u76ee\u4e2d\u7701\u7565 `apiKey`\uff0cOpenClaw \u4f1a\u5728\u53ef\u7528\u6027\u68c0\u67e5\u65f6\u81ea\u52a8\u586b\u5145\u5b83\u3002\n\n### \u81ea\u5b9a\u4e49 base URL\uff08\u663e\u5f0f\u914d\u7f6e\uff09\n\n\u5982\u679c Ollama \u8fd0\u884c\u5728\u4e0d\u540c\u7684\u4e3b\u673a\u6216\u7aef\u53e3\u4e0a\uff08\u663e\u5f0f\u914d\u7f6e\u4f1a\u7981\u7528\u81ea\u52a8\u53d1\u73b0\uff0c\u56e0\u6b64\u4f60\u9700\u8981\u624b\u52a8\u5b9a\u4e49\u6a21\u578b\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  models: {\n    providers: {\n      ollama: {\n        apiKey: &quot;ollama-local&quot;,\n        baseUrl: &quot;http:\/\/ollama-host:11434&quot;, \/\/ \u4e0d\u8981\u52a0 \/v1 - \u4f7f\u7528\u539f\u751f Ollama API URL\n        api: &quot;ollama&quot;, \/\/ \u663e\u5f0f\u8bbe\u7f6e\uff0c\u4ee5\u786e\u4fdd\u539f\u751f\u5de5\u5177\u8c03\u7528\u884c\u4e3a\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<p>\n  \u4e0d\u8981\u5728 URL \u4e2d\u6dfb\u52a0 <code>\/v1<\/code>\u3002<code>\/v1<\/code> \u8def\u5f84\u4f1a\u542f\u7528 OpenAI \u517c\u5bb9\u6a21\u5f0f\uff0c\u800c\u5728\u8be5\u6a21\u5f0f\u4e0b\u5de5\u5177\u8c03\u7528\u5e76\u4e0d\u53ef\u9760\u3002\u8bf7\u4f7f\u7528\u4e0d\u5e26\u8def\u5f84\u540e\u7f00\u7684\u57fa\u7840 Ollama URL\u3002\n<\/p>\n<h3>\u6a21\u578b\u9009\u62e9<\/h3>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u4f60\u7684\u6240\u6709 Ollama \u6a21\u578b\u90fd\u53ef\u7528\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      model: {<br \/>\n        primary: &#8220;ollama\/gpt-oss:20b&#8221;,<br \/>\n        fallbacks: [&#8220;ollama\/llama3.3&#8221;, &#8220;ollama\/qwen2.5-coder:32b&#8221;],<br \/>\n      },<br \/>\n    },<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n## \u4e91\u7aef\u6a21\u578b\n\n\u4e91\u7aef\u6a21\u578b\u8ba9\u4f60\u53ef\u4ee5\u5c06\u4e91\u6258\u7ba1\u6a21\u578b\uff08\u4f8b\u5982 `kimi-k2.5:cloud`\u3001`minimax-m2.5:cloud`\u3001`glm-5:cloud`\uff09\u4e0e\u672c\u5730\u6a21\u578b\u4e00\u8d77\u4f7f\u7528\u3002\n\n\u8981\u4f7f\u7528\u4e91\u7aef\u6a21\u578b\uff0c\u8bf7\u5728\u8bbe\u7f6e\u671f\u95f4\u9009\u62e9 **Cloud + Local** \u6a21\u5f0f\u3002\u5411\u5bfc\u4f1a\u68c0\u67e5\u4f60\u662f\u5426\u5df2\u767b\u5f55\uff0c\u5e76\u5728\u9700\u8981\u65f6\u6253\u5f00\u6d4f\u89c8\u5668\u767b\u5f55\u6d41\u7a0b\u3002\u5982\u679c\u65e0\u6cd5\u9a8c\u8bc1\u8ba4\u8bc1\u72b6\u6001\uff0c\u5411\u5bfc\u4f1a\u56de\u9000\u5230\u672c\u5730\u6a21\u578b\u9ed8\u8ba4\u503c\u3002\n\n\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728 [ollama.com\/signin](https:\/\/ollama.com\/signin) \u767b\u5f55\u3002\n\n## \u9ad8\u7ea7\u7528\u6cd5\n\n### \u63a8\u7406\u6a21\u578b\n\nOpenClaw \u9ed8\u8ba4\u4f1a\u5c06\u540d\u79f0\u4e2d\u5305\u542b `deepseek-r1`\u3001`reasoning` \u6216 `think` \u7684\u6a21\u578b\u89c6\u4e3a\u652f\u6301\u63a8\u7406\u7684\u6a21\u578b\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\nollama pull deepseek-r1:32b\n<\/code><\/pre>\n<h3>\u6a21\u578b\u6210\u672c<\/h3>\n<p>Ollama \u662f\u514d\u8d39\u7684\uff0c\u5e76\u4e14\u5728\u672c\u5730\u8fd0\u884c\uff0c\u56e0\u6b64\u6240\u6709\u6a21\u578b\u6210\u672c\u90fd\u8bbe\u7f6e\u4e3a $0\u3002<\/p>\n<h3>\u6d41\u5f0f\u4f20\u8f93\u914d\u7f6e<\/h3>\n<p>OpenClaw \u7684 Ollama \u96c6\u6210\u9ed8\u8ba4\u4f7f\u7528 <strong>\u539f\u751f Ollama API<\/strong>\uff08<code>\/api\/chat<\/code>\uff09\uff0c\u5b83\u5b8c\u5168\u652f\u6301\u540c\u65f6\u8fdb\u884c\u6d41\u5f0f\u4f20\u8f93\u548c\u5de5\u5177\u8c03\u7528\u3002\u65e0\u9700\u4efb\u4f55\u7279\u6b8a\u914d\u7f6e\u3002<\/p>\n<h4>\u65e7\u7248 OpenAI \u517c\u5bb9\u6a21\u5f0f<\/h4>\n<p>\n  <strong>\u5728 OpenAI \u517c\u5bb9\u6a21\u5f0f\u4e0b\uff0c\u5de5\u5177\u8c03\u7528\u5e76\u4e0d\u53ef\u9760\u3002<\/strong> \u53ea\u6709\u5f53\u4f60\u9700\u8981\u4e3a\u4ee3\u7406\u4f7f\u7528 OpenAI \u683c\u5f0f\uff0c\u5e76\u4e14\u4e0d\u4f9d\u8d56\u539f\u751f\u5de5\u5177\u8c03\u7528\u884c\u4e3a\u65f6\uff0c\u624d\u4f7f\u7528\u8fd9\u79cd\u6a21\u5f0f\u3002\n<\/p>\n<p>\u5982\u679c\u4f60\u786e\u5b9e\u9700\u8981\u6539\u7528 OpenAI \u517c\u5bb9\u7aef\u70b9\uff08\u4f8b\u5982\uff0c\u5728\u53ea\u652f\u6301 OpenAI \u683c\u5f0f\u7684\u4ee3\u7406\u4e4b\u540e\uff09\uff0c\u8bf7\u663e\u5f0f\u8bbe\u7f6e <code>api: \"openai-completions\"<\/code>\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  models: {<br \/>\n    providers: {<br \/>\n      ollama: {<br \/>\n        baseUrl: &#8220;http:\/\/ollama-host:11434\/v1&#8221;,<br \/>\n        api: &#8220;openai-completions&#8221;,<br \/>\n        injectNumCtxForOpenAICompat: true, \/\/ \u9ed8\u8ba4\uff1atrue<br \/>\n        apiKey: &#8220;ollama-local&#8221;,<br \/>\n        models: [&#8230;]<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<pre><code>\n\u8fd9\u79cd\u6a21\u5f0f\u53ef\u80fd\u4e0d\u652f\u6301\u540c\u65f6\u8fdb\u884c\u6d41\u5f0f\u4f20\u8f93 + \u5de5\u5177\u8c03\u7528\u3002\u4f60\u53ef\u80fd\u9700\u8981\u5728\u6a21\u578b\u914d\u7f6e\u4e2d\u901a\u8fc7 `params: { streaming: false }` \u7981\u7528\u6d41\u5f0f\u4f20\u8f93\u3002\n\n\u5f53 Ollama \u4f7f\u7528 `api: &quot;openai-completions&quot;` \u65f6\uff0cOpenClaw \u9ed8\u8ba4\u4f1a\u6ce8\u5165 `options.num_ctx`\uff0c\u8fd9\u6837 Ollama \u5c31\u4e0d\u4f1a\u9759\u9ed8\u56de\u9000\u5230 4096 \u4e0a\u4e0b\u6587\u7a97\u53e3\u3002\u5982\u679c\u4f60\u7684\u4ee3\u7406\/\u4e0a\u6e38\u62d2\u7edd\u672a\u77e5\u7684 `options` \u5b57\u6bb5\uff0c\u8bf7\u7981\u7528\u6b64\u884c\u4e3a\uff1a\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  models: {\n    providers: {\n      ollama: {\n        baseUrl: &quot;http:\/\/ollama-host:11434\/v1&quot;,\n        api: &quot;openai-completions&quot;,\n        injectNumCtxForOpenAICompat: false,\n        apiKey: &quot;ollama-local&quot;,\n        models: [...]\n      }\n    }\n  }\n}\n<\/code><\/pre>\n<h3>\u4e0a\u4e0b\u6587\u7a97\u53e3<\/h3>\n<p>\u5bf9\u4e8e\u81ea\u52a8\u53d1\u73b0\u7684\u6a21\u578b\uff0cOpenClaw \u4f1a\u5728 Ollama \u63d0\u4f9b\u65f6\u4f7f\u7528\u5176\u62a5\u544a\u7684\u4e0a\u4e0b\u6587\u7a97\u53e3\uff0c\u5426\u5219\u56de\u9000\u5230 OpenClaw \u4f7f\u7528\u7684\u9ed8\u8ba4 Ollama \u4e0a\u4e0b\u6587\u7a97\u53e3\u3002\u4f60\u53ef\u4ee5\u5728\u663e\u5f0f\u63d0\u4f9b\u5546\u914d\u7f6e\u4e2d\u8986\u76d6 <code>contextWindow<\/code> \u548c <code>maxTokens<\/code>\u3002<\/p>\n<h2>\u6545\u969c\u6392\u9664<\/h2>\n<h3>\u672a\u68c0\u6d4b\u5230 Ollama<\/h3>\n<p>\u8bf7\u786e\u8ba4 Ollama \u6b63\u5728\u8fd0\u884c\uff0c\u5e76\u4e14\u4f60\u5df2\u8bbe\u7f6e <code>OLLAMA_API_KEY<\/code>\uff08\u6216\u51ed\u8bc1\u914d\u7f6e\u6587\u4ef6\uff09\uff0c\u800c\u4e14<strong>\u6ca1\u6709<\/strong>\u5b9a\u4e49\u663e\u5f0f\u7684 <code>models.providers.ollama<\/code> \u6761\u76ee\uff1a<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nollama serve<\/p>\n<pre><code>\n\u5e76\u786e\u8ba4 API \u53ef\u8bbf\u95ee\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\ncurl http:\/\/localhost:11434\/api\/tags\n<\/code><\/pre>\n<h3>\u6ca1\u6709\u53ef\u7528\u6a21\u578b<\/h3>\n<p>\u5982\u679c\u6ca1\u6709\u5217\u51fa\u4f60\u7684\u6a21\u578b\uff0c\u53ef\u4ee5\uff1a<\/p>\n<ul>\n<li>\u5728\u672c\u5730\u62c9\u53d6\u8be5\u6a21\u578b\uff0c\u6216\u8005<\/li>\n<li>\u5728 <code>models.providers.ollama<\/code> \u4e2d\u663e\u5f0f\u5b9a\u4e49\u8be5\u6a21\u578b\u3002<\/li>\n<\/ul>\n<p>\u6dfb\u52a0\u6a21\u578b\uff1a<\/p>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nollama list  # \u67e5\u770b\u5df2\u5b89\u88c5\u7684\u6a21\u578b<br \/>\nollama pull glm-4.7-flash<br \/>\nollama pull gpt-oss:20b<br \/>\nollama pull llama3.3     # \u6216\u5176\u4ed6\u6a21\u578b<\/p>\n<pre><code>\n### \u8fde\u63a5\u88ab\u62d2\u7edd\n\n\u68c0\u67e5 Ollama \u662f\u5426\u6b63\u5728\u6b63\u786e\u7684\u7aef\u53e3\u4e0a\u8fd0\u884c\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n# \u68c0\u67e5 Ollama \u662f\u5426\u6b63\u5728\u8fd0\u884c\nps aux | grep ollama\n\n# \u6216\u91cd\u542f Ollama\nollama serve\n<\/code><\/pre>\n<h2>\u53e6\u8bf7\u53c2\u9605<\/h2>\n<ul>\n<li><a href=\"\/concepts\/model-providers\">Model Providers<\/a> &#8211; \u6240\u6709\u63d0\u4f9b\u5546\u7684\u6982\u89c8<\/li>\n<li><a href=\"\/concepts\/models\">Model Selection<\/a> &#8211; \u5982\u4f55\u9009\u62e9\u6a21\u578b<\/li>\n<li><a href=\"\/gateway\/configuration\">Configuration<\/a> &#8211; \u5b8c\u6574\u914d\u7f6e\u53c2\u8003<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ollama Ollama \u662f\u4e00\u4e2a\u672c\u5730 LLM \u8fd0\u884c\u65f6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u5728\u81ea\u5df1\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u5f00\u6e90\u6a21\u578b\u3002OpenCla [&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-227","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/227","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=227"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions\/522"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}