Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ccusage/ccusage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: liuzemei/ccusage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: perf/cache-first-litellm-pricing
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Oct 25, 2026

  1. perf(pricing): reuse recently confirmed LiteLLM pricing

    Every online run refreshed LiteLLM pricing before reporting. The ETag
    cache made that refresh cheap in bytes, but each run still waited on a
    round trip, and a unified report made one per pricing load.
    
    The HTTP cache already holds the last response the server vouched for,
    so an online load now reads it first and decides by its age:
    
    - confirmed within the last hour: price from it with no request at
      all, falling back only to the embedded models.dev snapshot, as
      --offline does with the embedded table;
    - confirmed within the last day: price from it, and refresh once, on
      the first lookup the cached table cannot answer exactly;
    - older or missing: refresh up front, as before.
    
    A 304 now renews the cache entry's timestamp, so the age is when the
    server last confirmed the body rather than when it last changed.
    
    The deferred refresh is delegated before any fallback guesses, so a
    model the cached table lacks resolves exactly as it would in a run that
    fetched. The hour-long quiet period exists because some models are in
    no table at all: re-asking for them on every miss would put the request
    back on every run that uses one. User overrides price their models on
    their own and never trigger a refresh, or a private model would cost a
    request every run.
    
    --offline is unchanged.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    SheldonNeo and claude committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    07cf77f View commit details
    Browse the repository at this point in the history
  2. docs: describe cached LiteLLM pricing reuse

    The offline section said --offline uses cached pricing, but it uses the
    pricing embedded in ccusage. Online runs are the ones that read the
    cache now, so say that instead and describe when they refresh.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    SheldonNeo and claude committed Oct 25, 2026
    Configuration menu
    Copy the full SHA
    d5b71d0 View commit details
    Browse the repository at this point in the history
Loading