Skip to content

feat: runtime pricing overrides via config #1198

Description

@xiaoMaJia707

What do you want to change?

Add runtime pricing overrides via ccusage.json, and make the Pi adapter respect CostMode when calculating cost.
Today Pi logs always write usage.cost.total = 0, and the Pi parser takes that value verbatim. That means Pi usage shows $0.00 in Auto mode even when token usage is present.
I'd like to:

  • make Pi use calculate_cost_for_usage(...) instead of trusting usage.cost.total
  • add a pricingOverrides config section so users can override per-model pricing and context limits at runtime

Why?

Fuzzy model matching already covers most naming differences, so the built-in pricing works well in many cases.
But there are still real cases where users need local overrides:

  • Pi logs do not include usable cost data
  • private deployments / internal proxies may use non-public pricing
  • LiteLLM pricing can be stale
  • custom models may need maxInputTokens
  • some models may not be in LiteLLM yet

How? (optional)

  • Add pricingOverrides to config, keyed by model name
  • Extend PricingMap to apply overrides after embedded / LiteLLM pricing is loaded
  • Allow overrides for token pricing fields, cache pricing, fastMultiplier, and maxInputTokens
  • Pass the resolved pricing map into Pi parsing so Pi cost follows normal Display / Auto / Calculate behavior

Activity

  1. github-actions commented on Jun 1, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  2. xiaoMaJia707 commented on Jun 2, 2026

    @xiaoMaJia707
    ContributorAuthor

    Check commit in my forked repository for code changes if you feel it is needed:
    xiaoMaJia707@4497d22

    Best Regards.

  3. ryoppippi commented on Jun 4, 2026

    @ryoppippi
    Member

    thanks! lmc

  4. xiaoMaJia707 commented on Jun 5, 2026

    @xiaoMaJia707
    ContributorAuthor

    Thank you, I will try to formally create a PR for your review.

  5. xiaoMaJia707 commented on Jun 5, 2026

    @xiaoMaJia707
    ContributorAuthor

    Opened the PR: #1204 — auto-closed by the contributor gate. Let me know
    if you'd like to take a look or want me to revise anything before reopening.

    Heads-up: PR description has a "Known limitations" section flagging a ~28s
    slowdown in --mode calculate when the models in use aren't covered by
    either built-in pricing or overrides. Looks like a pre-existing
    characteristic of PricingMap::find for unknown models, surfaced now that
    Pi goes through the pricing path on my local setup — once overrides privices are
    filled in, runtime returns to ~0.2s.

  6. xiaoMaJia707 commented on Jun 9, 2026

    @xiaoMaJia707
    ContributorAuthor

    Thank you @ryoppippi for taking the time to finish this PR. I’m sorry I couldn't get around to it yesterday, your improvements look great!

  7. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:resolvedResolved by a later change or current implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions