Fork of ericc-ch/copilot-api — a reverse-engineered proxy that exposes GitHub Copilot as an OpenAI- and Anthropic-compatible API, usable as a backend for Claude Code.
Warning
Reverse-engineered and unsupported by GitHub. Excessive automated/bulk requests may trigger GitHub's abuse detection and get your Copilot access suspended. Use responsibly. See GitHub Acceptable Use and the Copilot Terms.
- VS Code token bridge / proxy-only auth — obtain the Copilot token from a running VS Code instead of the GitHub device-code flow. Lets the proxy run with no
GH_TOKEN(see Token sources). - Model mappings —
MODEL_MAPPINGSenv var rewrites incoming model IDs (e.g. theclaude-*IDs Claude Code sends) to the internal Copilot model names. This is what makes Claude Code work against Copilot. /v1/responsesendpoint — OpenAI Responses API support, in addition to the upstream chat/messages/embeddings routes.- Hardened token refresh — centralized 401 handling, retry with backoff, and survives long-running sessions.
- Enterprise account type by default —
bun run dev/bun run authpass--account-type enterprise. - Windows
.cmdhelpers + Claude Codesettings.jsonfor a one-double-click workflow (see below).
- Bun (>= 1.2.x)
- A GitHub account with a Copilot subscription, or a running VS Code signed in to Copilot (for the token bridge)
bun installThe repo ships .cmd launchers. Set them up once as Windows Terminal profiles (Settings → Add a new profile → New empty profile → paste the script path into Command line), or just double-click them.
| Script | What it does |
|---|---|
start-copilot-api.cmd |
Starts the proxy server (npm run dev) on http://localhost:4141. |
start-claude.cmd |
Launches Claude Code pointed at the proxy (working dir c:\src\controlplane). |
start-cc-copilot-api.cmd |
Launches Claude Code in this repo's dir (handy for working on the proxy itself). |
re-auth.cmd |
Re-runs the GitHub auth flow (npm run auth) when the token expires. |
Typical flow: run start-copilot-api.cmd, then start-claude.cmd.
The model IDs and effort level Claude Code uses are set as set ANTHROPIC_* lines at the top of start-claude.cmd / start-cc-copilot-api.cmd — edit those to change models.
bun run dev # watch mode (account-type enterprise)
bun run start # production
bun run auth # GitHub auth onlySee the upstream README for npx, Docker, and the full CLI option tables — they apply unchanged.
The proxy resolves a Copilot token in this order:
- GitHub token (
GH_TOKEN/--github-token, or the interactive device-code flow) → exchanged for a Copilot token, then auto-refreshed. - VS Code token bridge (fallback, or proxy-only mode when no GitHub token is present) — the proxy fetches a token from a small VS Code extension at
http://127.0.0.1:<VSCODE_PROXY_PORT>/token.
Source: wenbo97/copilot-token-bridge — the extension is open source; the bundled
.vsixbelow is a prebuilt copy.
- Install the bundled extension:
copilot-token-bridge-0.3.0.vsixcode --install-extension copilot-token-bridge-0.3.0.vsix
- Make sure VS Code is signed in to GitHub Copilot and left running.
- (Optional) If the extension uses a non-default port, set
VSCODE_PROXY_PORTin.env(default18774).
With the bridge available the proxy can run with no GitHub token at all — useful when the device-code flow is blocked.
Copy .env.example to .env. Fork-relevant keys:
| Variable | Purpose | Default |
|---|---|---|
MODEL_MAPPINGS |
Rewrite model IDs, source:target comma-separated (e.g. claude-opus-4-8:claude-opus-4.8). |
none |
VSCODE_PROXY_PORT |
Port of the Copilot Token Bridge VS Code extension. | 18774 |
IDLE_TIMEOUT |
Bun server idle timeout (seconds). | 255 |
TRACE_OUTPUT_FOLDER |
Where request/response traces go when --trace is set. |
./traces |
MODEL_MAPPINGS example (maps the IDs Claude Code sends to internal Copilot model names):
MODEL_MAPPINGS="claude-opus-4-8:claude-opus-4.8,claude-opus-4-7:claude-opus-4.7-1m-internal,claude-sonnet-4-6:claude-sonnet-4.6,claude-haiku-4-5:claude-haiku-4.5"- Copy
settings.jsontoC:/Users/<user-name>/.claude/settings.json(create the file if needed). - Restart the Claude chat (close and reopen it).
settings.json points ANTHROPIC_BASE_URL at http://localhost:4141 and sets the model IDs — adjust to taste.
| Command | |
|---|---|
bun run dev |
Watch-mode server |
bun run lint |
ESLint (@echristian/eslint-config) — bun run lint --fix to autofix |
bun test |
Run the test suite (tests/*.test.ts) |
bun run typecheck |
tsc |
See AGENTS.md for code-style conventions.
Credit: original work by Erick Christian (ko-fi). This fork only layers on the Windows/Claude-Code/token-bridge changes described above.