> ## Content Index
> Fetch the complete content index at: https://brotherhong.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# VSCode 接入任意 AI 模型教程
- URL: https://brotherhong.com/vscode-custom-ai-model/
- Published: 2026-09-08T00:00:00.000Z
- Updated: 2026-09-08T00:00:00.000Z
- Description: VS Code 1.122 起支持自带 API 密钥（BYOK）与自定义端点，手把手教你把 DeepSeek、Kimi、Claude、GPT 等任意模型接入 Copilot 聊天与 Agent 模式。
- Author: 洪哥
- Tags: 教程, VSCode, Copilot, AI模型

同步视频教程：<https://www.bilibili.com/video/BV1pRVe66Efa/>

Visual Studio Code `1.122.0` 版本现已支持自带大模型 API 密钥（BYOK），将你的版本更新到此版本，即可自由接入其他提供商的模型，甚至本地运行的模型。不再局限于内置模型，想用什么模型，你说了算！

## VS Code 添加自定义模型的三种方法

VS Code 提供了三种方式添加自己的模型，根据你的场景对号入座，其中自定义端点，就是这次更新的功能：

| 方式        | 适用场景                                                                  | 怎么上手           |
| --------- | --------------------------------------------------------------------- | -------------- |
| **内置提供商** | 你的模型提供商已在列表中（Azure、Anthropic、Gemini、OpenAI 等）                         | 填入 API 密钥即可    |
| **扩展**    | 通过 Marketplace 扩展提供模型，比如用 OAI 插件                                      | 安装扩展，按提示配置     |
| **自定义端点** | **你有第三方模型、自托管、企业或兼容 Chat Completions / Responses / Messages API 的端点** | **指向任意兼容 URL** |

## 添加自定义端点模型

适用场景：你有一个第三方魔性、自托管的、企业的、或其他兼容 Chat Completions、Responses、Messages API 的端点。比如 DeepSeek，其他模型厂商、中转站都可以。

想在一个平台里接入 Claude、GPT 等多种模型，也可以使用中转站获取 API Key。本文下面的 Claude 和 GPT 配置示例使用的是 Seedance：

<https://www.openzhenzhen.com/?aff=xx1N&ch=brotherhong>

注册并创建 API Key 后，按照下方示例填写 API 类型、Base URL 和模型 ID 即可。

**操作步骤：**

**1\.** 打开 Copilot 聊天框的模型选择栏，然后依次点击齿轮图标 → 选择**添加模型** → 选择**自定义端点**。

![模型选择栏与齿轮图标](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-01.png)

![添加模型菜单选择自定义端点](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-02.png)

**2\.** 输入分组名称（之后可改）。我输入了：DeepSeek

**3\.** 输入端点的显示名称和 API 密钥。

**4\.** 选择 API 类型：**Chat Completions**、**Responses** 或 **Messages**（确保你的模型支持该类型），一般选**Chat Completions**就好。

**5\.** VS Code 会打开 `chatLanguageModels.json`，在此配置模型详情，保存即可。找到对应的 BaseURL，注意要使用 OpenAI 的端点。详细属性说明见文末模型配置参考。

### DeepSeek API：开启思考 + 1M 上下文，思考等级设置为 xhigh

```json
[
    {
        "name": "DeepSeek",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.39d03ffb}",
        "apiType": "chat-completions",
        "models": [
            {
                "id": "deepseek-v4-pro",
                "name": "DeepSeek V4 Pro",
                "url": "https://api.deepseek.com",
                "toolCalling": true,
                "vision": false,
                "thinking": true,
                "maxInputTokens": 1024000,
                "maxOutputTokens": 64000,
                "supportsReasoningEffort": [
                    "low",
                    "max",
                    "xhigh"
                ]
            }
        ],
        "settings": {
            "deepseek-v4-pro": {
                "reasoningEffort": "xhigh"
            }
        }
    }
]

```

### Kimi API：需要配置为 messages 类型，然后启用 thinking 即可（没有思考等级）

```json
[
    {
        "name": "KimiAPI",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.6a9c4db9}",
        "apiType": "messages",
        "models": [
            {
                "id": "kimi-k2.6",
                "name": "kimi-k2.6",
                "url": "https://api.moonshot.cn/anthropic",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 200000,
                "maxOutputTokens": 16000,
                "thinking": true
            }
        ]
    }
]

```

### Kimi Code：来自于 B 站朋友 I\_影\_I：[关于 KimiCode 如何配置到 VSCode Copilot 中](https://www.bilibili.com/video/BV1pRVe66Efa?comment%5Fon=1&comment%5Froot%5Fid=301264206193&share%5Ftag=s%5Fi#reply301264206193)

```json
[
    {
        "name": "KimiCode",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.-1c9b1811}",
        "apiType": "messages",
        "models": [
            {
                "id": "kimi-for-coding",
                "name": "kimi-for-coding",
                "url": "https://api.kimi.com/coding/v1",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 128000,
                "maxOutputTokens": 16000,
                "thinking": true,
                "supportsReasoningEffort": [
                    "low",
                    "max",
                    "xhigh"
                ]
            }
        ],
        "settings": {
            "kimi-for-coding": {
                "reasoningEffort": "max"
            }
        }
    }
]

```

### Claude：我个人在用的中转站

<https://www.openzhenzhen.com/?aff=xx1N&ch=brotherhong>

