feat(ai-gateway): mirror synced providers to Redis and fetch /api/v1/providers#2555
Open
kilo-code-bot[bot] wants to merge 3 commits intomainfrom
Open
feat(ai-gateway): mirror synced providers to Redis and fetch /api/v1/providers#2555kilo-code-bot[bot] wants to merge 3 commits intomainfrom
kilo-code-bot[bot] wants to merge 3 commits intomainfrom
Conversation
…providers Extends syncAndStoreProviders to also download the public OpenRouter provider list from /api/v1/providers, persist it alongside the other synced data in the models_by_provider table, and mirror all four payloads to Redis so future read paths can avoid a database round-trip. Redis writes are best-effort and do not block the transaction. Consumers are not wired up yet.
|
|
||
| const openrouter_data = await fetchGatewayModels(PROVIDERS.OPENROUTER); | ||
| const vercel_data = await fetchGatewayModels(PROVIDERS.VERCEL_AI_GATEWAY); | ||
| const openrouter_providers = await fetchOpenRouterApiProviders(); |
Contributor
Author
There was a problem hiding this comment.
WARNING: Ancillary provider fetch now blocks the main sync
openrouter_providers is new data with no readers yet, but this call happens before the existing snapshot write and the later < 10 guard throws if /api/v1/providers is unavailable or malformed. That means a temporary issue in the new endpoint can prevent the already-consumed data, openrouter, and vercel payloads from refreshing at all. Consider making this fetch best-effort or persisting it separately so the primary sync can still succeed.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by gpt-5.4-20260305 · 1,149,984 tokens |
Addresses review feedback: a failure in the ancillary /api/v1/providers fetch must not prevent the primary openrouter/vercel/providers snapshot from refreshing. Log the error and persist NULL instead.
Removes the DB migration and column for openrouter_providers. The data from /api/v1/providers is still fetched during sync and mirrored to Redis, but no longer persisted to Postgres.
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
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
syncAndStoreProvidersnow also downloads the public OpenRouter provider list fromhttps://openrouter.ai/api/v1/providersand persists it tomodels_by_provider.openrouter_providers(newjsonbcolumn).providers,openrouter,vercel,openrouter_providers) are mirrored to Redis under fixed keys. Writes are best-effort and do not block the DB write.Verification
pnpm typecheckpnpm lintpnpm formatpnpm drizzle generateproduced a clean one-line migration (ADD COLUMN openrouter_providers jsonb).Visual Changes
N/A
Reviewer Notes
ai-gateway.sync-providers.*; no TTL since the job overwrites them on every run./api/v1/providersresponse is validated with a newOpenRouterApiProvidersResponsezod schema inpackages/db/src/schema-types.ts.< 10sanity check is enforced on the provider list to match the existing guards for the other synced data.