Skip to content

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 会话。

通过界面添加模型

  1. 在 VS Code 中打开命令面板(Ctrl+Shift+P / Cmd+Shift+P),运行 Chat: Manage Language Models
  2. 在打开的 Language Models 编辑器中点击 Add Models,选择 Custom Endpoint
  3. 输入分组名称(如 ChatECNU)与 API Key(您的我的令牌)。API Key 会由 VS Code 保存在本机密钥库中,并在配置中生成 ${input:xxx} 形式的引用。
  4. 选择 API 类型:Responses(对应 /open/api/v1 的 Responses 兼容端点)。
  5. 保存后 VS Code 会打开 chatLanguageModels.json,按下文配置模型即可。

配置文件示例(chatLanguageModels.json)

json
[
  {
    "name": "ChatECNU",
    "vendor": "customendpoint",
    "apiKey": "${input:chatecnu-api-key}",
    "apiType": "responses",
    "models": [
      {
        "id": "ecnu-plus",
        "name": "ecnu-plus",
        "url": "https://chat.ecnu.edu.cn/open/api/v1",
        "toolCalling": true,
        "vision": true,
        "maxInputTokens": 256000,
        "maxOutputTokens": 32000
      },
      {
        "id": "ecnu-max",
        "name": "ecnu-max",
        "url": "https://chat.ecnu.edu.cn/open/api/v1",
        "toolCalling": true,
        "vision": false,
        "streaming": true,
        "thinking": true,
        "supportsReasoningEffort": [
          "none",
          "low",
          "high",
          "max"
        ],
        "reasoningEffortFormat": "responses",
        "maxInputTokens": 1000000,
        "maxOutputTokens": 384000
      }
    ],
    "settings": {
      "ecnu-max": {
        "reasoningEffort": "low"
      }
    }
  }
]

配置说明

字段说明
vendor固定为 customendpoint,表示自定义端点
apiType接口协议类型。responses 对应平台 Responses 兼容端点;也支持 messages(对应 /open/api/anthropic)或 chat-completions
url端点地址。以 /v1 结尾时,VS Code 会自动按 apiType 附加路径(如 responses.../v1/responses),无需手写完整路径
toolCalling模型是否支持工具调用,两个主模型均开启
vision是否支持图片输入,ecnu-plus 支持、ecnu-max 不支持
thinking是否支持思考模式,ecnu-max 支持
supportsReasoningEffort模型可用的思考强度档位。none 关闭思考;low / high / max 对应 ecnu-max 档位,服务端映射规则详见 思考模式
reasoningEffortFormat思考强度的请求格式。responses 对应 reasoning.effort 嵌套对象;messages 对应 output_config.effortchat-completions 对应顶层 reasoning_effort
maxInputTokens / maxOutputTokens上下文窗口与最大输出长度,参考 模型介绍
settings可选,设置默认思考强度(如上例为 ecnu-max 默认 low),也可在模型选择器中随时调整

注意:maxInputTokensmaxOutputTokens 之和不应超过模型上下文窗口(ecnu-max 为 1M、ecnu-plus 为 256K),否则模型选择器中上下文用量显示可能超窗。

配置思考强度

配置完成后,在聊天输入框的模型选择器中:

  1. 选择 ecnu-max
  2. 点击模型名旁的箭头(>)打开 Thinking Effort 子菜单;
  3. 选择思考强度(None 关闭 / Low / High / Max)。

您的请求将按 credits 配额统一处理,详见 配额限制

参考