GeezerVison is showing github.com — fix(opencode): auto-discover models for OpenAI-compatible custom providers · Pull Request #32079 · anomalyco/opencode
Conversation
ghost
commented
Jun 12, 2026
•
edited by ghost
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #32076
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
When a user configures a custom provider (e.g. LM Studio, Ollama, llama.cpp) with a baseURL in opencode.json, automatically fetch the model list from GET /v1/models or /models at startup and register discovered models.
The discovery runs for any user-configured provider (source: "config") that has an explicit baseURL in options. It first tries /v1/models (OpenAI standard), then falls back to /models. If an API key is stored, it is passed as a Bearer token.
Discovered models do not overwrite manually defined ones. If the endpoint is unreachable or returns nothing, the discovery is silently skipped.
Previously only the 3 LM Studio models hardcoded in the models.dev catalog would appear. Now all models loaded in LM Studio are visible in the UI.
How did you verify your code works?
- Ran bun run typecheck (passes with no errors)
- Reviewed the initialization flow to ensure the discovery runs after config providers are merged and before the final provider model filtering loop
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…iders
When a user configures a custom OpenAI-compatible provider (e.g. LM Studio) with a baseURL in opencode.json, automatically fetch the model list from GET {baseURL}/models and register discovered models.
Previously only GitLab had discoverModels support. This adds generic discovery for any user-configured provider using @ai-sdk/openai-compatible with an explicit baseURL option.
|
The following comment was made by an LLM, it may be inaccurate:
Potential Related PRs Found
Based on the search results, here are related PRs that may have overlapping functionality:
-
PR feat(opencode): local LAN provider discovery + auto-discover models #27554 - feat(opencode): local LAN provider discovery + auto-discover models
- Implements similar auto-discovery functionality for local LAN providers, including model discovery at startup
-
PR feat(opencode): add local server provider with auto model discovery #19959 - feat(opencode): add local server provider with auto model discovery
- Adds a local server provider with automatic model discovery capability
-
PR feat(opencode): add LiteLLM provider with auto model discovery #14468 - feat(opencode): add LiteLLM provider with auto model discovery
- Implements auto model discovery for the LiteLLM provider
These PRs appear to address similar functionality—discovering and registering models from external providers at startup. PR #27554 in particular seems most closely related as it covers both local LAN discovery and auto-discovering models from compatible endpoints.
You may want to check if PR #27554 already handles the OpenAI-compatible custom provider scenario, or if there's complementary functionality being added in PR #32079.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…h baseURL
Remove the hasOpenAICompatible check on provider.models (caused deadlock when no models pre-configured). Now any user-configured provider with an explicit baseURL will attempt model discovery via /v1/models or /models endpoint.
|
Closing this PR. There are already existing PRs (#19959, #27554) that address the same issue with better approaches. Will contribute there instead.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This pull request was closed.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.