anomalyco / anomalyco/opencode

fix(github-copilot): Grok models get endpoint error due to defaulting to generic OpenAI SDK

Open
#44,103 1 comment 0 reactions 1 assignee View on GitHub

@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:

  1. provider.ts (2 locations) — Override the npm to @ai-sdk/github-copilot for github-copilot provider, before falling back to provider.npm. Both the catalog path (fromModelsDevModel) and the config-defined model path (apiNpm assignment) are covered.

  2. model.ts:fromCatalogModel — Allow @ai-sdk/github-copilot package through the same OpenAICompatibleChat.route that @ai-sdk/openai-compatible uses.

  3. model.ts:supported — Include @ai-sdk/github-copilot alongside @ai-sdk/openai-compatible in 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.