[Feature] Per-model pricing overrides in config for /usage and cost display
Description
Cost shown by /usage and the per-response indicator is looked up only from the models.dev catalogue by model id (getModelPricing in source/models/models-dev-client.ts). There is no way to set or override a price in config. Models served through a gateway, a self-hosted deployment with an internal chargeback rate, a negotiated enterprise price, a new model the catalogue has not caught up with, or a fine-tune with a custom name all show either no cost or the public list price of a different model with a similar name (the lookup falls back to findModelByName).
Use Case
A team routes requests through an internal gateway and wants /usage and the spend views to reflect what finance will actually be billed. Another user runs a local model on rented GPUs and wants an hourly rate converted to a per-token estimate. Aider supports this through a model metadata file with per-token costs.
Proposed Solution
Accept an optional pricing object per provider, with an optional per-model override:
{
"name": "gateway",
"models": ["team-model"],
"pricing": {"team-model": {"input": 1.2, "output": 4.0, "cacheRead": 0.12, "cacheWrite": 1.5, "currency": "USD"}}
}
Values are per million tokens, matching how models.dev reports them. Config pricing wins over the catalogue, and the usage output marks a cost as estimated or configured so users can tell where a number came from. Models with no price anywhere keep showing tokens only.
Alternatives Considered
- Wait for models.dev to add the entry. That does not help private or custom models.
- Ignore cost for non-catalogue models. This blocks the budget and spend features requested in #2019.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Related: #2019 (spend and token budget cap) depends on trustworthy prices.
Implementation Notes (optional)
source/usage/response-usage.ts already takes a getPricing lookup function, so a config-aware lookup can be injected without touching the formatters.
Please assign this to me, Thankyou
@puri-adityakumar are you still planning to work on this? If not, I'd be glad to pick it up.
I just reworked the pricing path in #2367 (local base URLs skip pricing, ids match exactly), so a configured price fits where buildResponseUsage resolves one. It would also give local providers a way to show a cost when the user wants one (rented GPUs, chargeback).
Plan: an optional pricing map on a provider ({"<model>": {input, output, cacheRead, cacheWrite}}, per million tokens like models.dev), checked before the catalogue in the footer, /usage, /review, ACP and /stats; the usage output marks configured prices; schema and docs updated. Happy to wait for a maintainer to assign it.
@akramcodez I'm Taking this issue!
@akramcodez for context: I asked about this on the 24th, with the plan above (a per-provider pricing map, used before the models.dev catalogue). It builds on the pricing path I changed in #2367. I'm happy to go with whoever you assign. I won't start until you say.
Since #2443 is up, I'll step back. Happy for it to go ahead.
@puri-adityakumar are you still planning to work on this? If not, I'd be glad to pick it up.
I just reworked the pricing path in #2367 (local base URLs skip pricing, ids match exactly), so a configured price fits where
buildResponseUsageresolves one. It would also give local providers a way to show a cost when the user wants one (rented GPUs, chargeback).Plan: an optional
pricingmap on a provider ({"<model>": {input, output, cacheRead, cacheWrite}}, per million tokens like models.dev), checked before the catalogue in the footer,/usage,/review, ACP and/stats; the usage output marks configured prices; schema and docs updated. Happy to wait for a maintainer to assign it.
Please go ahead. You can work on this issue.
Thanks @puri-adityakumar! #2443 already covers this, so I've stepped back and left a review there instead.