Skip to content

[FEATURE]: Auto-discover models from OpenAI-compatible providers #27553

Closed as duplicate

Description

@androidand

Describe the enhancement you want to request

OpenAI-compatible providers configured with a baseURL (e.g. llama-swap, Ollama, LM Studio) serve a /v1/models endpoint that lists their available models. Right now you have to list every model manually in opencode.json, which means the config goes stale every time you swap a model on the backend.

This PR adds auto-discovery: on startup, OpenCode calls GET /v1/models for each @ai-sdk/openai-compatible provider that has a baseURL and no statically configured models. It reads id, name, context_length/max_context_length, and max_output_tokens from the response. Manually configured models always win (non-destructive merge), and opt-out is discoverModels: false in the provider config.

Discovery runs in parallel across providers with a 2-second timeout per request, so offline servers don't slow startup. Errors are swallowed silently.

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

Activity

  1. changed the title [-]feat: auto-discover models from openai-compatible providers[/-] [+][FEATURE]: Auto-discover models from OpenAI-compatible providers[/+] on May 14, 2026
  2. github-actions commented on May 14, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets our contributing guidelines. We appreciate you taking the time to fix it.

  3. Logicwax commented on Aug 14, 2026

    @Logicwax

    see this

    https://github.com/MohammadMD1383/opencode-dynamic-config

    That's quite a Rube Goldberg way of going about it lol but it works! Would be great to have this integrated into opencode though

  4. yuhp commented on Sep 11, 2026

    @yuhp

    This use case is already supported by the community plugin:

    https://github.com/yuhp/opencode-models-discovery

    The plugin discovers models from /v1/models for configured @ai-sdk/openai-compatible providers and injects them into provider.<name>.models during the config hook.

    It supports provider-specific endpoints, timeouts, model filtering, OpenCode /connect credentials, optional persisted caching, and provider-specific metadata enrichment. Explicitly configured models are preserved and take precedence over discovered values.

    Example:

    {
      "plugin": ["opencode-models-discovery@latest"],
      "provider": {
        "my-provider": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "My Provider",
          "options": {
            "baseURL": "http://127.0.0.1:1234/v1",
            "modelsDiscovery": {
              "enabled": true
            }
          }
        }
      }
    }
  5. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #6231, which tracks discovering models automatically from OpenAI-compatible /v1/models endpoints. Please add your use case and 👍 there.

    In OpenCode v2, LM Studio, Ollama and vLLM already discover their models automatically (#42607 added LM Studio). Generic OpenAI-compatible providers don't yet.

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