<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Claude Code &#8211; IT Crafter</title>
	<atom:link href="https://blog.itcrafter.net/archives/tag/claude-code/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.itcrafter.net</link>
	<description></description>
	<lastBuildDate>Sun, 08 Mar 2026 13:36:51 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Claude Code 接入硅基流动，一个中转搞定</title>
		<link>https://blog.itcrafter.net/archives/196</link>
		
		<dc:creator><![CDATA[IT Crafter]]></dc:creator>
		<pubDate>Sun, 08 Mar 2026 01:16:19 +0000</pubDate>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Claude Code]]></category>
		<category><![CDATA[Siliconflow]]></category>
		<guid isPermaLink="false">https://blog.itcrafter.net/?p=196</guid>

					<description><![CDATA[2,784 字，阅读时间 15 分钟。]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="1-siliconflow-官方文档的坑">1. Siliconflow 官方文档的坑</h2>



<p>想用 Claude Code 接 Siliconflow 硅基流动的模型，以为照着&nbsp;<a href="https://docs.siliconflow.cn/cn/usercases/use-siliconcloud-in-ClaudeCode#claude-code">官网文档</a>&nbsp;配置就行：<br><img decoding="async" src="https://pic2.helpfully.top:9522/uploads/2026/03/69ac4755bf92a.png" alt="69ac4755bf92a.png"></p>



<p>结果，运行直接报 Not logged in:<br><img decoding="async" src="https://pic2.helpfully.top:9522/uploads/2026/03/69ac47b1dd1f3.png" alt="69ac47b1dd1f3.png"></p>



<p>有经验的朋友都知道，接入第三方模型是无须登录的，出现这个现象想必是踩坑了&#8230;</p>



<p>试着把 setting.json 中的 ANTHROPIC_API_KEY 字段名改为 ANTHROPIC_AUTH_TOKEN:<br><img decoding="async" src="https://pic2.helpfully.top:9522/uploads/2026/03/69ac48a85a21b.png" alt="69ac48a85a21b.png"></p>



<p>这回，直接报错。看来只是换了个坑：<br><img decoding="async" src="https://pic2.helpfully.top:9522/uploads/2026/03/69ac490a377ea.png" alt="69ac490a377ea.png"></p>



<p>这是 siliconflow server 返回的报错，因为 Siliconflow 的模型需要特殊的 thinking 配置，而 Claude Code 默认发过去的请求格式不匹配。</p>



<p>看来官方文档也不甚靠谱。</p>



<h2 class="wp-block-heading" id="2-中转方案claude-code-router">2. 中转方案：claude-code-router</h2>



<p>claude code 有个第三方的转发器: claude-code-router，似乎可以解决这个问题。（<a href="https://github.com/musistudio/claude-code-router">github 源码</a>）</p>



<p>数据链路大致是：</p>



<pre class="wp-block-code"><code>Claude Code → claude-code-router → Siliconflow
</code></pre>



<p>后面的实践表明，这款 router 可以解决 siliconflow 的接入问题。</p>



<h2 class="wp-block-heading" id="3-较佳实践docker-部署">3. 较佳实践：docker 部署</h2>



<p>能用 docker 部署的服务，我都不会再直接安装到服务器上了。正好 claude-code-router 作者在 dockerhub 上发布了<a href="https://hub.docker.com/r/musistudio/claude-code-router">镜像</a>。</p>



<h3 class="wp-block-heading" id="31-准备工作">3.1. 准备工作</h3>



<p>确保你已经具备：</p>



<ul class="wp-block-list">
<li>Docker 和 Docker Compose</li>



<li>Siliconflow 的 API Key</li>



<li>大概 5 分钟时间</li>
</ul>



<h3 class="wp-block-heading" id="32-配置文件">3.2. 配置文件</h3>



<p>分别需要准备 docker compose 的配置文件，和 claude-code-router 本身的配置文件。</p>



<p><code>docker-compose.yml</code>&nbsp;示例：</p>



<pre class="wp-block-code"><code>version: '3.8'

services:
  claude-code-router:
    image: musistudio/claude-code-router:latest
    ports:
      - "3456:3456"
    restart: unless-stopped
    volumes:
      - /your_config_path:/root/.claude-code-router
</code></pre>



<p>claude-code-router 配置文件&nbsp;<code>config.json</code>&nbsp;示例：（重要配置）</p>



<pre class="wp-block-code"><code># 放置路径: /your_config_path/config.json
# 使用时请删除所有 # 注释内容
{
    "PROXY_URL": "http://ip:port",  # 可选，支持配置 proxy
    "LOG": true,
    "APIKEY":"$CCR_KEY",  # claude-code 接入 claude-code-router 时配置的 ANTHROPIC_AUTH_TOKEN
    "HOST":"0.0.0.0", # docker 部署中，此处必须设为 0.0.0.0
    "LOG_LEVEL": "trace",
    "API_TIMEOUT_MS": 600000,
    "NON_INTERACTIVE_MODE": false,
    "Providers": &#91;
      {
        "name": "siliconflow",
        "api_base_url": "https://api.siliconflow.cn/v1/chat/completions",
        "api_key": "$SILICONFLOW_API_KEY",
        "models": &#91;
          "Pro/MiniMaxAI/MiniMax-M2.5",
          "Pro/zai-org/GLM-5",
	        "zai-org/GLM-4.5-Air",
	        "Qwen/Qwen2.5-72B-Instruct-128K",
          "Qwen/Qwen3-VL-235B-A22B-Thinking"
        ],
        "transformer": {
          "use": &#91;
	    &#91;
	      "max_tokens",
	      {
		"max_tokens": 16384
	      }
      	    ]	      
	  ]
        }
      }
    ],
    "Router": {
      "default": "siliconflow,Pro/MiniMaxAI/MiniMax-M2.5",
      "background": "siliconflow,Qwen/Qwen2.5-72B-Instruct-128K",
      "think": "siliconflow,Pro/zai-org/GLM-5",
      "longContext": "siliconflow,Pro/MiniMaxAI/MiniMax-M2.5",
      "longContextThreshold": 60000,
      "webSearch": "siliconflow,zai-org/GLM-4.5-Air",
      "image": "siliconflow,Qwen/Qwen3-VL-235B-A22B-Thinking"
    }

}

