Skip to content

feat(provider): discover models for openai-compatible providers - #48486

Closed
nikakoy131 wants to merge 1 commit into
anomalyco:devfrom
nikakoy131:openai-model-discovery
Closed

feat(provider): discover models for openai-compatible providers#48486
nikakoy131 wants to merge 1 commit into
anomalyco:devfrom
nikakoy131:openai-model-discovery

Conversation

@nikakoy131

Copy link
Copy Markdown

Adds automatic model discovery for OpenAI-compatible providers.

Changes

  • Providers configured with a baseURL and no explicit models (using @ai-sdk/openai-compatible, explicitly or by default) are probed via GET <baseURL>/models during provider init. Discovered entries are mapped to model definitions (id, name, modalities from input_modalities, zero-cost defaults) and merged with any manually configured models — manual entries always win.
  • Discovery failures (network error, non-200, malformed payload) are treated as "no models"; providers ending up with zero models are filtered out, and defaultModelIDs no longer throws for empty provider maps.
  • When discovery returns nothing but the provider already has models (e.g. a catalog provider pointed at an unreachable endpoint), existing models are preserved.
  • New Provider.refreshDiscovery() re-runs discovery; opencode models --refresh uses it to re-fetch discovered model lists.

Testing

  • Unit tests for the discovery mapper (headers, auth, malformed payloads, modality mapping) plus provider-level tests (eligibility, manual override, refresh).
  • Verified against a live llama.cpp server: a provider configured with only baseURL + apiKey lists its discovered models.
  • Unreachable baseURL does not crash; the provider is simply omitted from listings.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found potential duplicate PRs:

  1. feat(opencode): auto-discover models from OpenAI-compatible providers #32731 - feat(opencode): auto-discover models from OpenAI-compatible providers

  2. feat(provider): add dynamic model discovery for custom providers #42660 - feat(provider): add dynamic model discovery for custom providers

  3. feat(opencode): local LAN provider discovery + auto-discover models #27554 - feat(opencode): local LAN provider discovery + auto-discover models

These PRs appear to be directly related or may already address the model discovery functionality for OpenAI-compatible providers. You should review their status and implementation to ensure PR #48486 isn't duplicating existing work.

@nikakoy131
nikakoy131 marked this pull request as draft September 11, 2026 11:38
@nikakoy131 nikakoy131 closed this Sep 11, 2026
@nikakoy131
nikakoy131 deleted the openai-model-discovery branch September 11, 2026 11:40
@nikakoy131
nikakoy131 restored the openai-model-discovery branch September 11, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant