在VS Code中添加自定义语言模型

通用流程

从VS Code 1.121开始原生支持在语言模型中添加Custom Endpoint,无需额外安装插件即可添加自定义模型,从而实现Copilot Chat切换自定义模型,具体可查看官方文档AI language models in VS Code

参考官方文档,添加一个自定义端点的流程为:

管理模型

  1. 按下Ctrl+Shift+P
  2. 输入Chat: Manage Language Models
  3. 弹出『语言模型』弹窗。

添加模型

  1. 点击添加模型->Custom Endpoint
  2. 输入组名,一个组将使用相同的API Key
  3. 输入API Key
  4. 根据API的实际类型选择API TypeChat CompletionsResponsesMessages
  5. 弹出chatLanguageModels.json并进行下一步编辑,文件的参数格式可参考官方文档

提供商级别的属性包括:

属性说明
vendor 使用 Custom Endpoint(自定义端点)提供程序时,必须设置为 customendpoint
apiKey 用于身份验证的 API 密钥。建议使用输入变量安全存储密钥, 例如 "apiKey": "${input:myApiKey}", 而不是直接将原始密钥写入配置文件并提交。
apiType (可选)指定该 Provider 中所有模型默认使用的 API 类型。 可选值包括: chat-completions(默认)、 responsesmessages。 也可以在单个模型配置中通过模型级别的 apiType 属性进行覆盖。
url (可选)用于自动发现模型的基础 URL。 设置该参数后,VS Code 会从该端点查询可用模型列表, 而不是使用 models 数组手动配置模型。 如果省略该参数,则需要通过 models 数组显式配置模型。

数组中的每个模型models都支持以下属性:

属性说明
id发送给 API 的模型标识符。例如,在 Foundry 中,该值对应部署名称(deployment name)。
name在模型选择器(model picker)中显示的模型名称。
url该模型的完整 API 端点 URL。
apiType(可选)为单个模型覆盖 API 类型(chat-completionsresponsesmessages)。默认继承 Provider 级别的 apiType
contextWindow (可选)模型完整上下文窗口大小(输入 + 输出)的 Token 数量。 例如,1000000 表示一个 100 万 Token 的模型。 设置该参数后,可以省略 maxInputTokens, VS Code 会根据公式 contextWindow - maxOutputTokens 自动计算最大输入 Token 数量。
modelOptions (可选)发送给模型的请求参数对象,会应用于每一次模型请求。 例如可以设置 temperaturetop_p 等参数。 示例: "modelOptions": { "temperature": 0.2 }
toolCalling如果模型支持工具调用(Tool Calling),设置为 true
vision如果模型支持图像输入,设置为 true
maxInputTokens模型可接受的最大输入 Token 数量。与 maxOutputTokens 一起决定模型的上下文窗口大小。
maxOutputTokens模型能够生成的最大输出 Token 数量。与 maxInputTokens 一起决定模型的上下文窗口大小。
editTools (可选)模型支持的编辑工具数组。如果未配置,编辑器会尝试多个编辑工具并自动选择最佳工具。 可选值包括: find-replacemulti-find-replaceapply-patchcode-rewrite
thinking(可选)如果模型支持思考能力(Thinking),设置为 true。默认值为 false
streaming(可选)如果模型支持流式响应(Streaming Responses),设置为 true。默认值为 true
zeroDataRetentionEnabled (可选)如果该端点启用了零数据保留(Zero Data Retention,ZDR),设置为 true。 启用后,通过 Responses API 请求时不会发送 previous_response_id。 默认值为 false
supportsReasoningEffort(可选)模型支持的推理强度级别数组,例如 ["low", "medium", "high"]。 设置后,模型选择器中会显示思考强度(Thinking Effort)选择器。 常见级别包括: minimallowmediumhigh
reasoningEffortFormat (可选)用于向模型传递推理强度参数的请求格式。 chat-completions 会发送顶层字符串参数 reasoning_effortresponses 会发送嵌套对象 reasoning.effortmessages 会发送 output_config.effort。 如果未设置,则根据 URL 自动决定格式。
requestHeaders (可选)包含额外 HTTP 请求头的对象,用于向该模型发送请求。 某些保留请求头(禁止使用、转发相关以及内部请求头)不允许配置,如果存在会被忽略。

