GitHub Copilot 接入教程

让 GitHub Copilot 使用 XiDao Api 作为后端,享受更低的成本和更多的模型选择

为什么用 XiDao Api 替代官方 API?

对比项Copilot 官方+ XiDao Api
模型选择GPT-4o / o 系列Claude / GPT-5 / Gemini 全系列
月费$10/月 或 $100/年按量付费,用多少算多少
响应速度受限于官方服务器亚洲优化,延迟更低
模型切换不支持随时切换任意模型
企业合规数据发往海外数据本地化选项

VSCode 中的 Copilot

方法一:通过 Copilot Chat 设置(推荐)

打开 Copilot Chat

Ctrl+Shift+P 打开命令面板,搜索 Copilot: Toggle Copilot Chat

打开设置

在 Copilot Chat 面板中,点击齿轮 ⚙️ 图标进入设置

配置 OpenAI Compatible

找到 「OpenAI Compatible」部分,填入:

Copilot Chat 配置
Endpoint: https://api.xidao.online/v1
API Key:  sk-你的API_KEY

方法二:通过 VSCode Settings.json

.vscode/settings.json
{
  "github.copilot.chat.openAiCompatibility": true,
  "github.copilot.openai.endpoint": "https://api.xidao.online/v1",
  "github.copilot.openai.apiKey": "sk-你的API_KEY"
}
完成! 配置保存后重启 VSCode,Copilot Chat 就会使用 XiDao Api 了。代码补全功能继续使用 Copilot 官方服务(免费)。

JetBrains IDE 中的 Copilot

适用于 IntelliJ IDEA、PyCharm、WebStorm、GoLand 等 JetBrains 全家桶。

打开设置

File → Settings → Tools → GitHub Copilot

配置 OpenAI Compatible

勾选「OpenAI Compatibility」,填入 Endpoint 和 API Key

JetBrains 配置
OpenAI Compatible: ✓
Endpoint: https://api.xidao.online/v1
API Key: sk-你的API_KEY

Neovim 中的 Copilot

对于 Neovim 用户,可以通过 copilot.vim 或 copilot.lua 插件接入。

使用 copilot.lua(推荐)

lua (~/.config/nvim/lua/copilot.lua)
require("copilot").setup({
  copilot_command = {
    openai_api_key = "sk-你的API_KEY",
    openai_api_base_url = "https://api.xidao.online/v1"
  },
})

Copilot Labs (AI Agent 模式)

Copilot Labs 是 GitHub 推出的 AI Agent 功能(类似 Cursor Composer / Windsurf Wave),可以让 AI 自主完成多步骤编程任务。

💡
提示 Copilot Labs 在 VSCode 中可通过侧边栏面板访问,也可以通过 Cmd+Shift+P 搜索「Copilot: Start Agent Task」启动。

同样可以使用上面的方法将 Copilot Labs 切换到 XiDao Api 后端,这样 Agent 任务就会使用你选择的模型(如 Claude Opus 4.6)来执行。