forked from sst/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: auto-discover models from any OpenAI-compatible provider #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
agustif
wants to merge
462
commits into
dev
Choose a base branch
from
openai-compatible-discovery
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
…viders that were bugged
- Add real-time model discovery from LM Studio /v1/models endpoint - Load actual models instead of fake documentation examples - Discover models only when lmstudio provider is configured - Graceful fallback on connection errors with debug logging
- Use LM Studio API v0 /api/v0/models endpoint for richer metadata - Extract real model type (llm, vlm, embeddings) from API - Use actual max_context_length from LM Studio instead of hardcoded values - Set architecture (family) from model.arch field - Detect vision capabilities from model.type === 'vlm' - Handle embeddings models with text-only capabilities - Fallback to OpenAI-compatible API if v0 unavailable
- Uses API v0 for rich model metadata (type, arch, context, etc) - Also calls v1 API for additional fields (created, owned_by) - Merges data from both endpoints for comprehensive model info - Graceful fallback if either API fails
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
@ai-sdk/openai-compatible/v1/modelsand Ollama-style/api/tagsendpointsKey Features
✅ Universal Detection: Scans all providers for
@ai-sdk/openai-compatiblenpm package✅ Multi-Endpoint Support: Handles OpenAI
{data:[...]}and Ollama{models:[...]}formats✅ Smart Inference: Detects vision, reasoning, embedding models from naming patterns
✅ Context Detection: Parses "128k", "32k" etc. from model IDs
✅ Resilient: 5s timeout, graceful failures, preserves manual configs
✅ Minimal Implementation: ~150 lines replacing complex special case logic
Testing Results
/modelsendpoint (expected behavior)Provider Support
Works with any OpenAI-compatible server:
/api/tagsfallback)/v1/modelsendpointThis makes any OpenAI-compatible provider "just work" without requiring manual model lists or special handling.