VS Code 通过 Custom Endpoint 接入第三方模型

📅 2026/7/23 8:37:45
VS Code 通过 Custom Endpoint 接入第三方模型
本文示例已做脱敏处理endpoint、模型名和截图中的模型标识均为占位内容。实际使用时请替换为自己的服务地址、模型 ID 和 API Key。前置准备将 VS Code 升级到 1.128 或以上。准备第三方模型服务的 API Key。如果此前安装过其他同类 Copilot 插件建议先禁用避免和 VS Code 官方 BYOK 配置混用。1. 设置 BYOK Utility Model升级 VS Code 后如果只配置了主 Agent 模型可能会出现下面的报错No utility model is configured for copilot-utility-small while the selected main agent model is BYOK.可以打开设置面板搜索byok将Chat: Byok Utility Model Default设置为Main Agent Model。快捷键Ctrl ,2. 禁用旧版或同类插件如果本机已经安装了其他用于接入自定义模型的 Copilot 插件比如 oaicopilot建议先禁用避免多个插件同时接管模型配置。3. 添加 Custom Endpoint 模型打开 GitHub Copilot Chat 的模型选择菜单进入模型管理页面。在Language Models页面中点击Add Models选择Custom Endpoint。4. 填写 Custom Endpoint 信息首先填写分组名称。这个名称只用于本地识别可以按项目、团队或服务类型命名。然后填写自己的 API Key。公开文章、截图和仓库里不要暴露真实 API Key。最后选择 API Type。一般规则如下GPT 类模型优先选择Responses。其他 OpenAI 兼容的 Chat 模型可以选择Chat Completions。5. 补充 chatLanguageModels.json 配置选择完成后VS Code 会在chatLanguageModels.json中生成一个基础配置。保留外层结构只替换或补充models数组即可。下面是示例配置models: [ { id: external/gpt-response, name: custom/gpt-response, url: https://your-custom-endpoint.example.com/v1, thinking: true, streaming: true, toolCalling: true, vision: true, maxInputTokens: 400000, maxOutputTokens: 16000, supportsReasoningEffort: [ medium, high, xhigh ], reasoningEffortFormat: responses }, { id: external/gpt-high, name: custom/gpt-high, url: https://your-custom-endpoint.example.com/v1, thinking: true, streaming: true, toolCalling: true, vision: true, maxInputTokens: 400000, maxOutputTokens: 16000, supportsReasoningEffort: [ medium, high, xhigh ], reasoningEffortFormat: responses }, { id: external/codex-model, name: custom/codex-model, url: https://your-custom-endpoint.example.com/v1, thinking: true, streaming: true, toolCalling: true, vision: true, maxInputTokens: 400000, maxOutputTokens: 16000, supportsReasoningEffort: [ medium, high, xhigh ], reasoningEffortFormat: responses }, { id: external/reasoning-model, name: custom/reasoning-model, url: https://your-custom-endpoint.example.com/v1, thinking: true, streaming: true, toolCalling: true, vision: true, maxInputTokens: 400000, maxOutputTokens: 16000, supportsReasoningEffort: [ high, max ], reasoningEffortFormat: responses } ]6. 添加 Chat Completions 端点上面的配置主要用于Responses端点。如果还需要添加Chat Completions端点可以重新执行第 3 步在填写API Type时选择Chat Completions。7. 查看会话上下文与操作将鼠标悬停在 Copilot Chat 面板的会话标题区域如下图所示会弹出一个上下文窗口。该窗口会显示当前会话的上下文信息、已使用的 Token 占比并提供“压缩对话”等操作选项方便你管理对话历史与资源。