anomalyco / anomalyco/opencode
fix(github-copilot): Grok models get endpoint error due to defaulting to generic OpenAI SDK
@nexxeln is already working on this.
Since Aug 22, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Problem
GitHub Copilot Grok models (e.g. copilot-grok-4.6) get an "endpoint error" when used through the opencode CLI. The models are resolved from models.opencode.ai and inherit the generic @ai-sdk/openai-compatible SDK via the GitHub Copilot provider-level npm field, instead of the custom @ai-sdk/github-copilot SDK.
The custom SDK is required to send requests with the correct URL path, headers, and error handling for the GitHub Copilot API.
Root Cause
In fromModelsDevModel() at packages/opencode/src/provider/provider.ts, the npm fallback chain resolves provider.npm ?? "@ai-sdk/openai-compatible". For the github-copilot provider, provider.npm is "@ai-sdk/openai-compatible" (truthy), so the custom @ai-sdk/github-copilot SDK is never selected.
Fix
Three targeted changes:
-
provider.ts(2 locations) — Override the npm to@ai-sdk/github-copilotforgithub-copilotprovider, before falling back toprovider.npm. Both the catalog path (fromModelsDevModel) and the config-defined model path (apiNpmassignment) are covered. -
model.ts:fromCatalogModel— Allow@ai-sdk/github-copilotpackage through the sameOpenAICompatibleChat.routethat@ai-sdk/openai-compatibleuses. -
model.ts:supported— Include@ai-sdk/github-copilotalongside@ai-sdk/openai-compatiblein the support check.
Files Changed
packages/opencode/src/provider/provider.ts(2 hunks: fromModelsDevModel + config path)packages/core/src/session/runner/model.ts(2 hunks: fromCatalogModel + supported)
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.
Assessment
This issue has not been assessed yet.