Claude Code 是 Anthropic 推出的智能编码命令行工具,默认使用 Claude 系列模型。但我们可以通过指定自定义 API 端点,将其连接到本地部署的 Qwen3.6 模型,实现“本地模型 + 强大编码助手”的组合。
本文将带你完成:
请确保你的系统已安装 Docker 并支持 GPU(NVIDIA Container Toolkit)。
在合适的位置创建项目目录,例如 ~/vllm-qwen,并在其中新建 docker-compose.yml 文件,内容如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
version: '3.8' services: vllm-qwen: image: vllm/vllm-openai:cu130-nightly container_name: vllm-qwen36-35B-A3B-FP8 restart: unless-stopped ipc: host ports: - "8000:8000" volumes: - /app/vllm/data/models:/root/.cache/modelscope # 模型缓存目录,可按需修改 environment: - VLLM_USE_MODELSCOPE=true deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] command: - --model - "Qwen/Qwen3.6-35B-A3B-FP8" - --tensor-parallel-size - "1" - --gpu-memory-utilization - "0.8" - --served-model-name - "Qwen3.6-35B-A3B-FP8" - --enable-prefix-caching - --enable-auto-tool-choice - --default-chat-template-kwargs - '{"enable_thinking": false}' - --tool-call-parser - "qwen3_coder" - --max-model-len - "196608" - --max-num-batched-tokens - "8192" - --enable-chunked-prefill - --max-num-seqs - "32" - --kv-cache-dtype - "fp8" |
在 docker-compose.yml 所在目录执行:
|
1 |
docker compose up -d |
服务启动后会监听本机 8000 端口。
使用 curl 检查模型列表:
|
1 |
curl http://127.0.0.1:8000/v1/models |
正常返回应包含 Qwen3.6-35B-A3B-FP8。
Claude Code 支持多种安装方式,可根据你的系统选择。
macOS / Linux / WSL(Linux 子系统)
打开终端,执行:
|
1 |
curl -fsSL https://claude.ai/install.sh | bash |
安装完成后重启终端或执行 source ~/.bashrc(或 ~/.zshrc)。
Windows PowerShell(管理员模式运行)
|
1 |
irm https://claude.ai/install.ps1 | iex |
Windows CMD(命令提示符)
|
1 |
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd |
|
1 |
npm install -g @anthropic-ai/claude-code |
安装后,执行一次初始化(非必须,但建议):
|
1 |
claude install |
将 Claude Code 指向本地 vLLM 服务。当前服务运行在 127.0.0.1:8000,如果其他机器使用可以ifconfig查看服务器的ip地址,认证 Token 可随意设置(vLLM 默认不校验,但需要占位符)。
Linux / macOS / WSL (bash/zsh)
|
1 2 |
export ANTHROPIC_BASE_URL="http://127.0.0.1:8000" export ANTHROPIC_AUTH_TOKEN="your_key" |
若想永久生效,可将这两行追加到 ~/.bashrc 或 ~/.zshrc。
Windows PowerShell
|
1 2 |
$env:ANTHROPIC_BASE_URL="http://127.0.0.1:8000" $env:ANTHROPIC_AUTH_TOKEN="your_key" |
Windows CMD
|
1 2 |
set ANTHROPIC_BASE_URL=http://127.0.0.1:8000 set ANTHROPIC_AUTH_TOKEN=your_key |
环境变量设置完毕后,使用 --model 参数指定模型名称(必须与 vLLM 启动参数 --served-model-name 一致):
|
1 |
claude --model Qwen3.6-35B-A3B-FP8 |
首次运行会提示登录,由于我们使用的是自定义端点,可以随意输入邮箱或直接回车跳过。
启动成功后,你将看到类似如下的交互界面:
|
1 2 3 |
Claude Code v2.x.x Type /help for commands, /exit to quit. > 你好,请帮我写一个 Python 冒泡排序 |