Uh oh!
There was an error while loading. Please reload this page.
feat(opencode): add local server provider with auto model discovery - #19959
feat(opencode): add local server provider with auto model discovery#19959hmblair wants to merge 2 commits into
Conversation
Add a custom loader for a "local" provider that auto-discovers models from any OpenAI-compatible local server (llama.cpp, ollama, vLLM, LM Studio, etc.) by querying the standard /v1/models endpoint at startup. Users configure only a baseURL and optional apiKey — no manual model listing required. Discovered models are merged with any manually configured models without overwriting them. Closesanomalyco#6231
…local provider tests The CUSTOM_LOADERS loop skipped providers not registered in models.dev, which prevented the local provider from ever being invoked. Create a stub Info as a fallback so custom loaders can bootstrap themselves. Adds three tests for the local provider: successful auto-discovery, unreachable endpoint, and missing baseURL.
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
|
LifetimeVip
commented
Jun 12, 2026
Thanks for this clean PR. One suggestion: some local servers (like LM Studio) expose the model list at /v1/models rather than /models. Adding a fallback to try /v1/models first, then /models, would improve compatibility with more providers. |
cjdell
commented
Aug 13, 2026
+1 for this PR. Awkward having to edit JSON files on all the machines that use the llama.cpp box. I'm always trying new models so having auto-discover is more useful than it sounds. |
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes#6231
Type of change
What does this PR do?
Adds a
localprovider toCUSTOM_LOADERSthat auto-discovers models from any OpenAI-compatible/v1/modelsendpoint at startup. When configured with abaseURL, it fetches the model list, registers each model, and returnsautoload: true. If the endpoint is unreachable or returns nothing, it returnsautoload: falseand the provider is silently skipped.Also fixes the
CUSTOM_LOADERSloop to allow custom loaders that don't have a models.dev entry — previously they were silently skipped becausedatabase[providerID]returned undefined and the loop hitcontinue.Usage:
{ "provider": { "local": { "options": { "baseURL": "http://localhost:11434/v1", "apiKey": "optional-key" } } } }This is an alternative to #17670 that solves the same problem in ~50 lines with no new config surface.
How did you verify your code works?
Three tests covering:
/modelsendpointbaseURLis not configuredTested locally against llama-server and LM Studio.
Screenshots / recordings
N/A — no UI changes.
Checklist