maxInputTokensmaxOutputTokens之和即为语言模型弹窗中上下文的大小。

添加特定模型

深度求索 DeepSeek

目前官方文档接入 GitHub Copilot仍然是通过插件添加的,在插件中输入API Key即可使用。

月之暗面 Kimi

API Type选择Chat Completions,需要额外注意Kimi的模型temperature和top_p等参数需要设置为固定值或为空,因此需要额外添加modelOptions将这两个参数设置为空,思考模型推理强度流式输出各个模型支持情况各异,需要根据实际填写。参考示例:

[
    {
        "name": "Kimi",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.xxxxxxxx}",
        "apiType": "chat-completions",
        "models": [
            {
                "id": "kimi-k3",
                "name": "Kimi K3",
                "url": "https://api.moonshot.cn/v1",
                "toolCalling": true,
                "vision": true,
                "thinking": true,
                "supportsReasoningEffort": [
                    "low",
                    "high",
                    "max"
                ],
                "streaming": true,
                "maxInputTokens": 934464,
                "maxOutputTokens": 65536,
                "modelOptions": {
                    "temperature": null,
                    "top_p": null
                }
            },
            {
                "id": "kimi-k2.7-code",
                "name": "Kimi K2.7 Code",
                "url": "https://api.moonshot.cn/v1",
                "toolCalling": true,
                "vision": false,
                "thinking": true,
                "streaming": true,
                "maxInputTokens": 223232,
                "maxOutputTokens": 32768,
                "modelOptions": {
                    "temperature": null,
                    "top_p": null
                }
            },
            {
                "id": "kimi-k2.7-code-highspeed",
                "name": "Kimi K2.7 Code Highspeed",
                "url": "https://api.moonshot.cn/v1",
                "toolCalling": true,
                "vision": false,
                "thinking": true,
                "streaming": true,
                "maxInputTokens": 223232,
                "maxOutputTokens": 32768,
                "modelOptions": {
                    "temperature": null,
                    "top_p": null
                }
            },
            {
                "id": "kimi-k2.6",
                "name": "Kimi K2.6",
                "url": "https://api.moonshot.cn/v1",
                "toolCalling": true,
                "vision": true,
                "thinking": true,
                "streaming": true,
                "maxInputTokens": 223232,
                "maxOutputTokens": 32768,
                "modelOptions": {
                    "temperature": null,
                    "top_p": null
                }
            }
        ]
    }
]

千问 Qwen

API Type选择Chat Completions,其余参数可参考官网数据。参考示例:

[
    {
        "name": "Qwen",
        "vendor": "customendpoint",
        "apiKey": "${input:chat.lm.secret.xxxxxxxx}",
        "apiType": "chat-completions",
        "models": [
            {
                "id": "qwen3.8-max",
                "name": "Qwen3.8-Max",
                "url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
                "toolCalling": true,
                "vision": true,
                "thinking": true,
                "supportsReasoningEffort": [
                    "low",
                    "medium",
                    "xhigh"
                ],
                "streaming": true,
                "maxInputTokens": 934464,
                "maxOutputTokens": 131072
            },
            {
                "id": "qwen3.8-flash",
                "name": "Qwen3.8-Flash",
                "url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
                "toolCalling": true,
                "vision": true,
                "thinking": true,
                "streaming": true,
                "maxInputTokens": 934464,
                "maxOutputTokens": 131072
            },
            {
                "id": "qwen3.7-plus",
                "name": "Qwen3.7-Plus",
                "url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
                "toolCalling": true,
                "vision": true,
                "thinking": true,
                "streaming": true,
                "maxInputTokens": 934464,
                "maxOutputTokens": 131072
            }
        ]
    }
]

Copilot Chat切换模型

点击聊天窗口的模型名称即可进行切换,具体可以参考官方文档

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