feat(runtimes): support dynamic model pricing from OpenRouter and env overrides#1966
Open
RainSunMe wants to merge 4 commits intomultica-ai:mainfrom
Open
feat(runtimes): support dynamic model pricing from OpenRouter and env overrides#1966RainSunMe wants to merge 4 commits intomultica-ai:mainfrom
RainSunMe wants to merge 4 commits intomultica-ai:mainfrom
Conversation
|
@RainSunMe is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
- Keep hardcoded Claude pricing as fallback - Fetch model pricing from OpenRouter API on startup - Support NEXT_PUBLIC_MODEL_PRICING_OVERRIDES env var - Priority: env > hardcoded > OpenRouter
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.
What
Extend the runtime cost estimation to support all LLM providers, not just Anthropic Claude.
Why
Currently,
MODEL_PRICINGinpackages/views/runtimes/utils.tsonly contains hardcoded Claude model prices. Users running non-Anthropic models (MiMo, DeepSeek, GPT, etc.) see "Tokens recorded but pricing missing" with no way to resolve it without submitting a PR upstream.How
Three pricing sources are merged at runtime, in descending priority:
NEXT_PUBLIC_MODEL_PRICING_OVERRIDESaccepts a JSON object for custom or corrected pricing:{"custom/model":{"input":2,"output":6,"cacheRead":0.5,"cacheWrite":0}}https://openrouter.ai/api/v1/modelsand merged for any model not already covered by the above.Only models missing from the first two layers are filled in from OpenRouter, so hardcoded and user-specified prices always take precedence.
Testing
NEXT_PUBLIC_MODEL_PRICING_OVERRIDEScorrectly overrides both hardcoded and OpenRouter entries.