Skip to content

refactor(byok): share models.dev catalog across sync fetchers#2970

Merged
chrarnoldus merged 1 commit intomainfrom
byok-sync-refactor
May 1, 2026
Merged

refactor(byok): share models.dev catalog across sync fetchers#2970
chrarnoldus merged 1 commit intomainfrom
byok-sync-refactor

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented Apr 30, 2026

Summary

  • Extracts modelsDevFetcher so multiple direct-BYOK providers can source their model list from the shared models.dev catalog; the existing zai-coding fetcher is rewritten on top of it.
  • Introduces a SyncContext with a lazy getModelsDevCatalog() memoized inside a single syncDirectByokModels run, so the models.dev JSON is fetched at most once per sync regardless of how many providers consume it.
  • Renames stripVendorPrefix to modelIdToDisplayName and also strips any :suffix tag (e.g. :cloud, :latest) so tagged ids render cleanly when models.dev does not provide an explicit name.

Preparatory refactor extracted from #2819 so the Ollama Cloud provider can land on top of a clean base.

Verification

  • Ran a local dry-run of syncDirectByokModels and confirmed models.dev is hit exactly once even with multiple models.dev-backed providers registered.
  • zai-coding output is unchanged (same model list serialized to Redis).

Visual Changes

N/A — internal refactor.

Reviewer Notes

  • Display-name behavior for existing providers is unchanged: name from upstream still wins; the colon stripping only affects the fallback path.
  • SyncContext is intentionally minimal; future models.dev-backed providers just call modelsDevFetcher(providerId, catalogKey).

- Extract modelsDevFetcher so any number of providers can pull from the
  shared models.dev catalog; rewrite the existing zai-coding fetcher to
  use it.
- Fetch the models.dev catalog at most once per syncDirectByokModels run
  via a lazy getModelsDevCatalog() on a shared SyncContext.
- Rename stripVendorPrefix to modelIdToDisplayName and also strip any
  ':suffix' tag (e.g. ':cloud', ':latest') so tagged ids render cleanly
  when models.dev doesn't provide an explicit name.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented Apr 30, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/src/lib/ai-gateway/providers/direct-byok/sync-direct-byok.ts

Reviewed by gpt-5.5-2026-04-23 · 130,075 tokens

@chrarnoldus chrarnoldus self-assigned this Apr 30, 2026
@chrarnoldus chrarnoldus merged commit f376920 into main May 1, 2026
13 checks passed
@chrarnoldus chrarnoldus deleted the byok-sync-refactor branch May 1, 2026 06:59
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.

2 participants