Skip to content

Custom models for models.dev providers silently ignored, falls back to most expensive model #20743

Closed as not planned

Description

@alexsiri7

Bug

When defining custom models in opencode.json for a provider that exists in models.dev (e.g. requesty), the custom model is silently ignored. OpenCode falls back to the most expensive/capable model from the models.dev snapshot instead. No error or warning is shown.

Reproduction

  1. Create opencode.json:
{
  "provider": {
    "requesty": {
      "models": {
        "google/gemini-3.1-flash-lite-preview": {
          "name": "Gemini 3.1 Flash Lite",
          "id": "google/gemini-3.1-flash-lite-preview"
        }
      }
    }
  },
  "model": "requesty/google/gemini-3.1-flash-lite-preview"
}
  1. Set REQUESTY_API_KEY and run:
opencode --model requesty/google/gemini-3.1-flash-lite-preview
  1. Expected: Uses google/gemini-3.1-flash-lite-preview ($0.25/M input)
  2. Actual: Uses google/gemini-3-pro-preview ($2/M input) — the most expensive model in the Requesty snapshot

The --model flag, the config model field, and the custom model definition are all silently ignored.

Root cause

In provider.ts, the defaultModel() function (line ~1564) checks cfg.model and calls parseModel() to get { providerID, modelID }. The TUI then validates this with isModelValid() which checks provider.models[modelID].

The custom model IS merged into the provider's models map during config loading (line ~1043). But the model key in the snapshot uses a different internal ID than what parseModel() produces, so isModelValid() returns false and the selection falls through to sort(Object.values(provider.models)) which picks the "best" (most expensive) model.

The model google/gemini-3.1-flash-lite-preview exists on Requesty's API and works fine via curl, but isn't in the models.dev snapshot for the requesty provider. Adding it via config should work per the docs but doesn't.

Impact

Users unknowingly burn 8-10x more money than intended. In our case, a witness agent meant to run on a $0.25/M model was running on a $2/M model, costing $1+ in minutes with no indication anything was wrong.

Environment

  • opencode v1.3.13
  • Provider: requesty (exists in models.dev)
  • Custom model: google/gemini-3.1-flash-lite-preview (not in models.dev snapshot for requesty)

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 2, 2026
  2. github-actions commented on Apr 2, 2026

    @github-actions
    Contributor

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

    If any of these cover your issue, please consider adding a comment there rather than opening a new report.

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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