anomalyco / anomalyco/opencode
github-copilot plugin does not see Enterprise BYOK models
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Github Copilot API is hiding models unless a specific set of headers are provided.
- https://api.githubcopilot.com/models does not list the model
- https://api.githubcopilot.com/chat/completions does not recognize the model as supported
The specific header missing is:
Copilot-Integration-Id: vscode-chat
This header should be provided to /models and /chat/completions.
This header was provided in the past, but that change got squashed as a result of this refactor:
- a433766a31fbf5c0597aec757de59a3d882c02fa
As the API mostly works, this limitations has gone unnoticed.
In my testing, the issue can be resolved by changing packages/opencode/src/plugin/github-copilot/copilot.ts, function CopilotAuthPlugin:
return CopilotModels.get(
base(auth.enterpriseUrl),
{
...(provider.options?.headers as Record<string, string> | undefined),
Authorization: `Bearer ${auth.refresh}`,
"User-Agent": `opencode/${InstallationVersion}`,
"X-GitHub-Api-Version": API_VERSION,
+ "Copilot-Integration-Id": "vscode-chat",
},
provider.models,
)
I tested the fix on dev. There may be other fixes to github-copilot that are queued on dev, not yet released in 2.0.10, that are also necessary to resolved this problem.
Plugins
github-copilot
OpenCode version
2.0.10
Steps to reproduce
- Enable Github Copilot Enterprise BYOK with one or more custom models.
- Confirm the models shows up in VS Code.
- Confirm the models are absent from OpenCode after /connect.
After the fix, the models should be listed and selectable without any customization to opencode.json.
Screenshot and/or share link
Not useful.
Operating System
EL 8
Terminal
Xfce4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/opencode/src/plugin/github-copilot/copilot.ts at CopilotAuthPlugin and inspect how headers are passed to CopilotModels.get for /models and /chat/completions. Reproduce with an Enterprise BYOK custom model, then verify the model is listed and selectable after connecting without opencode.json customization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100