文档 · 指南
让 JetBrains Copilot 用任意模型
IntelliJ IDEA、PyCharm、GoLand 等 JetBrains IDE 和 Android Studio 里的 GitHub Copilot 插件,可以通过 Bring Your Own Key(自带 Key)使用其他厂商的模型:在 Copilot Chat 的模型选择器里点 Manage Models…,再添加 Custom Endpoint Provider。magpie 直接替你把这个自定义端点写好,名叫 magpie,于是 DeepSeek、GLM、Kimi、Qwen、Claude 或 ChatGPT 订阅等 magpie 里的每个模型都出现在 Copilot Chat 的选择器里。想反过来把 Copilot 订阅用在别的 Agent 里,见 GitHub Copilot 接入 Claude Code、Codex、Gemini CLI 和 OpenCode。
接入 JetBrains Copilot
- 在 magpie 里添加供应商在 供应商 页添加 API Key,或登录一个订阅。
- 在 Agent 页把 Copilot (JetBrains) 的供应商设为 magpiemagpie 把自己的端点写进 Copilot 的 byok.json。
- 重启 IDEIDE 在 Copilot 登录时读取端点列表,所以重启后 magpie 的模型才会出现。
- 在 Copilot Chat 的模型选择器里选模型magpie 的模型列在 magpie 下面。选好的模型由 IDE 记在项目文件里。
magpie 发现 JetBrains IDE 或 Android Studio 的插件文件夹里装了 github-copilot-intellij 插件,或者 byok.json 里已经有 magpie 的端点时,就会在 Agent 页列出 Copilot (JetBrains)。
需要哪种 Copilot 方案
Bring Your Own Key 要求 Copilot 用 GitHub 账号登录。个人方案 Copilot Free、Pro 和 Pro+ 都有这个功能;Business 和 Enterprise 要看组织的策略是否允许。这些请求和 Copilot 语言服务器的其他客户端一样,带的都是 GithubCopilot/<服务器版本>,magpie 靠 Key 区分它们。
byok.json
JetBrains 插件自己不保存这些设置,而是交给它内置的 Copilot 语言服务器(copilot-language-server)。这个服务器把所有自定义端点放在一个 JSON 文件里,每次用到时都重新读取:
- 设置了
$XDG_CONFIG_HOME(绝对路径)时:$XDG_CONFIG_HOME/github-copilot/byok.json - Windows:
%USERPROFILE%\AppData\Local\github-copilot\byok.json - macOS 和 Linux:
~/.config/github-copilot/byok.json
一个自定义端点在这里是三个键。magpie 按语言服务器自己保存时的写法写入:
// ~/.config/github-copilot/byok.json
{
"magpie-provider-config": { "groupName": "magpie", "apiType": "chatCompletions" },
"magpie-api-key": "",
"magpie-models-config": {
"…": {
"deploymentUrl": "http://127.0.0.1:3425/v1/chat/completions",
"isRegistered": true,
"isCustomModel": true,
"modelCapabilities": {
"name": "…", "maxInputTokens": …, "maxOutputTokens": …,
"toolCalling": true, "vision": …
}
}
},
…
} 每个模型都指向网关的 /v1/chat/completions,Key 作为 Bearer 令牌发送。注意 Key 以明文写在这个文件里,不在 IDE 的密码库中。Xcode 和 Eclipse 里的 Copilot 运行同一个语言服务器、读同一个文件,所以它们也会列出 magpie 的模型。
Agent 模式和上下文
每个模型都打开了工具调用,因为 Copilot 的 Agent 模式只列出能调用工具的模型。maxInputTokens 是服务器填充提示词用的窗口,取 magpie 目录里的上下文长度,不知道时用服务器自己对自定义端点的默认值 128K;maxOutputTokens 留在这个窗口里面。
你的设置保持不变
你在 byok.json 里的其他端点和 Key 保持原样。你在 IDE 的 Manage Models 里隐藏的 magpie 模型,同步后仍然隐藏。没有变化时 magpie 不写文件,文件保持语言服务器最后写入的样子。
切回
在 magpie 里关掉 Copilot (JetBrains) 时,magpie 删掉 byok.json 里自己的三个键,你自己的端点不受影响。
常见问题
JetBrains 里的 Copilot 能用 DeepSeek 或 GLM 吗?
能。magpie 在 Copilot 的 byok.json 里写一个自定义端点,重启 IDE 后在 Copilot Chat 的模型选择器里选 magpie 下的模型即可。
Copilot Business 能用吗?
Bring Your Own Key 在 Business 和 Enterprise 上要看组织的策略是否允许;Free、Pro 和 Pro+ 都可以用。
Agent 模式里能选 magpie 的模型吗?
能。magpie 给每个模型打开了工具调用,Copilot 的 Agent 模式只列出能调用工具的模型。
Xcode 或 Eclipse 里的 Copilot 也会有吗?
会。它们运行同一个 Copilot 语言服务器,读同一个 byok.json。
更多 Agent 用同样的模型:让 VS Code 用任意模型、让 Copilot CLI 用任意模型、让 OpenMausBot 用任意模型、让 Kiro Crew 用任意模型。遇到报错?见 常见错误排查,或到 Discord 提问。