Visual Studio Code(简称 VS Code)官方文档 Bring your own language model key[1] 中介绍了在 VS Code 中添加更多语言模型的方法,包括 内置提供商(Built-in providers)[2]、扩展(Extensions)[3]、自定义端点(Custom endpoint)[4] 三种方式。
自定义端点支持三种 API 类型:Chat Completions[5]、Responses[6] 和 Messages[7]。
添加模型步骤如下:



chatLanguageModels.json 文件,调用模型具体的模型名称(id)和完整 url 需在此文件中填写。有关配置属性的详细信息,请参阅 Model configuration reference[8]。下面是调用 Anthropic Messages API 的配置示例:
[
{
"name": "Anthropic",
"vendor": "customendpoint",
"apiKey": "YOUR_API_KEY",
"apiType": "messages",
"models": [
{
"id": "claude-sonnet-4-6",
"name": "Claude Sonnet 4.6",
"url": "https://api.anthropic.com/v1/messages",
"toolCalling": true,
"vision": true,
"maxInputTokens": 200000,
"maxOutputTokens": 64000
}
]
}
]
下面是调用 OpenAI Chat Completions API 的配置示例:
[
{
"name": "LocalHost",
"vendor": "customendpoint",
"apiKey": "${input:chat.lm.secret.xxxxxx}",
"apiType": "chat-completions",
"models": [
{
"id": "model1",
"name": "Local Model 1",
"url": "http://localhost:8000/v1/chat/completions",
"toolCalling": true,
"vision": true,
"maxInputTokens": 128000,
"maxOutputTokens": 16000
},
{
"id": "model2",
"name": "Local Model 2",
"url": "http://localhost:8000/v1/chat/completions",
"toolCalling": true,
"vision": true,
"maxInputTokens": 128000,
"maxOutputTokens": 16000
}
]
}
]
在 VS Code GitHub Copilot Chat 中使用自定义模型可能会遇到请求失败的报错,如:
Sorry, your request failed. Please try again.
Client Request Id: 95903bd3-e7d5-435f-a842-45bcf985940b
Reason: token expired or invalid: 403: Error: token expired or invalid: 403 at qG._provideLanguageModelResponse (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/copilot/dist/extension.js:1690:14362) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async qG.provideLanguageModelResponse (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/copilot/dist/extension.js:1690:15327)
Meta: Sorry, your request failed. Please try again. #253136[9] 给出了一些解决方案,如重试请求、更换模型、检查日志(CTRL + SHIFT + U 打开输出面板,选择 GitHub Copilot Chat 查看日志)等。

output
模型 | 平台 | URL | 模型 ID | API Key |
|---|---|---|---|---|
DeepSeek-V4-Flash | OpenCode Zen | https://opencode.ai/zen/v1/chat/completions | deepseek-v4-flash-free | - |
MiMo-V2.5 | mimo-v2.5-free | |||
Hy3 | hy3-free | |||
DeepSeek-V4-Flash | Nvidia | https://integrate.api.nvidia.com/v1/chat/completions | deepseek-ai/deepseek-v4-flash | API Keys |
DeepSeek-V4-Pro | deepseek-ai/deepseek-v4-pro | |||
GLM-5.2 | z-ai/glm-5.2 | |||
Qwen3.5-122B-A10B | qwen/qwen3.5-122b-a10b | |||
Qwen3.5-397B-A17B | qwen/qwen3.5-397b-a17b | |||
Qwen3-Next-80B-A3B-Instruct | qwen/qwen3-next-80b-a3b-instruct | |||
MiniMax-M3 | minimaxai/minimax-m3 | |||
Step 3.7 Flash | stepfun-ai/step-3.7-flash | |||
Mistral Medium 3.5 | Mistral | https://api.mistral.ai/v1/chat/completions | mistral-medium-3-5 | API Keys |
参考资料
[1]
Bring your own language model key: https://code.visualstudio.com/docs/agent-customization/language-models#_bring-your-own-language-model-key
[2]
内置提供商(Built-in providers): https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-model-from-a-built-in-provider
[3]
扩展(Extensions): https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-model-provider-extension
[4]
自定义端点(Custom endpoint): https://code.visualstudio.com/docs/agent-customization/language-models#_add-a-custom-endpoint-model
[5]
Chat Completions: https://developers.openai.com/api/reference/chat-completions/overview
[6]
Responses: https://developers.openai.com/api/reference/responses/overview
[7]
Messages: https://platform.claude.com/docs/en/api/messages
[8]
Model configuration reference: https://code.visualstudio.com/docs/agent-customization/language-models#_model-configuration-reference
[9]
Meta: Sorry, your request failed. Please try again. #253136: https://github.com/microsoft/vscode/issues/253136