← 全部工具

TheStreamCode/copilot-byok-switcher

热度 75 更新于 开发与构建

Safely switch GitHub Copilot CLI between native and BYOK providers—OpenAI, Anthropic, Ollama and more—without persisting credentials.

githubauto-collected

安装

暂未验证可直接使用的安装命令,请查看项目官方文档或 Release。

Copilot BYOK Switcher

Your own provider models, inside the GitHub Copilot CLI /model picker — in the same session as the GitHub ones.

npm install -g copilot-byok-switcher

Created by Michael Gasperini.

What you get

Start Copilot the way you always do, open /model, and find your own models listed next to GitHub's:

Recommended models
❯ Auto
New models
  Claude Sonnet 4.6 (Anthropic)      ← your Anthropic key
  GPT-5.5 (OpenAI)                   ← your OpenAI key
  DeepSeek V4 Pro (DeepSeek)         ← your DeepSeek key
  GLM-5.2 (Z.AI GLM)                 ← your Z.AI key
  Qwen3 Coder Plus (Alibaba Qwen)    ← your DashScope key
Unavailable models
  claude-sonnet-5
  ...

Pick one and the session talks straight to that provider. GitHub authentication stays intact, every other Copilot feature keeps working, and those turns cost zero AI credits — you pay your provider directly.

The list is not hard-coded: each provider is asked what it serves at startup, so a model released this morning is in the picker this morning.

● Model changed to: byok-anthropic-claude-sonnet-4-6 for this session

Why this exists

Copilot CLI does support BYOK out of the box, through COPILOTPROVIDERBASEURL. That path has three limits this project removes:

| | Built-in BYOK | Copilot BYOK Switcher | |---|---|---| | Providers per session | one | as many as you configure | | /model picker | shows nothing to choose from | your models listed with GitHub's | | GitHub models | unavailable while BYOK is on | still there, same session | | Switching model | restart with new env vars | /model inside the session |

Bringing your own key for OpenAI, Anthropic or Gemini is not possible natively on personal accounts at all — GitHub reserves that for enterprise owners, who get custom models in the picker. On a personal plan those vendors appear in the picker but are served by GitHub's own subscription: they consume premium requests and follow your plan's restrictions. On the free plan most of them are visible yet unusable.

How it works

Copilot CLI reads an environment variable, COPILOTAPIURL, that repoints its API endpoint anywhere — including plain HTTP on localhost. The switcher starts a small local router there:

copilot ──COPILOT_API_URL──> router ──┬──> api.<tier>.githubcopilot.com   (everything else, untouched)
                                       └──> your providers (OpenAI-compatible)

The router does exactly three things: