Unlocks all GitHub Copilot models in OpenCode — including preview models that arrive in VS Code before OpenCode supports them natively.
GitHub Copilot gives VS Code access to models that OpenCode can't use:
- OpenCode uses its own OAuth app, which doesn't support the Copilot token exchange
- Certain models (like
claude-opus-4.6-fast) require specific headers that OpenCode doesn't send - New preview models appear in VS Code weeks before OpenCode/models.dev adds them
This bridge fixes both authentication and model discovery:
| Layer | What it does |
|---|---|
| JWT Patch | Reads VS Code's Copilot token, exchanges it for a JWT via copilot_internal/v2/token, and uses that for API calls |
| Header Fix | Removes the Openai-Intent header that blocks certain models, adds required Copilot headers |
| Model Discovery | Queries the Copilot /models API to auto-discover and configure models missing from OpenCode |
- Windows x64 (macOS/Linux support planned)
- VS Code with GitHub Copilot extension, signed in
- GitHub Copilot subscription (Pro, Business, or Enterprise)
- Bun runtime (for model discovery script)
Works on PowerShell 5.1, 7.x, and newer — just copy & paste:
# Install stable bridge (Desktop Stable + CLI) — default
irm https://raw.githubusercontent.com/templarsco/opencode-copilot-bridge/main/scripts/install-bridge.ps1 | iex
# Install beta bridge (Desktop Beta)
$env:BRIDGE_CHANNEL='beta'; irm https://raw.githubusercontent.com/templarsco/opencode-copilot-bridge/main/scripts/install-bridge.ps1 | iex
# Install both stable and beta
$env:BRIDGE_CHANNEL='all'; irm https://raw.githubusercontent.com/templarsco/opencode-copilot-bridge/main/scripts/install-bridge.ps1 | iex
# Uninstall (restore original binaries)
$env:BRIDGE_UNINSTALL='1'; irm https://raw.githubusercontent.com/templarsco/opencode-copilot-bridge/main/scripts/install-bridge.ps1 | iexThis wizard automatically:
- Downloads the latest bridge binary for the selected channel
- Closes any running OpenCode instances
- Backs up original binaries (
.original) - Replaces sidecars in the appropriate installations:
- Stable: Desktop Stable (
%LOCALAPPDATA%\OpenCode\) + CLI (%USERPROFILE%\.bun\bin\) - Beta: Desktop Beta (
%LOCALAPPDATA%\OpenCode Beta\)
- Stable: Desktop Stable (
- Restarts Desktop apps
- Download the latest
.exefrom Releases:- Stable:
opencode-copilot-bridge-*-stable-windows-x64.exe - Beta:
opencode-copilot-bridge-*-beta-windows-x64.exe
- Stable:
- Close OpenCode (all instances)
- Replace your installed OpenCode binary:
# Desktop Stable sidecar (use stable binary) copy opencode-copilot-bridge-*-stable-*.exe "%LOCALAPPDATA%\OpenCode\opencode-cli.exe" # Desktop Beta sidecar (use beta binary) copy opencode-copilot-bridge-*-beta-*.exe "%LOCALAPPDATA%\OpenCode Beta\opencode-cli.exe" # CLI (use stable binary) copy opencode-copilot-bridge-*-stable-*.exe "%USERPROFILE%\.bun\bin\opencode.exe" - Restart OpenCode
- Clone this repo and the OpenCode source:
git clone https://github.com/templarsco/opencode-copilot-bridge.git git clone <opencode-source-repo>
- Apply the patch and build:
.\opencode-copilot-bridge\scripts\apply-patch.ps1
- Binary is at
packages/opencode/dist/opencode-windows-x64/bin/opencode.exe
The discover-models.ts script queries GitHub Copilot's API to find all available models and generates OpenCode configuration for any that are missing.
# List all models available in your Copilot subscription
bun run scripts/discover-models.ts
# Show only models that need configuration
bun run scripts/discover-models.ts --diff
# Auto-add missing models to your opencode.json
bun run scripts/discover-models.ts --apply
# Output raw API response (for debugging)
bun run scripts/discover-models.ts --json
# Use a custom config path
bun run scripts/discover-models.ts --apply --config "C:\path\to\opencode.json"The script automatically:
- Reads your VS Code Copilot OAuth token from
%LOCALAPPDATA%\github-copilot\apps.json - Exchanges it for a short-lived JWT (valid ~30 minutes)
- Queries
https://api.githubcopilot.com/modelsfor the full model catalog - Maps Copilot model specs (context window, capabilities, reasoning) to OpenCode format
- Writes missing models to your
opencode.jsonconfig
Run this script whenever:
- You suspect new models are available in VS Code but not in OpenCode
- After updating your Copilot subscription tier
- After a new OpenCode release (to check for newly supported models)
VS Code Copilot Extension
↓ (stores OAuth token)
%LOCALAPPDATA%\github-copilot\apps.json
↓ (read by bridge)
GET api.github.com/copilot_internal/v2/token
↓ (returns JWT, ~30 min TTL)
Bearer {JWT} → api.githubcopilot.com/chat/completions
The JWT is cached in-memory and auto-refreshed 5 minutes before expiry. If the JWT can't be obtained (VS Code not signed in, etc.), it falls back to OpenCode's standard OAuth token.
| Header | Before (blocks models) | After (works) |
|---|---|---|
Authorization |
Bearer {gho_token} |
Bearer {JWT} |
Openai-Intent |
conversation-edits |
(removed) |
Copilot-Integration-Id |
(missing) | vscode-chat |
Editor-Version |
(missing) | vscode/1.107.0 |
Openai-Organization |
(missing) | github-copilot |
Models are added to ~/.config/opencode/opencode.json under the github-copilot provider:
{
"provider": {
"github-copilot": {
"models": {
"claude-opus-4.6-fast": {
"name": "Claude Opus 4.6 (fast mode)",
"attachment": true,
"reasoning": true,
"temperature": true,
"tool_call": true,
"modalities": { "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 200000, "input": 128000, "output": 64000 },
"variants": {
"low": { "budgetTokens": 1024 },
"medium": { "budgetTokens": 10240 },
"high": { "budgetTokens": 32000 },
"max": { "budgetTokens": 64000 }
}
}
}
}
}
}See config/opencode.json.example for a full example.
This repo includes a GitHub Actions workflow that tracks both channels:
| Channel | Source | Tag Pattern | Check Frequency |
|---|---|---|---|
| Stable | anomalyco/opencode |
bridge-v1.2.x |
Every 6 hours |
| Beta | anomalyco/opencode-beta |
bridge-beta-YYYYMMDDHHMM |
Every 6 hours |
For each channel, the CI:
- Checks for new upstream releases
- Clones the release tag (via
OPENCODE_PATsecret), applies the patch, builds a Windows binary - Creates a tagged release with the patched
.exe
The CI needs access to both OpenCode source repositories. Add a GitHub PAT as a secret:
- Go to Settings → Secrets and variables → Actions
- Add secret
OPENCODE_PATwith a PAT that hasreposcope and read access toanomalyco/opencodeANDanomalyco/opencode-beta
You can also trigger a build manually from the Actions tab, choosing to build stable, beta, or both.
- Ensure VS Code is signed into GitHub Copilot (check the Copilot icon in the status bar)
- Run
bun run scripts/discover-models.ts --jsonto verify the model appears in the API - Check that the model is configured in
opencode.json
- Verify
%LOCALAPPDATA%\github-copilot\apps.jsonexists and contains a token - Try signing out and back into GitHub Copilot in VS Code
- Check your Copilot subscription is active
- The patch is based on a specific OpenCode version and may need updating
- Check the latest release for an updated patch
- Or use a pre-built binary from releases
- Three OAuth apps discovered: OpenCode (
Ov23li8tweQw6odWQebz, 35 models), Legacy (Iv1.b507a08c87ecfe98, 35 models), VS Code (Ov23liV9UpD7Rnfnskm3, 40+ models with exchange support) - The
Openai-Intentheader blocks certain models (claude-opus-4.6-fastand potentially others). Removing it entirely fixes the issue. - JWT lifetime: ~30 minutes. Auto-refreshed with a 5-minute buffer before expiry.
- Fallback: If JWT exchange fails, the bridge falls back to OpenCode's standard
gho_token. Models requiring JWT will not work, but standard models remain functional.
MIT