ByteNoteByteNote

字节笔记本

2026年5月25日

GitHub Copilot CLI 接入 DeepSeek V4:BYOK 模式配置

API中转
¥120

GitHub Copilot CLI 支持 BYOK(自带密钥)模式,允许接入第三方模型。通过 DeepSeek 的 Anthropic 兼容端点,可以在 Copilot CLI 中使用 DeepSeek V4 模型。需要注意的是,必须使用 anthropic 作为 provider type,使用 openai 类型会触发 400 错误。

安装 GitHub Copilot CLI

需要 Node.js 22 或更高版本:

bash
npm install -g @github/copilot

详细安装说明参考 GitHub Copilot CLI 官方文档

获取 DeepSeek API Key

前往 DeepSeek 开放平台 创建并复制 API Key(以 sk- 开头)。

配置环境变量

Linux / macOS:

bash
export COPILOT_PROVIDER_TYPE=anthropic
export COPILOT_PROVIDER_BASE_URL=https://api.deepseek.com/anthropic
export COPILOT_PROVIDER_API_KEY=sk-your-deepseek-api-key
export COPILOT_MODEL=deepseek-v4-pro

Windows(PowerShell):

powershell
$env:COPILOT_PROVIDER_TYPE="anthropic"
$env:COPILOT_PROVIDER_BASE_URL="https://api.deepseek.com/anthropic"
$env:COPILOT_PROVIDER_API_KEY="sk-your-deepseek-api-key"
$env:COPILOT_MODEL="deepseek-v4-pro"

可选模型:deepseek-v4-prodeepseek-v4-flash,修改 COPILOT_MODEL 即可切换。

启动使用

bash
copilot

Copilot CLI 完整支持 Agent 模式、工具调用和 MCP,全部由 DeepSeek 驱动。

可选配置

Token 限制

由于 deepseek-v4-pro 不在 Copilot CLI 的内置模型目录中,建议显式配置 token 限制:

bash
export COPILOT_PROVIDER_MAX_PROMPT_TOKENS=840000
export COPILOT_PROVIDER_MAX_OUTPUT_TOKENS=128000

离线模式

阻止 GitHub API 调用(提示词仍会发送到 api.deepseek.com):

bash
export COPILOT_OFFLINE=true
分享: