Skip to content

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

Closed

Description

@munim

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)

Activity

  1. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions