Skip to content

Feature request: Plugin hook for filtering models at startup #27738

@shubham-bansal-jswone

Description

@shubham-bansal-jswone

Feature Request

Problem

Currently, OpenCode loads all models from all connected providers at startup. There is no plugin hook that allows filtering or excluding specific models from the model list before they appear in the /models selector.

The existing blacklist/whitelist fields in the provider config work on a per-provider basis, but there's no way to apply a global filter across all providers via a plugin.

Use Case

I want to exclude all Claude/Anthropic models from every provider's model list. With 40+ providers that include Claude models, adding a blacklist to each provider's config is impractical. A plugin hook would allow a single filter to apply across all providers.

Proposed Solution

Add a new plugin hook that fires during model loading, allowing plugins to filter the model list:

export const ModelFilterPlugin = async () => {
  return {
    "model.list": async (input, output) => {
      // input: { providerID: string, models: Model[] }
      // output: { models: Model[] }
      output.models = output.models.filter(
        m => !m.name.toLowerCase().includes("claude") && 
             !m.id.toLowerCase().includes("anthropic")
      )
    },
  }
}

Alternative

If a dedicated hook isn't feasible, consider:

  1. A global disabled_models config field that accepts patterns (e.g., ["*claude*", "*anthropic*"])
  2. A model.filter event that plugins can subscribe to

Context

  • Plugin hooks currently cover: messages, sessions, tools, files, permissions, shell env, etc.
  • No model-related hooks exist
  • The blacklist/whitelist provider config fields exist but are per-provider and require manual configuration for each provider

Metadata

Metadata

Assignees

Labels

No labels
No labels

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