</code></pre>



<h3 class="wp-block-heading" id="4-启动服务">4. 启动服务</h3>



<pre class="wp-block-code"><code>docker-compose up -d
</code></pre>



<p>通过 docker 日志确认容器启动成功：</p>



<pre class="wp-block-code"><code>docker logs -f claude-code-router
</code></pre>



<p>成功加载 config 配置：<br><img decoding="async" src="https://pic2.helpfully.top:9522/uploads/2026/03/69ac510e06c0a.png" alt="69ac510e06c0a.png"></p>



<h3 class="wp-block-heading" id="5-配置-claude-code">5. 配置 Claude Code</h3>



<p>设置环境变量：</p>



<pre class="wp-block-code"><code>export ANTHROPIC_BASE_URL="http://localhost:3456"
export ANTHROPIC_AUTH_TOKEN="CCR config 中配置的 CCR_KEY"
</code></pre>



<p>或者直接在 Claude Code 的 ~/.claude/settings.json 里改：</p>



<pre class="wp-block-code"><code>{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "CCR config 中配置的 CCR_KEY",
    "ANTHROPIC_BASE_URL": "http://localhost:3456",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "siliconflow,zai-org/GLM-4.5-Air",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "siliconflow,Pro/zai-org/GLM-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "siliconflow,Pro/MiniMaxAI/MiniMax-M2.5",
    "ANTHROPIC_MODEL": "siliconflow,Pro/MiniMaxAI/MiniMax-M2.5",
    "ANTHROPIC_REASONING_MODEL": "siliconflow,Pro/zai-org/GLM-5",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
</code></pre>



<h3 class="wp-block-heading" id="6-测试一下">6. 测试一下</h3>



<p>启动 claude code，随便对话一下，返回正常就说明成功了。</p>



<h2 class="wp-block-heading" id="7-总结">7. 总结</h2>



<p>颇费周折，终于成功在 claude code 中接入了 siliconflow 硅基流动的模型。我觉得官方得好好刷新下指引文档。</p>



<h2 class="wp-block-heading" id="参考链接">参考链接</h2>



<ul class="wp-block-list">
<li><a href="https://github.com/musistudio/claude-code-router">claude-code-router 项目地址</a></li>



<li><a href="https://hub.docker.com/r/musistudio/claude-code-router">claude-code-router docker 镜像</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
