Skip to content

[FEATURE]:Model de-duplication/grouping + provider priority routing with seamless failover (cost/quota-aware) #14739

@Nikain

Description

@Nikain

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Background / Problem

In OpenCode, the available model list can come from multiple providers/entry points (e.g., Claude Subscription, GitHub Copilot, various API providers). This often leads to:

  1. Duplicate models in the UI: the same underlying model (e.g., Opus 4.6) appears multiple times because it is offered by different providers, making selection confusing.
  2. No way to express billing/quota priority: users may want to consume the “cheapest / already-paid / subscription quota” first (e.g., Claude Pro subscription) and only fall back to pay-as-you-go APIs later.
  3. Manual switching is disruptive: when a provider hits quota limits, rate limits, or temporary outages, users must manually change the provider/model, breaking workflow and reliability.

Request / Desired Behavior

Add a mechanism to group/merge models by the underlying model identity, and within a merged model, automatically route requests through a user-defined provider priority order, with transparent failover to the next provider offering the same model.

Example desired flow

  • User selects a single merged model: “Opus 4.6”
  • Actual routing priority configured by user:
    1. Claude Subscription Pro
    2. GitHub Copilot
    3. API Provider A
    4. API Provider B
  • When the first provider is out of quota / unavailable / rate-limited, OpenCode automatically switches to the next provider for the same model.
  • Switching should be seamless and “invisible” to the user (no manual action required).

Proposed Solution (High-level)

1) Model De-duplication / Grouping (Model Group / Alias)

Introduce a “Model Group / Alias” concept:

  • UI/config shows one model entry: e.g., opus-4.6 (or user-defined alias like opus46)
  • The group contains multiple provider-backed implementations of the same model:
    • provider=claude_subscription_pro, model=opus-4.6
    • provider=github_copilot, model=opus-4.6
    • provider=api_provider_a, model=opus-4.6
  • Grouping rules:
    • Prefer provider-supplied canonical model id when available
    • Also allow manual mapping/merging, since naming can differ across providers

2) Provider Priority Order (Cost/Quota-aware)

For each model group, allow configuring a provider priority list (user adjustable), e.g.:

  1. claude_subscription_pro
  2. github_copilot
  3. api_provider_a
  4. api_provider_b

3) Seamless Failover (Transparent fallback)

At request time:

  • Try the highest priority provider first
  • Automatically fall back on:
    • quota/credits exhausted (quota exceeded, insufficient credits, etc.)
    • provider unavailable or timeout
    • 429 rate limit (optionally after retry/backoff)
    • auth failure (optionally surface a warning but still allow fallback where possible)
  • Keep the user-facing selection stable:
    • The model remains “Opus 4.6” (merged model)
    • Optionally log/telemetry records the actual provider used (for debugging)

UX / UI Suggestions

  • Default model list shows only merged models; add a toggle to “show all provider variants”
  • Model details page:
    • list all providers available for the merged model
    • allow reordering provider priority
    • show provider health/status (available / rate limited / quota exhausted / missing token, etc.)
  • Runtime (optional):
    • status indicator like: “Opus 4.6 (via Claude Pro)” (can be hidden)

Example Config (concept)

Illustrative only; adapt to OpenCode’s existing config format.

models:
  - alias: opus-4.6
    group:
      - provider: claude_subscription_pro
        model: opus-4.6
      - provider: github_copilot
        model: opus-4.6
      - provider: api_provider_a
        model: opus-4.6
    routing:
      sticky_mode: session   # optional: none | session | time_window
      allow_feature_downgrade: false
    failover:
      on:
        - quota_exceeded
        - rate_limited
        - provider_unavailable
        - timeout
      retry:
        attempts: 1
        backoff_ms: 300

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions