{"id":6513,"date":"2025-10-03T17:08:14","date_gmt":"2025-10-03T09:08:14","guid":{"rendered":"https:\/\/dingxuan.info\/wp\/?p=6513"},"modified":"2025-12-09T11:47:46","modified_gmt":"2025-12-09T03:47:46","slug":"%e4%b8%ad%e8%bd%acapi%e9%85%8d%e7%bd%aeclaude-code","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=6513","title":{"rendered":"\u4e2d\u8f6cAPI\u914d\u7f6eClaude Code"},"content":{"rendered":"<p>\u672c\u6587\u6863\u63d0\u4f9b\u9002\u7528\u4e8e Windows 11\u4e2d\uff0c\u914d\u7f6eAnthropic Claude Code\u7a0b\u5e8f\u7684\u64cd\u4f5c\u3002\n\u4f7f\u7528\u4e2d\u8f6cAPI\uff0c\u514d\u53bb\u5404\u79cd\u4eba\u4e3a\u8bbe\u7f6e\u7684\u969c\u788d\uff0c\u5e2e\u52a9\u5feb\u6377\u5b8c\u6210\u914d\u7f6e\u5de5\u4f5c\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u51c6\u5907\u5de5\u4f5c<\/h2>\n<ol>\n<li><strong>\u7ec8\u7aef\u5de5\u5177\u8981\u6c42<\/strong>\n<ul>\n<li>Windows\uff1a\u4f7f\u7528\u00a0<strong>PowerShell<\/strong>\n<figure id=\"attachment_mmd_6508\" class=\"wp-block-image \"><img decoding=\"async\" width=\"749\" height=\"500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2025\/10\/image-3.jpeg\" class=\"attachment-full size-full\" alt=\"image-3.jpeg\" loading=\"lazy\" \/><\/figure><\/li>\n<\/ul>\n<\/li>\n<li><strong>\u914d\u7f6e\u4fe1\u606f\u786e\u8ba4<\/strong>\n\u51c6\u5907\u597d\u963f\u5179\u63d0\u4f9b\u7684API Key\uff08<code>sk-xxxxxx<\/code>\u957f\u4e32\u5b57\u7b26\uff09\uff1a<\/li>\n<\/ol>\n<!--more-->\n<pre><code class=\"language-bash\"># Claude\uff08Anthropic\uff09\u914d\u7f6e\nANTHROPIC_BASE_URL=&quot;https:\/\/api.alz-ai.cn&quot;\nANTHROPIC_AUTH_TOKEN=&quot;sk-xxxxxx&quot;\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p><strong>\u5b89\u88c5Node.JS\u73af\u5883<\/strong>\n<strong>\u65b9\u6cd5\u4e00\uff1a\u5b98\u7f51\u4e0b\u8f7d\uff08\u63a8\u8350\uff09<\/strong><\/p>\n<ol>\n<li>\u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95ee\u00a0<code>https:\/\/nodejs.org\/<\/code><\/li>\n<li>\u70b9\u51fb &#8220;LTS&#8221; \u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\uff08\u7248\u672c\u53f7\u8981\u5927\u4e8e18\uff0c\u63a8\u8350\u957f\u671f\u652f\u6301\u7248\u672c\uff09<\/li>\n<li>\u4e0b\u8f7d\u5b89\u88c5<\/li>\n<\/ol>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/strong>\n\u5982\u679c\u4f60\u5b89\u88c5\u4e86 Chocolatey \u6216 Scoop\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5b89\u88c5\uff1a<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"language-powershell\"># \u4f7f\u7528 Chocolatey\nchoco install nodejs\n# \u6216\u4f7f\u7528 Scoop\nscoop install nodejs\n<\/code><\/pre>\n<pre><code>**Windows \u6ce8\u610f\u4e8b\u9879**\n- \u5efa\u8bae\u4f7f\u7528 PowerShell \u800c\u4e0d\u662f CMD\n- \u5b89\u88c5\u914d\u7f6e\u65f6\uff0c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\n\n**\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f**\n\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00 PowerShell \u6216 CMD\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<\/code><\/pre>\n<pre><code class=\"language-powershell\">node --version\nnpm --version\n# \u663e\u793a\u7248\u672c\u53f7\u5373\u4e3a\u5b89\u88c5\u6210\u529f\n<\/code><\/pre>\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h2>\n<h3 class=\"wp-block-heading\">1. Windows \u7cfb\u7edf\uff08PowerShell\uff09<\/h3>\n<p>Windows \u9700\u901a\u8fc7 PowerShell \u914d\u7f6e\u7528\u6237\u7ea7\u73af\u5883\u53d8\u91cf\uff0c\u786e\u4fdd\u6c38\u4e45\u751f\u6548\u3002<\/p>\n<h4 class=\"wp-block-heading\">\u6b65\u9aa4 1\uff1a\u6253\u5f00\u7ba1\u7406\u5458\u6a21\u5f0f PowerShell<\/h4>\n<ul>\n<li>\u6309\u4e0b\u00a0<code>Win+X<\/code>\u00a0\u7ec4\u5408\u952e\uff0c\u5728\u5f39\u51fa\u7684\u83dc\u5355\u4e2d\u9009\u62e9\u00a0<strong>\u201cWindows PowerShell\uff08\u7ba1\u7406\u5458\uff09\u201d<\/strong>\uff08\u82e5\u663e\u793a \u201c\u7ec8\u7aef\uff08\u7ba1\u7406\u5458\uff09\u201d\uff0c\u6253\u5f00\u540e\u5207\u6362\u4e3a PowerShell \u6807\u7b7e\u9875\uff09\u3002<\/li>\n<\/ul>\n<h4 class=\"wp-block-heading\">\u6b65\u9aa4 2\uff1a\u6267\u884c\u914d\u7f6e\u547d\u4ee4<\/h4>\n<h5 class=\"wp-block-heading\"><strong>\u65b9\u6cd5\u4e00\uff08\u6c38\u4e45\u751f\u6548\uff09<\/strong><\/h5>\n<p>\u5728 PowerShell \u4e2d\u9010\u884c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff08\u66ff\u6362<code>sk-xxxxxx<\/code>\u4e3a\u5b9e\u9645\u5bc6\u94a5\uff09\uff1a<\/p>\n<pre><code class=\"language-powershell\"># \u914d\u7f6eClaude\uff08Anthropic\uff09API\u73af\u5883\u53d8\u91cf\n[Environment]::SetEnvironmentVariable(&quot;ANTHROPIC_BASE_URL&quot;, &quot;https:\/\/api.alz-ai.cn&quot;, &quot;User&quot;)\n[Environment]::SetEnvironmentVariable(&quot;ANTHROPIC_AUTH_TOKEN&quot;, &quot;sk-xxxxxx&quot;, &quot;User&quot;)\n<\/code><\/pre>\n<h5 class=\"wp-block-heading\"><strong>\u65b9\u6cd5\u4e8c\uff08\u5f53\u524d\u7a97\u53e3\u751f\u6548\uff09<\/strong><\/h5>\n<p>\u5728PowerShell\u4e2d\u8f93\u5165\uff1a\uff08\u66ff\u6362<code>sk-xxxxxx<\/code>\u4e3a\u5b9e\u9645\u5bc6\u94a5\uff09\uff1a<\/p>\n<pre><code class=\"language-powershell\">$env:ANTHROPIC_BASE_URL = &quot;https:\/\/api.alz-ai.cn&quot;\n$env:ANTHROPIC_AUTH_TOKEN = &quot;sk-xxxxx&quot;\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\">2. Linux\/macOS \u7cfb\u7edf\uff08Zsh\/Bash \u7ec8\u7aef\uff09<\/h3>\n<p>Linux \u9ed8\u8ba4\u7ec8\u7aef\u591a\u4e3a Bash\uff0cmacOS \u9ed8\u8ba4\u7ec8\u7aef\u4e3a Zsh\uff0c\u9700\u6839\u636e\u5b9e\u9645\u4f7f\u7528\u7684\u7ec8\u7aef\u7c7b\u578b\u9009\u62e9\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<h4 class=\"wp-block-heading\">\u6b65\u9aa4 1\uff1a\u6253\u5f00\u914d\u7f6e\u6587\u4ef6<\/h4>\n<ul>\n<li>\u82e5\u4f7f\u7528 Zsh\uff08macOS \u9ed8\u8ba4 \/ \u624b\u52a8\u5b89\u88c5\uff09\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">nano ~\/.zshrc\n<\/code><\/pre>\n<ul>\n<li>\u82e5\u4f7f\u7528 Bash\uff08Linux \u9ed8\u8ba4 \/ \u624b\u52a8\u5207\u6362\uff09\uff1a<\/li>\n<\/ul>\n<pre><code class=\"language-bash\">nano ~\/.bashrc\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\">\u6b65\u9aa4 2\uff1a\u6dfb\u52a0\u914d\u7f6e\u5185\u5bb9<\/h4>\n<p>\u5728\u6253\u5f00\u7684\u6587\u4ef6\u672b\u5c3e\uff0c\u7c98\u8d34\u4ee5\u4e0b\u914d\u7f6e\uff08\u66ff\u6362<code>sk-xxxxxx<\/code>\u4e3a\u5b9e\u9645\u5bc6\u94a5\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u914d\u7f6eClaude\uff08Anthropic\uff09API\nexport ANTHROPIC_BASE_URL=&quot;https:\/\/api.alz-ai.cn&quot;\nexport ANTHROPIC_AUTH_TOKEN=&quot;sk-xxxxxx&quot;\n\n# \u914d\u7f6eCodex\uff08OpenAI\uff09API\nexport OPENAI_BASE_URL=&quot;https:\/\/api.alz-ai.cn\/v1&quot;\nexport OPENAI_API_KEY=&quot;sk-xxxxxx&quot;\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\">\u6b65\u9aa4 3\uff1a\u4fdd\u5b58\u5e76\u751f\u6548<\/h4>\n<ul>\n<li>\u6309\u00a0<code>Ctrl+O<\/code>\u00a0\u952e\u4fdd\u5b58\u5185\u5bb9\uff0c\u6309\u00a0<code>Enter<\/code>\u00a0\u786e\u8ba4\u6587\u4ef6\u540d\uff0c\u6309\u00a0<code>Ctrl+X<\/code>\u00a0\u9000\u51fa\u7f16\u8f91\u3002<\/li>\n<li>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u914d\u7f6e\u7acb\u5373\u751f\u6548\uff1a\n<ul>\n<li>Zsh \u7ec8\u7aef\uff1a<code>source ~\/.zshrc<\/code><\/li>\n<li>Bash \u7ec8\u7aef\uff1a<code>source ~\/.bashrc<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5b89\u88c5 \/ \u8fd0\u884cclaude code<\/h2>\n<h3 class=\"wp-block-heading\">\u6b65\u9aa4 1\uff1a\u5b89\u88c5 Claude Code<\/h3>\n<pre><code class=\"language-bash\">npm install -g @anthropic-ai\/claude-code\n<\/code><\/pre>\n<p>\u8fd9\u4e00\u6b65\uff0c\u53ef\u80fd\u9700\u8981\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884cpowershell\n<figure id=\"attachment_mmd_6509\" class=\"wp-block-image \"><img decoding=\"async\" width=\"749\" height=\"500\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2025\/10\/image-3-1.jpeg\" class=\"attachment-full size-full\" alt=\"image-3.jpeg\" loading=\"lazy\" \/><\/figure>\n<h3 class=\"wp-block-heading\">\u6b65\u9aa4 2\uff1a\u8fd0\u884cClaude Code<\/h3>\n<pre><code class=\"language-powershell\"># 1. \u8fdb\u5165\u4ee3\u7801\u76ee\u5f55\ncd d:\\temp\n\n# 2. \u9a8c\u8bc1Claude\u914d\u7f6e\n$env:ANTHROPIC_BASE_URL\n# \u5e94\u8f93\u51fa\uff1ahttps:\/\/api.alz-ai.cn\n$env:ANTHROPIC_AUTH_TOKEN\n# \u5e94\u8f93\u51fa\uff1ask-xxxxxx\uff08\u5b9e\u9645\u5bc6\u94a5\uff09\n\nclaude #\u542f\u52a8\u8f6f\u4ef6\n<\/code><\/pre>\n<p>\u5728claude\u4e2d\uff0c\u8f93\u5165\u547d\u4ee4\u9009\u62e9\u6a21\u578b<\/p>\n<pre><code class=\"language-claude\"># \u8f93\u5165\u547d\u4ee4\u9009\u62e9\u6a21\u578b\n# \u9009\u62e9\u6a21\u578b claude-sonnet-4-5\n\/model sonnet45\n# \u6216 claude-opus-4-1\n\/model op41\n### !!!opus 4.1\u6a21\u578b\u5355\u4ef7\u6602\u8d35\uff0c\u6ce8\u610f\u989d\u5ea6\u6d88\u8017!!!\n\n\/status \n# \u67e5\u770b\u5de5\u4f5c\u72b6\u6001\n<\/code><\/pre>\n<figure id=\"attachment_mmd_6510\" class=\"wp-block-image \"><img decoding=\"async\" width=\"1098\" height=\"611\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2025\/10\/image-4.jpeg\" class=\"attachment-full size-full\" alt=\"image-4.jpeg\" loading=\"lazy\" \/><\/figure>\n<p>\u5b89\u88c5\u4e00\u4e2a\u5e38\u7528\u7684MCP\u63d2\u4ef6\uff0c<strong>\u5728powershell\u4e2d<\/strong>\uff0c\u8f93\u5165\uff1a<\/p>\n<pre><code class=\"language-powershell\">claude mcp add playwright npx @playwright\/mcp@latest\n<\/code><\/pre>\n<p>\u6ca1\u6709playwright\u7684\u60c5\u51b5\u4e0b\uff0ccc\u4f9d\u8d56claude\u6a21\u578b\u7684web\u6d4f\u89c8\u80fd\u529b\u3002\u53d7\u5230\u5b89\u5168\u9650\u5236\uff0c\u4e0d\u80fd\u76f4\u63a5\u6d4f\u89c8\u3002\n<figure id=\"attachment_mmd_6511\" class=\"wp-block-image \"><img decoding=\"async\" width=\"1093\" height=\"605\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2025\/10\/image-5.jpeg\" class=\"attachment-full size-full\" alt=\"image-5.jpeg\" loading=\"lazy\" \/><\/figure>\n\u5b89\u88c5playwright\u540e\uff0cmcp\u4f1a\u5728\u672c\u5730\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u76f4\u63a5\u5728\u5176\u4e2d\u64cd\u4f5c\uff0c\u6293\u53d6\u5fc5\u8981\u6570\u636e\u3002\n<figure id=\"attachment_mmd_6512\" class=\"wp-block-image \"><img decoding=\"async\" width=\"1096\" height=\"599\" src=\"https:\/\/dingxuan.info\/wp\/wp-content\/uploads\/2025\/10\/image-6.jpeg\" class=\"attachment-full size-full\" alt=\"image-6.jpeg\" loading=\"lazy\" \/><\/figure>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6863\u63d0\u4f9b\u9002\u7528\u4e8e Windows 11\u4e2d\uff0c\u914d\u7f6eAnthropic Claude Code\u7a0b\u5e8f\u7684\u64cd\u4f5c\u3002 \u4f7f\u7528\u4e2d\u8f6c &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=6513\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u4e2d\u8f6cAPI\u914d\u7f6eClaude Code<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[155],"tags":[],"class_list":["post-6513","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/6513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6513"}],"version-history":[{"count":2,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/6513\/revisions"}],"predecessor-version":[{"id":6522,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/6513\/revisions\/6522"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}