feat: support OpenRouter models and multi-provider pricing entries#1089
Open
JoseArroyave wants to merge 5 commits intomnfst:mainfrom
Open
feat: support OpenRouter models and multi-provider pricing entries#1089JoseArroyave wants to merge 5 commits intomnfst:mainfrom
JoseArroyave wants to merge 5 commits intomnfst:mainfrom
Conversation
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/backend/src/database/pricing-sync.service.ts">
<violation number="1" location="packages/backend/src/database/pricing-sync.service.ts:163">
P2: Deduplicate provider targets before syncing. For `openrouter/*` models, `[provider, 'OpenRouter']` produces duplicate `OpenRouter` writes and duplicate history/update counts.</violation>
</file>
<file name="packages/backend/src/model-prices/model-pricing-cache.service.ts">
<violation number="1" location="packages/backend/src/model-prices/model-pricing-cache.service.ts:48">
P1: The cache now uses `${model_name}:${provider}` keys, but getByModel still looks up by raw model name/alias. This means existing callers like `getByModel('gpt-4o')` will always miss and return undefined unless they supply the composite key. Update getByModel (and its callers) to use the composite key or maintain a secondary index keyed by model name.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
…ave/manifest into feat/openrouter-models
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1089 +/- ##
==========================================
- Coverage 99.01% 99.01% -0.01%
==========================================
Files 223 223
Lines 11584 11564 -20
Branches 3652 3640 -12
==========================================
- Hits 11470 11450 -20
- Misses 22 24 +2
+ Partials 92 90 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Fix: Support OpenRouter models and multi-provider pricing entries
Fixes #1088
Support multi-provider models in the pricing sync and fix cache key collisions.
This change resolves an issue where models retrieved from the OpenRouter API were not correctly exposed in Local Mode because:
model_namewas unique and overwrote entries from different providersThis update enables proper multi-provider support so the same model can exist for both its vendor and OpenRouter without being overwritten in the cache.
Changes
1. Multi-provider support in
model_pricingThe
model_pricingtable now uses a composite primary key:This allows the same model to exist for multiple providers.
Example:
This is required because OpenRouter acts as an aggregator that exposes models from multiple vendors.
2. Store OpenRouter models explicitly
During the pricing sync (
syncAllModels), models retrieved from OpenRouter are now stored for both providers:OpenAI,Anthropic, etc.)OpenRouterThis ensures that provider filtering works correctly when OpenRouter is configured as the active provider.
3. Fix cache key collision in
pricingCacheThe pricing cache previously used
model_nameas the cache key:This caused entries from different providers to overwrite each other.
The cache now uses a composite key:
This ensures each provider entry is cached independently.
4. Update quality score updates
Quality score updates now correctly target a specific provider entry:
instead of updating all rows with the same model name.
Result
After these changes:
Compatibility
These changes do not affect existing routing logic and remain backward-compatible with existing vendor providers.
Summary by cubic
Adds multi-provider model pricing with explicit
OpenRouterentries so models show correctly in Local Mode. Improves cache keys and alias resolution to prevent provider collisions.New Features
(model_name, provider)inmodel_pricingto support the same model across providers.OpenRouterentry in one pass, without relying onopenrouter/ID prefixes.Bug Fixes
(model_name, provider)rows only.Written for commit a08ba6b. Summary will update on new commits.