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:
- The live Portkey dataset (cached for 24 hours)
- The vendored snapshot shipped inside the package at
spens/data/pricing, used when the fetch fails or you are offline - A small built-in price table
- 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| Option | Description |
|---|---|
--refresh | Re-fetch every provider's pricing dataset into the local cache |
--vendor | Re-fetch and also update the snapshots shipped in spens/data/pricing (needs a writable checkout) |
--provider NAME | Limit to one provider (repeatable) |
--model ID | Show the resolved price for one model id |
--tokens N | Context size used to pick a banded model's price with --model |
--offline | Do not fetch; report what cached and vendored data provide |
Spens