{"id":115470,"date":"2026-10-12T08:33:01","date_gmt":"2026-10-12T00:33:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115470.html"},"modified":"2026-10-12T08:33:01","modified_gmt":"2026-10-12T00:33:01","slug":"%e4%bd%bf%e7%94%a8-python-%e8%b0%83%e7%94%a8-apple-%e7%ab%af%e4%be%a7-foundation-model%ef%bc%9aapfel-%e6%9c%ac%e5%9c%b0-openai-%e5%85%bc%e5%ae%b9%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%9e%e6%88%98%e6%8c%87","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115470.html","title":{"rendered":"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357"},"content":{"rendered":"<h3 class=\"gcb-project-title\">\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011apfel<\/h3>\n<p class=\"gcb-project-desc\">The free AI already on your Mac. CLI tool, OpenAI-compatible server, and interactive chat \u2014 all on-device via Apple Intelligence. No API keys, no cloud, no downloads.<\/p>\n<p>    <span class=\"gcb-project-addr-label\">\u9879\u76ee\u5730\u5740&#xff1a;<\/span><br \/>\n    <span class=\"gcb-project-addr-link\">https:\/\/gitcode.com\/gh_mirrors\/apfe\/apfel<\/span> <\/p>\n<p>  <span class=\"gcb-project-btn\"> <span class=\"gcb-project-btn-main\">\u70b9\u51fb\u67e5\u770b<\/span> <span class=\"gcb-project-btn-sub\">\u514d\u8d39\u4e0b\u8f7d<\/span> <\/span> <\/p>\n<p>\u5bfc\u8bfb&#xff1a;\u672c\u6587\u4ee5 docs\/guides\/python.md \u4e3a\u6838\u5fc3&#xff0c;\u5b8c\u6574\u8bb2\u89e3\u5982\u4f55\u7528\u5b98\u65b9 openai Python SDK \u5bf9\u63a5\u672c\u5730\u8fd0\u884c\u7684 apfel &#8211;serve&#xff0c;\u8ba9 Apple \u7aef\u4fa7 Foundation Model \u901a\u8fc7 OpenAI \u517c\u5bb9\u7684 http:\/\/localhost:11434\/v1 \u63a5\u53e3\u4e3a AI\/ML \u811a\u672c\u3001\u6570\u636e\u5de5\u5177\u548c\u540e\u7aef\u670d\u52a1\u63d0\u4f9b\u63a8\u7406\u80fd\u529b\u2014\u2014100% \u7aef\u4fa7\u6267\u884c\u3001\u96f6 API \u8d39\u7528\u3001\u63a8\u7406\u8fc7\u7a0b\u65e0\u9700\u8054\u7f51\u3002\u8bfb\u5b8c\u672c\u6587&#xff0c;\u4f60\u5c06\u638c\u63e1\u4e00\u6b21\u6027\u5bf9\u8bdd\u8865\u5168\u3001\u6d41\u5f0f\u8f93\u51fa\u3001JSON \u7ed3\u6784\u5316\u8f93\u51fa\u3001\u9519\u8bef\u5904\u7406\u3001\u5de5\u5177\u8c03\u7528&#xff08;function calling&#xff09;\u4ee5\u53ca&#034;\u4ece stdin \u8bfb\u53d6\u6587\u4ef6\u505a\u6458\u8981&#034;\u8fd9\u516d\u79cd\u5f00\u7bb1\u5373\u7528\u7684\u5b9e\u6218\u6a21\u5f0f&#xff0c;\u5e76\u4e86\u89e3\u6bcf\u6761\u6a21\u5f0f\u80cc\u540e\u5728 apfel \u4ed3\u5e93\u4e2d\u7684\u5b9e\u73b0\u4f9d\u636e\u3002<\/p>\n<h3>\u8fd0\u884c\u524d\u63d0&#xff1a;\u8f6f\u786c\u4ef6\u4e0e\u670d\u52a1\u5668\u51c6\u5907<\/h3>\n<p>\u6309\u7167 docs\/guides\/python.md \u7684\u8981\u6c42&#xff0c;\u4f7f\u7528\u524d\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff1a;<\/p>\n<table>\n<tr>\u524d\u63d0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>macOS 26&#043; Tahoe\u3001Apple Silicon<\/td>\n<td>\u7aef\u4fa7 Foundation Model \u4f9d\u8d56 Apple Intelligence \u6846\u67b6<\/td>\n<\/tr>\n<tr>\n<td>Apple Intelligence \u5df2\u5f00\u542f<\/td>\n<td>System Settings -&gt; Apple Intelligence &amp; Siri<\/td>\n<\/tr>\n<tr>\n<td>brew install apfel<\/td>\n<td>\u5b89\u88c5 apfel CLI<\/td>\n<\/tr>\n<tr>\n<td>apfel &#8211;serve \u6b63\u5728\u8fd0\u884c<\/td>\n<td>\u9ed8\u8ba4\u7aef\u53e3 11434<\/td>\n<\/tr>\n<tr>\n<td>Python 3.11&#043;<\/td>\n<td>SDK \u8fd0\u884c\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>pip install openai&#xff08;\u6216 uv add openai&#xff09;<\/td>\n<td>OpenAI \u5b98\u65b9 Python SDK<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>apfel \u7684 &#8211;serve \u6a21\u5f0f\u5728\u6e90\u7801\u5c42\u9762\u6709\u660e\u786e\u4f50\u8bc1&#xff1a;Sources\/CLI\/CLIArguments.swift \u4e2d serverPort \u9ed8\u8ba4\u503c\u4e3a 11434\u3001serverHost \u9ed8\u8ba4\u503c\u4e3a 127.0.0.1&#xff0c;\u56e0\u6b64 SDK \u6307\u5411 http:\/\/localhost:11434\/v1 \u5373\u53ef\u3002\u540c\u65f6\u8be5\u6587\u4ef6\u663e\u793a\u7aef\u53e3\u53ef\u901a\u8fc7 &#8211;port \u53c2\u6570\u6216 APFEL_PORT \u73af\u5883\u53d8\u91cf\u8986\u76d6&#xff08;\u975e\u6cd5\u503c\u4f1a\u88ab\u5ffd\u7565\u5e76\u8bb0\u5f55\u8b66\u544a&#xff0c;\u800c\u4e0d\u662f\u9759\u9ed8\u751f\u6548&#xff09;&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>apfel &#8211;serve &#8211;port 3000 &#8211;host 0.0.0.0 &#8211;cors<\/p>\n<p>\u670d\u52a1\u5668\u542f\u52a8\u540e&#xff0c;\u5efa\u8bae\u5148\u505a\u4e00\u6b21\u5065\u5eb7\u68c0\u67e5&#xff1a;<\/p>\n<p>apfel &#8211;serve &amp;<br \/>\ncurl -s http:\/\/localhost:11434\/health<br \/>\n# {&#034;status&#034;:&#034;ok&#034;}<\/p>\n<p>\/health \u7aef\u70b9\u7531 Sources\/Server.swift \u5b9e\u73b0&#xff0c;\u9664 status \u5916\u8fd8\u4f1a\u8fd4\u56de model\u3001version\u3001context_window\u3001context_window_measured\u3001capabilities\u3001supported_languages \u7b49\u5b57\u6bb5&#xff1b;\/v1\/models \u5219\u4f1a\u5217\u51fa apple-foundationmodel \u53ca\u5176\u652f\u6301\u7684\u53c2\u6570\u6e05\u5355&#xff08;\u89c1\u4e0b\u6587&#034;\u80fd\u529b\u8fb9\u754c&#034;&#xff09;\u3002<\/p>\n<h3>1. \u4e00\u6b21\u6027\u5bf9\u8bdd\u8865\u5168&#xff08;One-shot chat completion&#xff09;<\/h3>\n<p>\u628a openai SDK \u7684 base_url \u6307\u5411\u672c\u5730 apfel \u670d\u52a1\u5668&#xff0c;\u5373\u53ef\u8c03\u7528 chat.completions.create&#xff1a;<\/p>\n<p>from openai import OpenAI<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>response &#061; client.chat.completions.create(<br \/>\n    model&#061;&#034;apple-foundationmodel&#034;,<br \/>\n    messages&#061;[<br \/>\n        {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: &#034;In one sentence, what is the Swift programming language?&#034;},<br \/>\n    ],<br \/>\n    max_tokens&#061;80,<br \/>\n)<\/p>\n<p>print((response.choices[0].message.content or &#034;&#034;).strip())<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff1a;<\/p>\n<p>Swift is a modern, high-performance, and safe programming language developed by Apple for developing iOS, macOS, watchOS, and tvOS applications.<\/p>\n<p>\u51e0\u70b9\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>api_key&#061;&#034;not-needed&#034; \u662f\u5360\u4f4d\u503c&#xff1a;apfel \u9ed8\u8ba4\u4e0d\u6821\u9a8c Authorization \u5934\u3002\u53ea\u6709\u5f53\u670d\u52a1\u5668\u4ee5 &#8211;token \u542f\u52a8&#xff08;\u6216\u7528 APFEL_TOKEN \u73af\u5883\u53d8\u91cf&#xff09;\u65f6&#xff0c;SDK \u624d\u9700\u8981\u4f20\u5165\u771f\u5b9e\u4ee4\u724c&#xff0c;\u5177\u4f53\u89c1 docs\/server-security.md\u3002<\/li>\n<li>model \u56fa\u5b9a\u4e3a apple-foundationmodel&#xff0c;\u4e0e \/v1\/models \u8fd4\u56de\u7684\u6a21\u578b ID \u4e00\u81f4&#xff08;\u89c1 Sources\/Server.swift&#xff09;\u3002<\/li>\n<li>\u7701\u7565 max_tokens \u65f6&#xff0c;apfel \u91c7\u7528 OpenAI \u8bed\u4e49&#034;\u4f7f\u7528\u5269\u4f59\u4e0a\u4e0b\u6587\u7a97\u53e3&#034;&#xff1b;\u82e5\u663e\u5f0f\u4f20\u5165&#xff0c;\u5219\u6309\u4f60\u7684\u9884\u7b97\u622a\u65ad&#xff0c;\u89e6\u9876\u65f6\u8fd4\u56de finish_reason: &#034;length&#034; \u548c\u90e8\u5206\u5185\u5bb9&#xff08;HTTP 200&#xff09;\u3002\u5b8c\u6574\u53c2\u6570\u6620\u5c04\u89c1 docs\/openai-api-compatibility.md\u3002<\/li>\n<li>\u4ed3\u5e93\u96c6\u6210\u6d4b\u8bd5 Tests\/integration\/openai_client_test.py \u4e2d\u7684 test_basic_completion\u3001test_system_prompt\u3001test_multi_turn_history \u9a8c\u8bc1\u4e86\u975e\u6d41\u5f0f\u8865\u5168\u3001\u7cfb\u7edf\u63d0\u793a\u8bcd\u4e0e\u591a\u8f6e\u5386\u53f2\u573a\u666f\u3002<\/li>\n<\/ul>\n<h3>2. \u6d41\u5f0f\u8f93\u51fa&#xff08;Streaming&#xff09;<\/h3>\n<p>\u4f20\u5165 stream&#061;True \u5e76\u8fed\u4ee3 chunk\u3002\u6ce8\u610f&#xff1a;\u5f53\u542f\u7528 stream_options: {&#034;include_usage&#034;: true} \u65f6&#xff0c;\u6700\u7ec8\u4f1a\u591a\u51fa\u4e00\u4e2a choices \u4e3a\u7a7a\u7684 usage chunk&#xff0c;\u56e0\u6b64\u4ee3\u7801\u5fc5\u987b\u5bf9\u7a7a choices \u505a\u9632\u62a4&#xff1a;<\/p>\n<p>import sys<br \/>\nfrom openai import OpenAI<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>stream &#061; client.chat.completions.create(<br \/>\n    model&#061;&#034;apple-foundationmodel&#034;,<br \/>\n    messages&#061;[{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: &#034;List three Apple silicon chips, one per line.&#034;}],<br \/>\n    max_tokens&#061;80,<br \/>\n    stream&#061;True,<br \/>\n)<\/p>\n<p>for chunk in stream:<br \/>\n    if not chunk.choices:<br \/>\n        continue<br \/>\n    delta &#061; chunk.choices[0].delta.content or &#034;&#034;<br \/>\n    sys.stdout.write(delta)<br \/>\n    sys.stdout.flush()<br \/>\nprint()<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff1a;<\/p>\n<p>Apple M1<br \/>\nApple M2<br \/>\nApple M3<\/p>\n<p>\u4ece\u534f\u8bae\u5b9e\u73b0\u770b&#xff0c;\u6d41\u5f0f\u54cd\u5e94\u4ee5 SSE&#xff08;Server-Sent Events&#xff09;\u4f20\u8f93&#xff0c;finish_reason \u652f\u6301 stop\u3001tool_calls\u3001length&#xff1b;stream_options.include_usage \u4e3a\u53ef\u9009\u5f00\u5173&#xff0c;\u5f00\u542f\u540e\u624d\u4f1a\u5728 [DONE] \u4e4b\u524d\u53d1\u9001\u7a7a choices \u7684 usage chunk&#xff08;\u89c1 docs\/openai-api-compatibility.md \u7684\u517c\u5bb9\u6027\u8868\u683c&#xff09;\u3002SDK \u4fa7\u7684\u7f16\u89e3\u7801\u5728 Tests\/apfelTests\/OpenAIWireFormatTests.swift \u4e2d\u6709\u5bf9\u5e94\u65ad\u8a00&#xff08;stream\u3001stream_options.include_usage\u3001response_format \u5747\u53ef\u6b63\u786e\u89e3\u6790&#xff09;&#xff0c;\u96c6\u6210\u6d4b\u8bd5 Tests\/integration\/openai_client_test.py \u7684 test_streaming \u4e5f\u8986\u76d6\u4e86\u8be5\u6d41\u7a0b\u3002<\/p>\n<h3>3. JSON \u6a21\u5f0f \/ \u7ed3\u6784\u5316\u8f93\u51fa<\/h3>\n<p>\u8bf7\u6c42 response_format: {&#034;type&#034;: &#034;json_object&#034;} \u5e76\u6309 JSON \u89e3\u6790\u3002\u4e00\u4e2a\u5e38\u89c1\u5751\u662f&#xff1a;apfel \u5076\u5c14\u4f1a\u628a JSON \u5305\u5728 markdown \u4ee3\u7801\u56f4\u680f\u91cc&#xff0c;\u56e0\u6b64\u6587\u6863\u7ed9\u51fa\u4e86\u4e00\u884c\u56f4\u680f\u5265\u79bb\u6b63\u5219&#xff0c;\u4e24\u79cd\u60c5\u5f62\u90fd\u80fd\u5e72\u51c0\u5904\u7406&#xff1a;<\/p>\n<p>import json, re<br \/>\nfrom openai import OpenAI<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>response &#061; client.chat.completions.create(<br \/>\n    model&#061;&#034;apple-foundationmodel&#034;,<br \/>\n    messages&#061;[{<br \/>\n        &#034;role&#034;: &#034;user&#034;,<br \/>\n        &#034;content&#034;: &#034;Return JSON with fields &#039;chip&#039;, &#039;year&#039;, &#039;cores&#039;. Describe the Apple M1 chip. Return ONLY JSON.&#034;,<br \/>\n    }],<br \/>\n    response_format&#061;{&#034;type&#034;: &#034;json_object&#034;},<br \/>\n    max_tokens&#061;120,<br \/>\n)<\/p>\n<p>raw &#061; (response.choices[0].message.content or &#034;&#034;).strip()<br \/>\nraw &#061; re.sub(r&#034;^&#096;&#096;&#096;(?:json)?\\\\s*|\\\\s*&#096;&#096;&#096;$&#034;, &#034;&#034;, raw, flags&#061;re.MULTILINE).strip()<br \/>\ndata &#061; json.loads(raw)<br \/>\nprint(json.dumps(data, indent&#061;2, sort_keys&#061;True))<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;chip&#034;: &#034;Apple M1&#034;,<br \/>\n  &#034;cores&#034;: 8,<br \/>\n  &#034;year&#034;: 2020<br \/>\n}<\/p>\n<p>\u5173\u4e8e\u56f4\u680f\u5265\u79bb&#xff0c;\u4ed3\u5e93\u91cc\u5176\u5b9e\u5185\u7f6e\u4e86\u6bd4\u8fd9\u4e2a\u6b63\u5219\u66f4\u7cbe\u7ec6\u7684\u5b9e\u73b0&#xff1a;Sources\/Core\/JSONFenceStripper.swift \u4e2d\u7684 JSONFenceStripper.strip(_:) \u53ea\u5265\u79bb&#034;\u4ee5\u4e09\u53cd\u5f15\u53f7\u5f00\u5934\u4e14\u56f4\u680f\u6807\u7b7e\u4e3a\u7a7a\u6216\u4e3a json&#034;\u7684\u5757&#xff0c;\u800c\u4e0d\u4f1a\u8bef\u4f24 &#096;&#096;&#096;python &#8230; &#096;&#096;&#096; \u8fd9\u7c7b\u4ee3\u7801\u5757&#xff1b;OpenAI \u89c4\u8303\u8981\u6c42 json_object \u6a21\u5f0f\u4e0b message content \u5fc5\u987b\u662f\u5408\u6cd5 JSON&#xff0c;\u56e0\u6b64\u670d\u52a1\u7aef\u4f1a\u5148\u505a\u540e\u5904\u7406\u518d\u8fd4\u56de\u539f\u59cb JSON\u3002\u4e5f\u5c31\u662f\u8bf4&#xff1a;\u5373\u4fbf\u4f60\u5728\u5ba2\u6237\u7aef\u4e0d\u505a\u4efb\u4f55\u5265\u79bb&#xff0c;apfel \u8fd4\u56de\u7684 content \u4e5f\u5df2\u7ecf\u662f\u5e72\u51c0 JSON&#xff1b;\u6587\u6863\u4fdd\u7559\u8fd9\u884c\u6b63\u5219\u662f\u4e3a\u4e86\u517c\u5bb9\u66f4\u65e9\u7248\u672c\u6216\u76f4\u63a5\u900f\u4f20\u7684\u539f\u59cb\u6d41\u3002\u53e6\u5916&#xff0c;\u82e5\u9700\u8981\u66f4\u5f3a\u7ea6\u675f\u7684\u7ed3\u6784\u5316\u8f93\u51fa&#xff08;\u4fdd\u8bc1\u7b26\u5408\u7ed9\u5b9a JSON Schema&#xff09;&#xff0c;apfel \u8fd8\u652f\u6301 response_format: {&#034;type&#034;: &#034;json_schema&#034;, &#8230;} \u4ee5\u53ca CLI \u4fa7 apfel &#8211;schema file.json&#xff0c;\u5177\u4f53\u652f\u6301\/\u62d2\u7edd\u7684\u5173\u952e\u5b57\u6e05\u5355\u89c1 docs\/openai-api-compatibility.md\u3002<\/p>\n<h3>4. \u9519\u8bef\u5904\u7406&#xff1a;apfel \u5bf9\u4e0d\u652f\u6301\u7684\u80fd\u529b\u8fd4\u56de\u8bda\u5b9e HTTP \u9519\u8bef<\/h3>\n<p>apfel \u5bf9\u672a\u5b9e\u73b0\u7684\u80fd\u529b\u4e0d\u4f1a\u5047\u88c5\u6210\u529f&#xff0c;\u800c\u662f\u8fd4\u56de\u660e\u786e\u7684 HTTP \u9519\u8bef\u7801\u3002\u5178\u578b\u4f8b\u5b50\u662f embeddings \u63a5\u53e3\u8fd4\u56de 501&#xff1a;<\/p>\n<p>from openai import APIStatusError, OpenAI<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>try:<br \/>\n    client.embeddings.create(<br \/>\n        model&#061;&#034;apple-foundationmodel&#034;,<br \/>\n        input&#061;&#034;apfel runs 100% on-device.&#034;,<br \/>\n    )<br \/>\nexcept APIStatusError as e:<br \/>\n    print(f&#034;Got expected error: HTTP {e.status_code} &#8211; {e.message}&#034;)<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff1a;<\/p>\n<p>Got expected error: HTTP 501 &#8211; Error code: 501 &#8211; {&#039;error&#039;: {&#039;message&#039;: &#034;Embeddings not supported by Apple&#039;s on-device model.&#034;, &#039;type&#039;: &#039;invalid_request_error&#039;}}<\/p>\n<p>\u8fd9\u6761 501 \u7531 Sources\/Server.swift \u76f4\u63a5\u8fd4\u56de&#xff0c;\u9519\u8bef\u6d88\u606f\u4e0e\u6587\u6863\u622a\u56fe\u5b8c\u5168\u4e00\u81f4&#xff1b;\u540c\u6587\u4ef6\u8fd8\u628a\u65e7\u7248 \/v1\/completions&#xff08;\u6587\u672c\u8865\u5168&#xff09;\u4e5f\u5b9a\u4e3a 501\u3002\u7ed3\u5408 docs\/openai-api-compatibility.md \u7684\u517c\u5bb9\u6027\u8868\u683c&#xff0c;apfel \u7684\u80fd\u529b\u8fb9\u754c\u53ef\u4ee5\u5f52\u7eb3\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\u4e0d\u652f\u6301&#xff1a;embeddings&#xff08;501&#xff0c;\u7aef\u4fa7\u6a21\u578b\u6ca1\u6709\u5411\u91cf\u63a5\u53e3&#xff0c;\u53ef\u7528 sentence-transformers \u7b49\u5916\u90e8 embedder \u8865\u5145&#xff09;\u3001\u89c6\u89c9\/\u97f3\u9891&#xff08;macOS 26 \u4e0a\u56fe\u7247\u8f93\u5165\u8fd4\u56de 400&#xff09;\u3001logprobs&#061;true\u3001n&gt;1\u3001stop\u3001presence_penalty\u3001frequency_penalty&#xff08;\u8fd9\u4e9b\u663e\u5f0f\u8fd4\u56de 400&#xff1b;n&#061;1 \u4e0e logprobs&#061;false \u4f5c\u4e3a\u65e0\u64cd\u4f5c\u63a5\u53d7&#xff09;\u3001Responses API \u7684\u670d\u52a1\u7aef\u4f1a\u8bdd\u72b6\u6001&#xff08;previous_response_id\u3001store \u7b49\u4e3a 501&#xff09;\u3002<\/li>\n<li>\u652f\u6301&#xff1a;GET \/v1\/models\u3001GET \/health\u3001\u6d41\u5f0f\u4e0e\u975e\u6d41\u5f0f \/v1\/chat\/completions\u3001\/v1\/responses \u7ffb\u8bd1\u5c42\u3001\u5de5\u5177\u8c03\u7528\u3001json_object\/json_schema\u3001temperature\/top_p\/max_tokens\/seed\u3001\u4e0a\u4e0b\u6587\u7b56\u7565\u6269\u5c55\u5b57\u6bb5\u7b49\u3002<\/li>\n<\/ul>\n<p>\/v1\/models \u54cd\u5e94\u4e2d\u7684 unsupported_parameters \u5b57\u6bb5&#xff08;logprobs, n, stop, presence_penalty, frequency_penalty&#xff09;\u5c31\u662f\u4e3a\u5ba2\u6237\u7aef\u505a\u80fd\u529b\u63a2\u6d4b\u51c6\u5907\u7684&#xff0c;\u96c6\u6210\u6d4b\u8bd5 Tests\/integration\/openai_client_test.py \u4e5f\u9488\u5bf9 \/health \u4e0e\u6a21\u578b\u80fd\u529b\u505a\u4e86\u65ad\u8a00\u3002<\/p>\n<h3>5. \u5de5\u5177\u8c03\u7528&#xff08;Tool calling \/ function calling&#xff09;<\/h3>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u5de5\u5177 schema&#xff0c;\u53d1\u9001\u63d0\u793a\u8bcd&#xff0c;\u5904\u7406\u6a21\u578b\u8fd4\u56de\u7684 tool call&#xff0c;\u628a\u7ed3\u679c\u4ee5 role: &#034;tool&#034; \u56de\u586b&#xff0c;\u518d\u53d1\u8d77\u7b2c\u4e8c\u8f6e\u8bf7\u6c42\u62ff\u5230\u6700\u7ec8\u56de\u7b54\u2014\u2014\u8fd9\u662f\u6807\u51c6\u7684 OpenAI \u5de5\u5177\u8c03\u7528\u5f80\u8fd4&#xff1a;<\/p>\n<p>import json<br \/>\nfrom openai import OpenAI<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>TOOLS &#061; [{<br \/>\n    &#034;type&#034;: &#034;function&#034;,<br \/>\n    &#034;function&#034;: {<br \/>\n        &#034;name&#034;: &#034;get_weather&#034;,<br \/>\n        &#034;description&#034;: &#034;Get the current temperature in Celsius for a city.&#034;,<br \/>\n        &#034;parameters&#034;: {<br \/>\n            &#034;type&#034;: &#034;object&#034;,<br \/>\n            &#034;properties&#034;: {&#034;city&#034;: {&#034;type&#034;: &#034;string&#034;, &#034;description&#034;: &#034;City name&#034;}},<br \/>\n            &#034;required&#034;: [&#034;city&#034;],<br \/>\n        },<br \/>\n    },<br \/>\n}]<\/p>\n<p>def get_weather(city: str, **_: object) -&gt; str:<br \/>\n    fake &#061; {&#034;Vienna&#034;: 14, &#034;Cupertino&#034;: 19, &#034;Tokyo&#034;: 11}<br \/>\n    return json.dumps({&#034;city&#034;: city, &#034;temp_c&#034;: fake.get(city, 15)})<\/p>\n<p>messages &#061; [{&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: &#034;What is the temperature in Vienna right now?&#034;}]<\/p>\n<p>first &#061; client.chat.completions.create(<br \/>\n    model&#061;&#034;apple-foundationmodel&#034;, messages&#061;messages, tools&#061;TOOLS, max_tokens&#061;256,<br \/>\n)<\/p>\n<p>msg &#061; first.choices[0].message<br \/>\nmessages.append(msg.model_dump(exclude_none&#061;True))<\/p>\n<p>if msg.tool_calls:<br \/>\n    for call in msg.tool_calls:<br \/>\n        args &#061; json.loads(call.function.arguments)<br \/>\n        result &#061; get_weather(**args)<br \/>\n        messages.append({&#034;role&#034;: &#034;tool&#034;, &#034;tool_call_id&#034;: call.id, &#034;content&#034;: result})<\/p>\n<p>    final &#061; client.chat.completions.create(<br \/>\n        model&#061;&#034;apple-foundationmodel&#034;, messages&#061;messages, max_tokens&#061;120,<br \/>\n    )<br \/>\n    print((final.choices[0].message.content or &#034;&#034;).strip())<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff1a;<\/p>\n<p>The current temperature in Vienna is 14\u00b0C.<\/p>\n<p>\u4ece\u5b9e\u73b0\u89d2\u5ea6\u770b&#xff0c;apfel \u5bf9 tool_choice&#xff08;none\/auto\/required\/{&#034;type&#034;:&#034;function&#034;,&#8230;}&#xff09;\u4e0e parallel_tool_calls \u662f\u5728\u54cd\u5e94\u8fb9\u754c\u5f3a\u5236\u6267\u884c\u800c\u975e\u4ec5\u63d0\u793a\u5f15\u5bfc&#xff1b;macOS 27 \u4e0a auto\/none \u8fd8\u4f1a\u989d\u5916\u6620\u5c04\u5230\u8fd0\u884c\u65f6 ToolCallingMode\u3002\u76f8\u5173\u7684\u5de5\u5177\u8c03\u7528\u6307\u5357\u89c1 docs\/tool-calling-guide.md&#xff0c;\u6d41\u5f0f\u8def\u5f84\u4e0b\u7684\u5de5\u5177\u8c03\u7528\u9632\u6cc4\u6f0f\u56de\u5f52\u6d4b\u8bd5\u89c1\u96c6\u6210\u6d4b\u8bd5 test_streaming_tool_call_no_content_leak&#xff08;\u4fdd\u8bc1\u5ba2\u6237\u7aef\u7edd\u4e0d\u4f1a\u6536\u5230\u539f\u59cb\u5de5\u5177\u4e2d\u95f4\u5185\u5bb9&#xff09;\u3002\u53e6\u5916 apfel \u8fd8\u652f\u6301 &#8211;mcp \u6302\u8f7d\u672c\u5730\u6216\u8fdc\u7a0b MCP \u5de5\u5177\u670d\u52a1\u5668&#xff08;Sources\/CLI\/CLIArguments.swift \u4e2d &#8211;mcp\u3001&#8211;mcp-timeout\u3001&#8211;mcp-token \u5747\u6709\u5bf9\u5e94\u5b9e\u73b0&#xff09;&#xff0c;CLI \u4e0e\u670d\u52a1\u5668\u4e24\u4fa7\u53ef\u5171\u7528\u540c\u4e00\u5957\u5de5\u5177\u6267\u884c\u7ba1\u7ebf\u3002<\/p>\n<h3>6. \u5b9e\u6218\u793a\u4f8b&#xff1a;\u4ece stdin \u8bfb\u53d6\u6587\u4ef6\u5e76\u505a\u6458\u8981<\/h3>\n<p>\u628a\u524d\u4e94\u79cd\u6a21\u5f0f\u7ec4\u5408\u6210\u771f\u5b9e\u811a\u672c&#xff1a;\u8bfb\u53d6 stdin \u6587\u672c \u2192 \u7528\u7cfb\u7edf\u63d0\u793a\u8bcd\u7ea6\u675f\u8f93\u51fa\u683c\u5f0f \u2192 \u6253\u5370\u5355\u6bb5\u6458\u8981&#xff1a;<\/p>\n<p>import sys<br \/>\nfrom openai import OpenAI<\/p>\n<p>text &#061; sys.stdin.read().strip()<br \/>\nif not text:<br \/>\n    sys.exit(&#034;usage: cat file.txt | python 06_example.py&#034;)<\/p>\n<p>client &#061; OpenAI(base_url&#061;&#034;http:\/\/localhost:11434\/v1&#034;, api_key&#061;&#034;not-needed&#034;)<\/p>\n<p>response &#061; client.chat.completions.create(<br \/>\n    model&#061;&#034;apple-foundationmodel&#034;,<br \/>\n    messages&#061;[<br \/>\n        {&#034;role&#034;: &#034;system&#034;, &#034;content&#034;: &#034;You are a concise summarizer. Reply with one short paragraph.&#034;},<br \/>\n        {&#034;role&#034;: &#034;user&#034;, &#034;content&#034;: f&#034;Summarize:\\\\n\\\\n{text}&#034;},<br \/>\n    ],<br \/>\n    max_tokens&#061;150,<br \/>\n)<br \/>\nprint((response.choices[0].message.content or &#034;&#034;).strip())<\/p>\n<p>\u8fd0\u884c\u65b9\u5f0f&#xff1a;<\/p>\n<p>cat README.md | python 06_example.py<\/p>\n<p>\u771f\u5b9e\u8f93\u51fa&#xff08;\u5bf9\u4e00\u6bb5\u5173\u4e8e M1 \u82af\u7247\u7684\u6bb5\u843d\u505a\u6458\u8981&#xff09;&#xff1a;<\/p>\n<p>The Apple M1 chip, released in November 2020, was Apple&#039;s first ARM-based system-on-a-chip for Mac computers. It features an 8-core CPU with four performance and four efficiency cores, plus an integrated GPU with up to 8 cores. The chip combines CPU, GPU, memory, and neural engine on a single die, delivering significant performance-per-watt improvements over the Intel chips it replaced.<\/p>\n<p>\u8fd9\u6bb5\u811a\u672c\u5c55\u793a\u4e86\u7aef\u4fa7\u6a21\u578b\u7528\u4e8e&#034;\u672c\u5730\u6587\u6863\u5feb\u901f\u6458\u8981&#034;\u7684\u6700\u5c0f\u53ef\u7528\u5f62\u6001&#xff1a;\u628a\u6587\u4ef6\u5185\u5bb9\u62fc\u8fdb user \u6d88\u606f&#xff0c;\u914d\u5408 system \u63d0\u793a\u8bcd\u7ea6\u675f\u98ce\u683c&#xff0c;max_tokens \u63a7\u5236\u8f93\u51fa\u957f\u5ea6\u3002\u540c\u6837\u7684\u7ba1\u9053\u6a21\u5f0f\u53ef\u4ee5\u6269\u5c55\u4e3a\u6279\u91cf\u5904\u7406\u65e5\u5fd7\u3001\u4ee3\u7801\u8bc4\u5ba1\u8349\u7a3f\u7b49\u672c\u5730\u4efb\u52a1&#xff0c;\u5168\u7a0b\u4e0d\u51fa\u7f51\u3002<\/p>\n<h3>\u6545\u969c\u6392\u67e5&#xff08;Troubleshooting&#xff09;<\/h3>\n<table>\n<tr>\u73b0\u8c61\u539f\u56e0\u4e0e\u5bf9\u7b56<\/tr>\n<tbody>\n<tr>\n<td>11434 \u7aef\u53e3 Connection refused<\/td>\n<td>\u670d\u52a1\u5668\u6ca1\u542f\u52a8\u3002\u5148\u8fd0\u884c apfel &#8211;serve&#xff1b;\u82e5\u6362\u4e86\u7aef\u53e3&#xff0c;SDK \u7684 base_url \u8981\u540c\u6b65\u6539<\/td>\n<\/tr>\n<tr>\n<td>Embeddings not supported<\/td>\n<td>apfel \u4ec5\u6587\u672c\u80fd\u529b&#xff0c;\u5411\u91cf\u8bf7\u6539\u7528 sentence-transformers \u7b49\u5916\u90e8 embedder<\/td>\n<\/tr>\n<tr>\n<td>JSON \u6a21\u5f0f\u4e0b JSONDecodeError<\/td>\n<td>\u4fdd\u7559\u56f4\u680f\u5265\u79bb\u6b63\u5219&#xff1b;apfel \u6709\u65f6\u4f1a\u628a JSON \u5305\u5728 &#096;&#096;&#096;json &#8230; &#096;&#096;&#096; \u91cc&#xff08;\u670d\u52a1\u7aef\u5df2\u5185\u7f6e\u5265\u79bb&#xff0c;\u89c1 Sources\/Core\/JSONFenceStripper.swift&#xff0c;\u5ba2\u6237\u7aef\u6b63\u5219\u53ef\u4f5c\u53cc\u4fdd\u9669&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6d41\u5f0f\u8f93\u51fa\u4e3a\u7a7a<\/td>\n<td>\u786e\u8ba4\u5ba2\u6237\u7aef\u5904\u7406\u4e86\u672b\u5c3e\u7a7a choices \u7684 usage chunk&#xff0c;if not chunk.choices: continue \u5373\u53ef\u8986\u76d6<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u578b\u62d2\u7edd\u5de5\u5177\u8c03\u7528<\/td>\n<td>\u5c0f\u5c3a\u5bf8\u7aef\u4fa7\u6a21\u578b\u5076\u5c14\u4f1a\u62d2\u7edd\u6267\u884c\u5de5\u5177&#xff0c;\u76f4\u63a5\u91cd\u8bd5\u6574\u6b21\u8c03\u7528\u5373\u53ef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u7248\u672c\u4e0e\u6d4b\u8bd5\u73af\u5883<\/h3>\n<p>\u6587\u6863\u8bb0\u5f55\u8be5\u6307\u5357\u6700\u521d\u5b9e\u6d4b\u4e8e\u4ee5\u4e0b\u73af\u5883&#xff0c;\u4e14\u540e\u7eed\u6bcf\u4e2a\u7248\u672c\u90fd\u53d7 apfel \u6d4b\u8bd5\u5957\u4ef6\u95e8\u7981\u4fdd\u62a4&#xff08;CLI \u4e0e HTTP \u8868\u9762\u884c\u4e3a\u7a33\u5b9a&#xff09;&#xff1a;<\/p>\n<ul>\n<li>apfel v1.0.3&#xff08;\u539f\u59cb\u6355\u83b7\u7248\u672c&#xff1b;CLI \u4e0e HTTP \u63a5\u53e3\u7531 apfel \u6d4b\u8bd5\u5957\u4ef6\u5728\u6bcf\u4e2a\u7248\u672c\u4e0a\u628a\u5173&#xff09;<\/li>\n<li>macOS 26.3.1\u3001Apple Silicon<\/li>\n<li>Python 3.11 \/ openai 2.31.0<\/li>\n<li>\u65e5\u671f&#xff1a;2026-04-16<\/li>\n<\/ul>\n<p>\u4ed3\u5e93\u5185\u53ef\u590d\u73b0\u7684\u7b49\u4ef7\u6d4b\u8bd5\u5305\u62ec&#xff1a;\u96c6\u6210\u6d4b\u8bd5 Tests\/integration\/openai_client_test.py&#xff08;\u57fa\u672c\u8865\u5168\u3001\u6d41\u5f0f\u3001\u591a\u8f6e\u3001\u7cfb\u7edf\u63d0\u793a\u8bcd\u3001\u5de5\u5177\u8c03\u7528\u3001\u6d41\u5f0f\u5de5\u5177\u8c03\u7528\u9632\u6cc4\u6f0f\u7b49&#xff09;\u4e0e\u5355\u5143\u6d4b\u8bd5 Tests\/apfelTests\/OpenAIWireFormatTests.swift&#xff08;\u8bf7\u6c42\/\u54cd\u5e94\u683c\u5f0f\u89e3\u7801&#xff09;\u3002\u82e5\u60f3\u5728\u672c\u673a\u91cd\u65b0\u9a8c\u8bc1&#xff0c;\u53ef\u53c2\u8003 Tests\/integration\/conftest.py \u7684\u670d\u52a1\u5668\u542f\u52a8\u7ea6\u5b9a\u3002<\/p>\n<h3>\u4e0a\u4e0b\u6587\u7a97\u53e3\u4e0e\u5176\u4ed6\u8bed\u8a00<\/h3>\n<p>apfel \u7684\u4e0a\u4e0b\u6587\u7a97\u53e3\u6309\u8fd0\u884c\u73af\u5883\u52a8\u6001\u8bfb\u53d6&#xff1a;macOS 26 \u4ee5\u53ca M1\/M2 \u82af\u7247\u4e0a\u4e3a 4096 tokens&#xff0c;macOS 27 \u642d\u914d M3 \u6216\u66f4\u65b0\u82af\u7247\u4e14\u5185\u5b58 12 GB&#043;&#xff08;Apple \u7684 AFM 3 Core Advanced \u6a21\u578b&#xff09;\u65f6\u4e3a 8192 tokens\u3002\u8fd0\u884c\u65f6\u53ef\u7528 apfel &#8211;model-info \u6253\u5370\u5b9e\u9645\u503c&#xff0c;\u6216\u76f4\u63a5\u770b \/health \u4e0e \/v1\/models \u8fd4\u56de\u7684 context_window \u5b57\u6bb5&#xff08;\u53c2\u8003 Sources\/Server.swift \u4e0e Sources\/Core\/ContextWindow.swift \u4e2d\u7684 assumedTokens &#061; 4096 \u515c\u5e95\u903b\u8f91&#xff09;\u3002<\/p>\n<p>\u672c\u6587\u6240\u8ff0\u7684 Python \u6a21\u5f0f\u4e0e apfel \u7684 OpenAI \u517c\u5bb9\u5c42\u5b8c\u5168\u4e00\u81f4&#xff0c;\u540c\u4e00\u5957 HTTP \u8868\u9762\u4e5f\u53ef\u4ee5\u4ece\u5176\u4ed6\u8bed\u8a00\u590d\u7528&#xff1a;Node.js \u89c1 docs\/guides\/nodejs.md&#xff0c;Ruby \u89c1 docs\/guides\/ruby.md&#xff0c;PHP \u89c1 docs\/guides\/php.md&#xff0c;\u4e0d\u7528 SDK \u7684\u7eaf HTTP \u65b9\u6848\u89c1 docs\/guides\/bash-curl.md&#xff1b;\u5168\u90e8\u8bed\u8a00\u6307\u5357\u7684\u7d22\u5f15\u5728 docs\/guides\/index.md\u3002\u63a5\u53e3\u7ea7\u7684\u80fd\u529b\u8fb9\u754c\u3001JSON Schema \u652f\u6301\u7ec6\u8282\u4e0e Responses API \u8bf4\u660e&#xff0c;\u53ef\u8fdb\u4e00\u6b65\u9605\u8bfb docs\/openai-api-compatibility.md\u3002<\/p>\n<p>  <img loading=\"lazy\" decoding=\"async\" class=\"gcb-icon-like\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012003300-6acc2abc48c0a.svg\" alt=\"\" width=\"16\" height=\"16\" \/> <span class=\"gcb-like-text\">\u8d5e<\/span>  <\/p>\n<p>   <span class=\"gcb-share-text\">\u5206\u4eab<\/span>  <\/p>\n<h3 class=\"gcb-project-title\">\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011apfel<\/h3>\n<p class=\"gcb-project-desc\">The free AI already on your Mac. CLI tool, OpenAI-compatible server, and interactive chat \u2014 all on-device via Apple Intelligence. No API keys, no cloud, no downloads.<\/p>\n<p>    <span class=\"gcb-project-addr-label\">\u9879\u76ee\u5730\u5740&#xff1a;<\/span><br \/>\n    <span class=\"gcb-project-addr-link\">https:\/\/gitcode.com\/gh_mirrors\/apfe\/apfel<\/span> <\/p>\n<p>  <span class=\"gcb-project-btn\"> <span class=\"gcb-project-btn-main\">\u70b9\u51fb\u67e5\u770b<\/span> <span class=\"gcb-project-btn-sub\">\u514d\u8d39\u4e0b\u8f7d<\/span> <\/span> <\/p>\n<h4 class=\"gcb-related-title\">\u76f8\u5173\u63a8\u8350<\/h4>\n<ul class=\"gcb-related-list\">\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\">\u7528 PHP \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model&#xff1a;\u57fa\u4e8e apfel \u7684 OpenAI \u517c\u5bb9\u672c\u5730\u670d\u52a1\u5b9e\u6218\u6307\u5357<\/h5>\n<p class=\"gcb-related-item-desc\">\u7528 PHP \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model&#xff1a;\u57fa\u4e8e apfel \u7684 OpenAI \u517c\u5bb9\u672c\u5730\u670d\u52a1\u5b9e\u6218\u6307\u5357 \u672c\u7bc7\u6280\u672f\u6307\u5357\u8bb2\u89e3\u5982\u4f55\u7528 PHP <\/p>\n<\/li>\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\">\u5728 Node.js \u4e2d\u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model&#xff1a;\u57fa\u4e8e apfel \u7684 OpenAI \u517c\u5bb9\u5f00\u53d1\u5b9e\u6218<\/h5>\n<p class=\"gcb-related-item-desc\">\u5728 Node.js \u4e2d\u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model&#xff1a;\u57fa\u4e8e apfel \u7684 OpenAI \u517c\u5bb9\u5f00\u53d1\u5b9e\u6218 \u672c\u6587\u662f\u4e00\u4efd\u9762\u5411 Node.js<\/p>\n<\/li>\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\">\u7528 Bash \u4e0e curl \u8c03\u7528 Apple \u7aef\u4fa7\u57fa\u7840\u6a21\u578b&#xff1a;apfel \u672c\u5730 OpenAI \u517c\u5bb9 API \u5b9e\u6218\u6307\u5357<\/h5>\n<p class=\"gcb-related-item-desc\">\u7528 Bash \u4e0e curl \u8c03\u7528 Apple \u7aef\u4fa7\u57fa\u7840\u6a21\u578b&#xff1a;apfel \u672c\u5730 OpenAI \u517c\u5bb9 API \u5b9e\u6218\u6307\u5357 \u672c\u6307\u5357\u57fa\u4e8e apfel \u9879\u76ee\u6587\u6863 docs\/<\/p>\n<\/li>\n<\/ul>\n<p>  <span class=\"gcb-prev-next-label\">\u4e0a\u4e00\u7bc7&#xff1a;<\/span><br \/>\n   Blutter\u5b9e\u6218\u6307\u5357&#xff1a;\u6df1\u5165\u63a2\u7d22Flutter\u5e94\u7528\u9006\u5411\u5206\u6790 <\/p>\n<p>  <span class=\"gcb-prev-next-label\">\u4e0b\u4e00\u7bc7&#xff1a;<\/span><br \/>\n   Wireshark 5G\u7f51\u7edc\u6545\u969c\u6392\u67e5\u5b9e\u6218\u6280\u5de7&#xff1a;\u4ece\u6293\u5305\u5230\u6df1\u5ea6\u89e3\u6790 <\/p>\n<p>\u521b\u4f5c\u58f0\u660e\uff1a\u672c\u6587\u90e8\u5206\u5185\u5bb9\u7531AI\u8f85\u52a9\u751f\u6210\uff08AIGC\uff09\uff0c\u4ec5\u4f9b\u53c2\u8003<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011apfel The free AI already on your Mac. CLI tool, OpenAI-compatible server, and interactive chat \u2014 all on-device via Apple Intelligence. No API keys, no cloud, no downloads. \u9879\u76ee\u5730\u5740&#xff1a; https:\/\/gitcode.com\/gh_mirrors\/apfe\/apfel \u70b9\u51fb\u67e5\u770b<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-115470","post","type-post","status-publish","format-standard","hentry","category-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/115470.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011apfel The free AI already on your Mac. CLI tool, OpenAI-compatible server, and interactive chat \u2014 all on-device via Apple Intelligence. No API keys, no cloud, no downloads. \u9879\u76ee\u5730\u5740&#xff1a; https:\/\/gitcode.com\/gh_mirrors\/apfe\/apfel \u70b9\u51fb\u67e5\u770b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115470.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-12T00:33:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012003300-6acc2abc48c0a.svg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115470.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115470.html\",\"name\":\"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-12T00:33:01+00:00\",\"dateModified\":\"2026-10-12T00:33:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115470.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115470.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115470.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/115470.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011apfel The free AI already on your Mac. CLI tool, OpenAI-compatible server, and interactive chat \u2014 all on-device via Apple Intelligence. No API keys, no cloud, no downloads. \u9879\u76ee\u5730\u5740&#xff1a; https:\/\/gitcode.com\/gh_mirrors\/apfe\/apfel \u70b9\u51fb\u67e5\u770b","og_url":"https:\/\/www.wsisp.com\/helps\/115470.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-12T00:33:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012003300-6acc2abc48c0a.svg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115470.html","url":"https:\/\/www.wsisp.com\/helps\/115470.html","name":"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-12T00:33:01+00:00","dateModified":"2026-10-12T00:33:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115470.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115470.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115470.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528 Python \u8c03\u7528 Apple \u7aef\u4fa7 Foundation Model\uff1aapfel \u672c\u5730 OpenAI \u517c\u5bb9\u670d\u52a1\u5668\u5b9e\u6218\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=115470"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115470\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115470"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}