Skip to content

feat(opencode): discover abacus models from /v1/models endpoint - #34563

Closed
neo-clon wants to merge 4 commits into
anomalyco:devfrom
neo-clon:abacus-discover-models
Closed

feat(opencode): discover abacus models from /v1/models endpoint#34563
neo-clon wants to merge 4 commits into
anomalyco:devfrom
neo-clon:abacus-discover-models

Conversation

@neo-clon

@neo-clon neo-clon commented Jun 30, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #41318

Type of change

  • New feature

What does this PR do?

Adds dynamic model discovery for the Abacus provider by querying the standard OpenAI-compatible /v1/models endpoint.

Problem: the Abacus catalog in models.dev drifts behind what the vendor actually serves, and it drifts again every few weeks. Measured today: models.dev lists 95 Abacus models, while the Abacus API returns 153 models — 74 of them text_generation, of which 12 are absent from models.dev (claude-opus-5, moonshotai/Kimi-K3, moonshotai/Kimi-K2.7-Code, gemini-3.6-flash, deepseek-ai/DeepSeek-V4-Flash-0731, thinkingmachines/Inkling and others). Those models are unreachable from opencode even though the user's key can already call them.

Changes:

  1. discoverModels for Abacus — fetches GET /v1/models from the Abacus API (https://routellm.abacus.ai/v1). Filters by model_type === "text_generation" to exclude image/video/audio models. Models already in models.dev are never overwritten, since their metadata is richer. New models get cost derived from the API's token rates, capabilities inferred from the reported modalities, and context/output limits from the response.

  2. Generalized discoveryLoaders loop — this is required, not incidental. provider.ts already registers discoverModels into discoveryLoaders for any provider, but the invocation is hardcoded to gitlab, so a loader registered by any other provider is never called. Replacing that branch with a loop over discoveryLoaders makes the existing mechanism reachable for every provider. No behavior change for gitlab: it is still discovered, now through the generic path.

How did you verify your code works?

  • Rebased onto current dev (fe82a1b) with no conflicts; the three earlier merge commits are flattened into one feature commit
  • tsgo --noEmit is clean for packages/opencode, the only package this PR touches and the check that .github/workflows/typecheck.yml runs
  • Verified against the live endpoint today: 153 models returned, model_type breakdown 74 text_generation / 34 image_generation / 34 video_generation / 11 audio_generation
  • Confirmed models already present in models.dev are preserved and not overwritten by discovery

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Add dynamic model discovery for the Abacus provider via the
standard OpenAI-compatible /v1/models endpoint. Filters to
text_generation models only (excludes image, video, audio).

Also generalizes the discoveryLoaders execution loop to support
any provider with a discoverModels function, replacing the
gitlab-specific hardcoded path.
@neo-clon
neo-clon force-pushed the abacus-discover-models branch from d2f739b to 76fba4b Compare June 30, 2026 05:08
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@neo-clon

neo-clon commented Aug 8, 2026

Copy link
Copy Markdown
Author

Requesting reopen — still relevant, and the branch is now rebased and conflict-free.

Rebased onto current dev (fe82a1b). The branch was 206 commits behind; the three Merge branch 'dev' commits are now flattened into a single feature commit (0a8a54b). The rebase applied with no conflicts, and tsgo --noEmit is clean for packages/opencode (the only package this PR touches).

The gap this closes is still open today. Checked against both sources just now:

  • models.dev lists 95 Abacus models
  • the Abacus /v1/models endpoint returns 153 models, 74 of them model_type: text_generation
  • 12 of those 74 are absent from models.dev — including claude-opus-5, moonshotai/Kimi-K3, moonshotai/Kimi-K2.7-Code, gemini-3.6-flash, deepseek-ai/DeepSeek-V4-Flash-0731 and thinkingmachines/Inkling

Without discovery those models are simply unreachable from opencode unless the user hand-maintains a local models database and points OPENCODE_MODELS_PATH at it, which is the workaround I'm running today. The set drifts every few weeks as Abacus adds models, so it's a standing maintenance cost rather than a one-time gap in models.dev.

The second half of the PR is provider-agnostic. It replaces the hardcoded gitlab branch in the discovery step with a generic loop over discoveryLoaders, so any provider returning discoverModels gets picked up without extra wiring. That block is still hardcoded on dev today (packages/opencode/src/provider/provider.ts:1598).

Happy to split this into two PRs — the generic discoveryLoaders loop on its own, then the Abacus loader on top — if that's easier to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Discover models from a built-in provider's own API when the models.dev catalog lags

1 participant