You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Auto-discover models from OpenAI-compatible providers #27553
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.
Reacted by Tim, Joost R., Quino Terrasa, Kevin Cox, MeIchthys, Arman, 2048khz-gachi-rmx, MrPandir, abhineetgupta, xiuc and 3 more
changed the title [-]feat: auto-discover models from openai-compatible providers[/-][+][FEATURE]: Auto-discover models from OpenAI-compatible providers[/+]on May 14, 2026
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.
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.
Activity
[-]feat: auto-discover models from openai-compatible providers[/-][+][FEATURE]: Auto-discover models from OpenAI-compatible providers[/+]github-actions commentedon May 14, 2026
Thanks for updating the issue! It now meets our contributing guidelines. We appreciate you taking the time to fix it.
MohammadMD1383 commentedon Jun 17, 2026
see this
https://github.com/MohammadMD1383/opencode-dynamic-config
Logicwax commentedon Aug 14, 2026
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
yuhp commentedon Sep 11, 2026
This use case is already supported by the community plugin:
https://github.com/yuhp/opencode-models-discovery
The plugin discovers models from
/v1/modelsfor configured@ai-sdk/openai-compatibleproviders and injects them intoprovider.<name>.modelsduring the config hook.It supports provider-specific endpoints, timeouts, model filtering, OpenCode
/connectcredentials, 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 } } } } }neriousy commentedon Oct 1, 2026
Closing as a duplicate of #6231, which tracks discovering models automatically from OpenAI-compatible
/v1/modelsendpoints. 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.