VS Code Copilot(BYOK)
VS Code 内置的 GitHub Copilot Chat 支持通过 BYOK(Bring Your Own Key,自带 Key) 功能接入任意 OpenAI / Anthropic 兼容端点。您可以将学校的大模型配置为 VS Code 中的聊天模型,无需 GitHub Copilot 订阅也可使用聊天与 Agent 能力。
注意:代码补全(inline suggestions)、语义搜索等依赖 GitHub Copilot 服务的功能仍需 Copilot 订阅,BYOK 仅覆盖聊天与 Agent 会话。Copilot Business / Enterprise 账号还需要组织管理员在 GitHub 上启用 BYOK 相关策略。
通过界面添加模型
- 在 VS Code 中打开命令面板(
Ctrl+Shift+P/Cmd+Shift+P),运行 Chat: Manage Language Models。 - 在打开的 Language Models 编辑器中点击 Add Models,选择 Custom Endpoint。
- 输入分组名称(如
ChatECNU)与 API Key(您的我的令牌)。API Key 会由 VS Code 保存在本机密钥库中,并在配置中生成${input:xxx}形式的引用。 - 选择 API 类型:Responses(对应
/open/api/v1的 Responses 兼容端点)。 - 保存后 VS Code 会打开
chatLanguageModels.json,按下文配置模型即可。
注意:请选择 Custom Endpoint,不要选择 OpenAI、Anthropic 等内置项。
配置文件示例(chatLanguageModels.json)
将 chatLanguageModels.json 的内容替换为下面的配置。如果第 3 步生成的 apiKey 引用与示例中的 ${input:chatecnu-api-key} 不同,请保留您自己的那一行。
[
{
"name": "ChatECNU",
"vendor": "customendpoint",
"apiKey": "${input:chatecnu-api-key}",
"apiType": "responses",
"models": [
{
"id": "ecnu-max",
"name": "ecnu-max",
"url": "https://chat.ecnu.edu.cn/open/api/v1/responses",
"toolCalling": true,
"vision": true,
"streaming": true,
"thinking": true,
"statefulResponses": false,
"supportsReasoningEffort": ["none", "low", "high", "max"],
"reasoningEffortFormat": "responses",
"maxInputTokens": 448000,
"maxOutputTokens": 64000
},
{
"id": "ecnu-plus",
"name": "ecnu-plus",
"url": "https://chat.ecnu.edu.cn/open/api/v1/responses",
"toolCalling": true,
"vision": true,
"streaming": true,
"thinking": true,
"statefulResponses": false,
"supportsReasoningEffort": ["none", "low", "medium", "xhigh"],
"reasoningEffortFormat": "responses",
"maxInputTokens": 224000,
"maxOutputTokens": 32000
}
],
"settings": {
"ecnu-max": {
"reasoningEffort": "low"
}
}
}
]保存后,在聊天输入框的模型选择器中选择 ecnu-max 或 ecnu-plus 即可使用,如果模型没有出现,请重启 VS Code。
配置说明
| 字段 | 说明 |
|---|---|
vendor | 固定为 customendpoint,表示自定义端点 |
apiType | 接口协议类型。responses 对应平台 Responses 兼容端点;也支持 messages(对应 /open/api/anthropic)或 chat-completions |
url | 端点的完整地址。建议像示例一样写到 /responses,VS Code 不会再改写 |
toolCalling | 模型是否支持工具调用。模型必须支持工具调用,才能在 Agent 模式中使用 |
vision | 是否支持图片输入,两个主模型均支持 |
thinking | 是否支持思考模式,两个主模型均支持 |
statefulResponses | 设为 false,每次请求都携带完整的对话历史,不依赖服务端保存会话状态 |
supportsReasoningEffort | 模型可用的思考强度档位,会在模型选择器中生成 Thinking Effort 菜单。none 关闭思考;ecnu-max 对应 low / high / max,ecnu-plus 对应 low / medium / xhigh,服务端映射规则详见 思考模式 |
reasoningEffortFormat | 思考强度的请求格式。responses 对应 reasoning.effort 嵌套对象;messages 对应 output_config.effort;chat-completions 对应顶层 reasoning_effort |
maxInputTokens / maxOutputTokens | 上下文窗口与最大输出长度,参考 模型介绍 |
settings | 可选,设置默认思考强度(如上例为 ecnu-max 默认 low),也可在模型选择器中随时调整 |
注意:
maxInputTokens与maxOutputTokens之和不应超过模型上下文窗口(ecnu-max为 512K、ecnu-plus为 256K),否则模型选择器中上下文用量显示可能超窗。示例中的输出上限(64K / 32K)低于模型的最大输出长度(256K / 128K),是为了把更多的窗口留给输入。
配置思考强度
配置完成后,在聊天输入框的模型选择器中:
- 选择
ecnu-max; - 点击模型名旁的箭头(
>)打开 Thinking Effort 子菜单; - 选择思考强度(
ecnu-max为 None 关闭 / Low / High / Max,ecnu-plus为 None 关闭 / Low / Medium / XHigh)。
辅助功能使用的模型
没有登录 GitHub 账号时,聊天标题、提交信息生成等辅助功能所用的内置小模型不可用。可在 VS Code 设置中搜索 chat.utilityModel 和 chat.utilitySmallModel,将它们指向上面添加的 ChatECNU 模型。
您的请求将按 credits 配额统一处理,详见 配额限制。