GeezerVison is showing github.com — feat(opencode): auto-discover models from OpenAI-compatible providers by sethjones · Pull Request #2 · sethjones/opencode
Conversation
sethjones
commented
Jun 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Type of change
What does this PR do?
Auto-discovers available models from OpenAI-compatible providers that have a baseURL configured in opencode.json. Instead of requiring users to list every model manually, opencode now calls GET /v1/models at startup and populates the model list.
Models come from three sources: Models.dev (metadata), config file (overrides), and the provider API (actual availability). A model is visible only if the provider API returns it or it is declared in config. Metadata is merged with API > config > Models.dev precedence.
This means providers like LM Studio, Ollama, and self-hosted OpenAI-compatible servers automatically show their loaded models without any per-model configuration.
How did you verify your code works?
- Built a standalone binary and ran it with an LM Studio server configured via
baseURL
- Confirmed models appear in the TUI
/models list without manual per-model config
- Confirmed models not returned by the provider API are hidden, even if listed in Models.dev
- Confirmed startup completes without hanging or displaying discovery output to the terminal
- Ran
bun typecheck from packages/opencode — passes
- Ran provider tests — pass
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.
zbndev and mimi1vx reacted with thumbs up emoji
- Fetch models from OpenAI-compatible providers with baseURL in config
- Support plugin-registered discovery loaders (e.g., GitLab)
- Discovery runs synchronously during bootstrap init
- Remove providers with no models after successful discovery
- Add tests for discovery and model registration
sethjones
changed the title
Custom model discovery
feat(opencode): auto-discover models from OpenAI-compatible providers
Jun 15, 2026
- Extract discoverProviderModels() helper from inline 110-line Effect.gen
- Replace globalThis.fetch with HttpClient layer (FetchHttpClient)
- Add Effect.timeout(10s) to HTTP discovery requests
- Replace Exit._tag with Exit.isSuccess/IsFailure
- Remove redundant config.get() in init() (use captured s.cfg)
- Remove unnecessary 'as any' casts
- Fix indentation to consistent 2-space
- Set family: 'discovered' on discovered models
- Update discovery tests to use HttpClient layer mocks
…nai-compatible schemas
- Log warning and continue when provider disappears between discovery snapshot and apply
- Add @ai-sdk/openai-compatible to schema sanitization check
- Add test case for openai-compatible schema sanitization
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.