Skip to content

Conversation

@agustif
Copy link
Owner

@agustif agustif commented Dec 19, 2025

Summary

  • Implements generic model discovery for any provider using @ai-sdk/openai-compatible
  • Attempts both standard /v1/models and Ollama-style /api/tags endpoints
  • Eliminates need for provider-specific special cases (like LM Studio)
  • Gracefully handles connection failures and unsupported endpoints

Key Features

Universal Detection: Scans all providers for @ai-sdk/openai-compatible npm 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

  • ✅ OpenRouter: 350 models discovered
  • ✅ OpenCode (zen): 22 models discovered
  • ✅ IO-Net: 18 models discovered
  • ❌ LM Studio: Graceful failure when localhost not running
  • ❌ ZAI: No /models endpoint (expected behavior)

Provider Support

Works with any OpenAI-compatible server:

  • OpenAI, OpenRouter, vLLM, Together AI, Groq
  • Ollama (via /api/tags fallback)
  • Custom deployments using standard OpenAI format
  • Local LLM servers with /v1/models endpoint

This makes any OpenAI-compatible provider "just work" without requiring manual model lists or special handling.

actions-user and others added 30 commits December 15, 2025 16:57
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]>
adamdotdevin and others added 30 commits December 18, 2025 11:16
- 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.