```json
[
    {
        "name": "ThinkClaude",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.-5964a227}",
        "apiType": "messages",
        "models": [
            {
                "id": "claude-opus-4-8",
                "name": "claude-opus-4-8",
                "url": "https://www.openzhenzhen.com",
                "toolCalling": true,
                "vision": false,
                "maxInputTokens": 128000,
                "maxOutputTokens": 16000
            }
        ]
    }
]

```

### GPT：我个人在用的中转站

<https://www.openzhenzhen.com/?aff=xx1N&ch=brotherhong>

```json
[
    {
        "name": "ThinkGPT",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.785955d5}",
        "apiType": "chat-completions",
        "models": [
            {
                "id": "gpt-5.5",
                "name": "gpt-5.5",
                "url": "https://www.openzhenzhen.com/v1",
                "toolCalling": true,
                "vision": true,
                "maxInputTokens": 128000,
                "maxOutputTokens": 16000
            }
        ]
    }
]

```

配置完成后，在模型选择器中选中即可使用。如果添加后没有立刻出现，重启 VS Code 即可。

![模型选择器中选中新模型](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-03.png)

## 更新已配置的模型

想换 API 密钥或修改端点？无需重新添加，直接更新即可：

1. 打开大模型编辑器（齿轮图标 → **管理大模型**），和刚才的步骤一样。
2. 找到你要修改的提供商，点击其旁边的齿轮图标。

![管理大模型](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-04.png)

1. 更新 API 密钥、端点 URL 等信息。

## 进阶：让自定义模型接管更多任务

除了 Chat 对话，VS Code 在后台还会用轻量级模型处理一些杂活——生成标题、写提交信息、检测意图等。你也可以让自定义模型来接管这些任务，打开 File -> Preferences -> Settings 面板，搜索 `chat.utilityModel`：

![chat.utilityModel 设置](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-05.png)

- `setting(chat.utilityModel)`：接管标题生成、摘要、设置搜索、Git 审查等通用任务。
- `setting(chat.utilitySmallModel)`：接管提交信息、重命名建议、分支名生成、意图检测等快速轻量任务（建议用一个又快又便宜的模型）。

两个设置默认都是 **Default**（即 Copilot 内置模型），改成你的自定义模型即可。

## Agent：使用 Local 模式，调用第三方模型

VSCode 前段时间新出的 Agent 模式（实际上就是一种类似于 Codex 和 Claude Code Desktop 的界面），也可以使用 BYOK 第三方模型，方法如下：

**1\.** 打开 Agent 界面，一定要先打开才行。

![Agent 界面](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-06.png)

**2\.** 点击这个链接跳转到设置，并打上对勾保存：`vscode://settings/sessions.chat.localAgent.enabled`

![设置链接跳转](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-07.png)

![勾选启用 Local Agent](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-08.png)

**3\.** 回到 Agent 界面，选择 Local 模式，最后选择你刚才配置好的第三方模型。

![Agent Local 模式选择第三方模型](https://brotherhong.com/content/images/2026/12/vscode-custom-ai-model-image-09.png)

## 附录：模型配置参考

以下为 `chatLanguageModels.json` 中所有可配置的属性，分为**提供商级别**和**模型级别**两层。自己按需修改对应的属性即可。

### 提供商级别属性

| 属性     | 描述                                  |
| ------ | ----------------------------------- |
| vendor | 模型提供商，如 azure、openai、customendpoint |
| name   | 在 UI 中显示的提供商分组名称                    |
| models | *（可选）* 此提供商提供的模型配置数组                |

### 模型级别属性

| 属性                       | 描述                                                                                                          |
| ------------------------ | ----------------------------------------------------------------------------------------------------------- |
| id                       | 发送给 API 的模型标识符（如部署名称）                                                                                       |
| name                     | 在模型选择器中的显示名称                                                                                                |
| url                      | 模型的完整端点 URL                                                                                                 |
| apiType                  | *（可选）* 按模型覆盖 API 类型：chat-completions、responses、messages。默认继承提供商级别的 apiType                                  |
| toolCalling              | 是否支持工具调用，设为 true                                                                                            |
| vision                   | 是否支持图像输入，设为 true                                                                                            |
| maxInputTokens           | 模型接受的最大输入 token 数，这里也作为上下文窗口大小使用                                                                            |
| maxOutputTokens          | 模型生成的最大输出 token 数                                                                                           |
| editTools                | *（可选）* 支持的编辑工具数组，可选值：find-replace、multi-find-replace、apply-patch、code-rewrite。不填则编辑器自动选择                    |
| thinking                 | *（可选）* 是否支持思考能力，默认 false，有思考的模型需要配置                                                                         |
| streaming                | *（可选）* 是否支持流式响应，默认 true                                                                                     |
| zeroDataRetentionEnabled | *（可选）* 是否启用零数据保留（ZDR），启用后不会在 Responses API 请求中发送 previous\_response\_id。默认 false                            |
| supportsReasoningEffort  | *（可选）* 模型支持的推理力度级别，如 \["low", "medium", "high"\]。设置后模型选择器中会出现**思考力度**选择器。常用级别：minimal、low、medium、high、xhigh |
| reasoningEffortFormat    | *（可选）* 推理力度的传参格式。chat-completions 发送顶层 reasoning\_effort 字符串；responses 发送嵌套 reasoning.effort 对象。不填则随 URL 推断 |
| requestHeaders           | *（可选）* 随请求一起发送的额外 HTTP 标头（保留标头会被忽略）                                                                         |