Skip to content

config: allow an explicit model whitelist, with OpenRouter presets as first-class model definitions #64560

Open

Description

@BenKingAffinity

Summary

V2 can only subtract from the model catalog (disabled: true per model). Anyone who wants a curated list must enumerate and disable everything else — 364 entries for a 7-model list here — and the allowlist silently rots as new catalog models appear enabled by default. At the same time, OpenRouter presets (@preset/<slug>) have no first-class representation: the only working spelling is an undocumented body: { preset } merge, which is silently ignored when the request model differs from the model the preset resolves to.

Environment

  • opencode version: 2.3.1
  • OS: Microsoft Windows NT 10.0.26200.0 (win32 x64)
  • Terminal: OpenCode Desktop (Electron)
  • Shell: C:\WINDOWS\system32\cmd.exe (PowerShell 7.7.0 host)
  • Install/channel: desktop install, latest
  • Active plugins: none

Reproduction

  1. Connect the openrouter provider. opencode models reports 371 models (359 openrouter + 12 opencode).

  2. Want a 7-model list: 4 OpenRouter presets plus 3 plain models.

  3. Attach a preset the only way config permits today:

    "providers": {
      "openrouter": {
        "models": {
          "z-ai/glm-5.3-flash": { "body": { "preset": "@preset/glm-5-3-flash-coding-test" } }
        }
      }
    }
  4. Disable the other 364 models one by one. The resulting opencode.jsonc is 29 KB.

  5. Add a model to the catalog upstream (or connect another provider) and it comes back enabled, because absence from config means enabled.

Expected Behavior

  • A way to declare the models I offer, rather than the models I refuse:

    "providers": {
      "openrouter": {
        "allow": ["deepseek/deepseek-v4.1-flash-1017", "z-ai/glm-5.2", "z-ai/glm-5.3", "z-ai/glm-5.3-flash"]
      }
    }

    Unlisted models would be hidden on the same paths disabled: true already hides them. New catalog models would appear only when explicitly allowed.

  • OpenRouter presets as first-class model entries, one per preset, picker label included, with catalog metadata inherited from the model the preset resolves to:

    "providers": {
      "openrouter": {
        "presets": {
          "deepseek-flash":  { "preset": "@preset/deep-seek-v4-1-flash-1017", "name": "DeepSeek V4.1 Flash" },
          "glm-5-3-reason":  { "preset": "@preset/glm-5-3-reasoning-test",   "name": "GLM 5.3 Reasoning" }
        }
      }
    }

    Selectable as openrouter/deepseek-flash, with limit, cost, capabilities and reasoning variants inherited rather than guessed.

Actual Behavior

  • Only disabled: true exists, so curation is a denylist of everything else. 364 entries, and every catalog addition silently widens the list of models we did not approve.
  • body.preset works but is undocumented for this purpose, is not validated (an unknown field is merged silently), and is defeated whenever the request model differs from the preset's model, because OpenRouter shallow-merges request fields over preset fields and request wins. A preset with a fallback array therefore cannot be expressed this way at all.
  • Setting a preset alias instead ("modelID": "@preset/<slug>") makes the preset authoritative but throws away catalog metadata: OpenCode then assumes 200k context / 32k output / unknown cost, so the picker and spend estimates are wrong for the model actually being used.
  • openrouter/@preset/<slug> as a model reference is rejected (requires openrouter/<catalog-key>), which is the original ask in [feature request] support openrouter presets #1439.

Additional Context

  • Presets matter commercially here: pinning provider routing through a preset raised cache-hit rate enough to cut cost by roughly 10% versus calling the same model directly, so teams want every session, subagent and command to go through a preset named in configuration.
  • Presets are workspace-scoped on the OpenRouter side, so a committed opencode.json referencing @preset/... is the natural way to give every dev identical routing — provided the key can't silently fall back to a non-preset path.
  • Workaround in use: a generator script emits the 364 disabled entries plus the four body.preset entries, and rewrites the config from a curated source list. It works, verified by opencode models returning exactly 7 and preset turns resolving, but it is 29 KB of generated config standing in for one config key.
  • Related: catalog metadata in opencode models only lists what the config leaves enabled, so after the denylist is applied the CLI can no longer report the full catalog. That makes any regeneration script depend on a cached copy of the catalog to avoid quietly re-enabling everything on its second run.

Activity

  1. opencodejr commented on Nov 18, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up and the numbers behind it. You're asking for two things:

    1. A per-provider allowlist, so a curated model list stays closed when new models are added to the catalog.
    2. OpenRouter presets as first-class model entries, with their own picker name, that inherit limits, cost, capabilities and variants from the model the preset resolves to.

    Maintainers will consider it.

    What you describe matches the current docs. In V2 a model is hidden with disabled: true on that model (providers docs). V2 ignores the V1 whitelist/blacklist fields (migration guide). A model that isn't in the catalog falls back to a 200,000-token context and 32,000-token output limit (models docs).

    Related issues, ordered by likelihood:

  2. added
    area/providers
    type/feature
    version/v2
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/providersplatform/windowstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions