Skip to content

feat(runtimes): support dynamic model pricing from OpenRouter and env overrides#1966

Open
RainSunMe wants to merge 4 commits intomultica-ai:mainfrom
RainSunMe:add-mimo-pricing
Open

feat(runtimes): support dynamic model pricing from OpenRouter and env overrides#1966
RainSunMe wants to merge 4 commits intomultica-ai:mainfrom
RainSunMe:add-mimo-pricing

Conversation

@RainSunMe
Copy link
Copy Markdown

@RainSunMe RainSunMe commented May 1, 2026

What

Extend the runtime cost estimation to support all LLM providers, not just Anthropic Claude.

Why

Currently, MODEL_PRICING in packages/views/runtimes/utils.ts only 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:

  1. Hardcoded pricing — existing Claude entries remain unchanged as the authoritative source for Anthropic models.
  2. Environment variableNEXT_PUBLIC_MODEL_PRICING_OVERRIDES accepts a JSON object for custom or corrected pricing:
    {"custom/model":{"input":2,"output":6,"cacheRead":0.5,"cacheWrite":0}}
  3. OpenRouter API — on page load, pricing for 500+ models is fetched from https://openrouter.ai/api/v1/models and 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

  • Verified that existing Claude pricing is unaffected.
  • Confirmed MiMo and other non-Claude models resolve to correct costs after OpenRouter fetch.
  • NEXT_PUBLIC_MODEL_PRICING_OVERRIDES correctly overrides both hardcoded and OpenRouter entries.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

@RainSunMe is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

RainSunMe added 2 commits May 1, 2026 09:41
- 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
@RainSunMe RainSunMe changed the title feat(runtimes): add mimo/mimo-v2.5-pro to MODEL_PRICING feat(runtimes): dynamic model pricing from OpenRouter + env overrides May 1, 2026
@RainSunMe RainSunMe changed the title feat(runtimes): dynamic model pricing from OpenRouter + env overrides feat(runtimes): support dynamic model pricing from OpenRouter and env overrides May 1, 2026
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.

1 participant