Claude Code 和 VSCODE合体

自从开始使用Claude Code之后,解决了大模型集成问题之后,开始琢磨如何在IDE中集成,使用起来多一个选择。研究后发现非常有意思的地方,看具体下文。

Claude Code的安装,以及ccr模式(claude-code-router) (Claude Code + claude-code-router白嫖魔搭社区千问模型,开启AI编程之路Claude Co - 掘金)

目录:

一 只有使用claude原生模式才可以集成到IDE,ccr code模式不行

二 ccr code模式如何转换为原生模式

只有使用claude原生模式才可以集成到IDE,ccr code模式不行

1 第一步,先打开vscode,并且打开你需要的编辑的代码工程目录,比如这里是D:\Develop\Nodejs\helloworld

2 第二步,打开命令行窗口,注意一定要切换到同一个目录下运行

cmd 复制代码
cd D:\Develop\Nodejs\helloworld
D:\Develop\Nodejs\helloworld>claude

在对话窗口敲入/ide

bash 复制代码
 > /ide  [open]                                                                                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  /ide     Manage IDE integrations and show status

按下回车

vbnet 复制代码
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                      │
│  Select IDE                                                                                                          │
│  Connect to an IDE for integrated development features.                                                              │
│                                                                                                                      │
│   > 1. Visual Studio Code√                                                                                           │
│     2. None                                                                                                          │
│                                                                                                                      │
│  ※ Tip: You can enable auto-connect to IDE in /config or with the --ide flag                                         │
│                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
 Enter to confirm · Esc to exit

注意这里选择

css 复制代码
> 1. Visual Studio Code√

等待,然后切回vscode,选择一个文件,看到窗口右上角的claude标志,

点击即可在vscode中启动:

ccr code模式如何转换为原生模式

上述操作必须在命令行原生模式 claude启动,如果采用ccr code模式是不行的。 但是,但是,但是有个转换,可以将ccr code转换为claude模式来兼容。 修改环境变量的值为

ini 复制代码
ANTHROPIC_API_KEY=myapikey 
ANTHROPIC_AUTH_TOKEN=http://127.0.0.1:3456

这里的myapikey是在 C:\Users\用户名.claude-code-router中的config.json文件中配置的,如下

json 复制代码
{
  "LOG": false,
  "CLAUDE_PATH": "",
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "APIKEY": "myapikey",
  "API_TIMEOUT_MS": "600000",
  "PROXY_URL": "",
  "Transformers": [],

有一行

json 复制代码
"APIKEY": "myapikey",

你可以换成自己喜欢的任意长字符串,如果为""空的话,环境变量ANTHROPIC_API_KEY的值可以随意写。 还有一行是

然后重新启动ccr

ruby 复制代码
C:\Users\ynzys>ccr start
⚠️ API key is not set. HOST is forced to 127.0.0.1.
127.0.0.1
Loaded JSON config from: C:\Users\ynzys\.claude-code-router\config.json
register transformer: Anthropic (endpoint: /v1/messages)
register transformer: gemini (endpoint: /v1beta/models/:modelAndAction)
register transformer: vertex-gemini (endpoint: /v1/projects/:projectId/locations/:location/publishers/google/models/:modelAndAction)
register transformer: vertex-claude (endpoint: /v1/projects/:projectId/locations/:location/publishers/anthropic/models/:modelAndAction)
register transformer: deepseek (no endpoint)
register transformer: tooluse (no endpoint)
register transformer: openrouter (no endpoint)
register transformer: maxtoken (no endpoint)
register transformer: groq (no endpoint)
register transformer: cleancache (no endpoint)
register transformer: enhancetool (no endpoint)
register transformer: reasoning (no endpoint)
register transformer: sampling (no endpoint)
register transformer: maxcompletiontokens (no endpoint)
modelscope provider registered
🚀 LLMs API server listening on http://127.0.0.1:3456

然后再命令行运行claude 这里看到API的URL为http://127.0.0.1:3456 就对了,它会通过这个代理访问ccr配置文件中的模型API。

相关推荐
怕浪猫21 小时前
领域特定语言(Domain-Specific Language, DSL)
设计模式·程序员·架构
爱勇宝1 天前
深扒 Anthropic 1680 位工程师简历:应届生几乎没机会,AI 公司最缺的不是博士
前端·后端·程序员
AskHarries1 天前
工具失败时怎么办:重试、回滚、人工确认和风险提示
后端·程序员
陈随易2 天前
VSCode的Copilot扩展支持接入DeepSeek,Kimi了!
前端·后端·程序员
七十二時4462 天前
什么是VibeCoding
程序员
AskHarries2 天前
Canvas / Artifact:把结果变成可查看、可交互的产物
程序员
爱勇宝3 天前
鸿蒙生态的下半场:开发者不只要能开发,还要能赚钱
android·前端·程序员
程序员cxuan3 天前
DeepSeek 杀入多模态,识图功能正式上线!
人工智能·后端·程序员
文心快码BaiduComate3 天前
Comate 搭载GLM-5.2:百万上下文,稳定支撑长程任务
前端·程序员·开源
程序员cxuan3 天前
分享一下我最近常用的 10 个 Codex 小技巧。
人工智能·后端·程序员