Spens logoSpens

Pricing

How session costs are estimated

Every session summary includes an estimated cost, computed from the token usage in the captured LLM traces.

Where prices come from

Spens prices tokens with the Portkey pricing dataset, covering six providers: anthropic, openai, google, fireworks-ai, openrouter, and bedrock. A model listed by more than one provider is priced from the first provider in that order that lists it, so a direct provider's rate wins over a reseller's.

You normally do not need to do anything. After each session, spens fetches the dataset on the host, caches it under ~/.cache/spens/pricing for 24 hours, and prices the session from it. For each model, the price is resolved from the first source that lists it:

  1. The live Portkey dataset (cached for 24 hours)
  2. The vendored snapshot shipped inside the package at spens/data/pricing, used when the fetch fails or you are offline
  3. A small built-in price table
  4. Nothing — a model that no source lists is costed at $0 rather than guessed

Each session summary records which source each provider's numbers came from, so an archived cost figure can still be explained later.

Offline mode

To keep costing entirely offline, set SPENS_PRICING_OFFLINE=1 in your environment or put "pricing": {"live_fetch": false} in .spens.config.json.

The spens pricing command

spens pricing                                  # where each provider's prices are coming from
spens pricing --refresh                        # re-fetch every provider into the local cache
spens pricing --model claude-sonnet-4          # resolved price for one model id
spens pricing --model gemini-2.5-pro --tokens 400000
OptionDescription
--refreshRe-fetch every provider's pricing dataset into the local cache
--vendorRe-fetch and also update the snapshots shipped in spens/data/pricing (needs a writable checkout)
--provider NAMELimit to one provider (repeatable)
--model IDShow the resolved price for one model id
--tokens NContext size used to pick a banded model's price with --model
--offlineDo not fetch; report what cached and vendored data provide

On this page