pi-cost-was-taken
Estimated session cost in the pi footer, priced at a reference model from the OpenRouter catalog
Package details
Install pi-cost-was-taken from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-cost-was-taken- Package
pi-cost-was-taken- Version
0.1.0- Published
- Sep 9, 2026
- Downloads
- 144/mo · 144/wk
- Author
- shreyashp7
- License
- unknown
- Types
- package
- Size
- 16.1 KB
- Dependencies
- 0 dependencies · 2 peers
Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-cost
Estimated session cost in the pi footer, priced at a reference model of your choice from the OpenRouter catalog. This is a pricing lens — pi's actual model/provider is never changed.
The built-in footer already shows token stats; pi-cost adds a status line:
$0.0750 @ openai/gpt-6-astra
The cost updates live on message_update (streaming) and settles on turn_end.
Install
From npm:
pi install npm:pi-cost-was-taken
Or for a single run without installing: pi -e npm:pi-cost-was-taken.
No build step, no runtime dependencies — pi loads the TypeScript directly.
Copy extensions/index.ts to ~/.pi/agent/extensions/pi-cost/index.ts (or
.pi/extensions/pi-cost/index.ts for a project).
Restart pi (or /reload).
Commands
| Command | Effect |
|---|---|
/cost |
Token sums + current cost + reference model, with usage hints |
/cost pick |
Prompts for a search term, then lists all matching models (blank = all 400+, by context length) |
/cost pick claude |
Skips the prompt, lists all models matching the substring (id or name, case-insensitive) |
/cost claude |
Same as above — substring sugar |
/cost usd / /cost inr |
Currency for the cost display (persisted) |
The reference model and currency persist across restarts. If you switch pi's actual model and that model exists in the catalog, the reference model follows it (reference-only, not persisted).
Pricing assumptions (read before trusting the number)
- Catalog:
GET https://openrouter.ai/api/v1/models(free, no auth), cached for 24 h at~/.pi/agent/extensions/pi-cost/catalog.json. On network failure the stale cache is used; with no cache at all the line showscost: n/a. - Cache prices: OpenRouter publishes cache read/write prices for only some models. Where absent, reads and writes are charged at the full input price — a conservative ceiling, never an underestimate.
- Per-request fees (
pricing.request) are ignored. - FX rate:
GET https://open.er-api.com/v6/latest/USD, fetched fresh at every session start and stored incatalog.json. On failure the last cached rate is used; if there is none ever, a hardcoded85(display-only fallback).
Files
| Path | Contents |
|---|---|
~/.pi/agent/extensions/pi-cost/catalog.json |
Cached catalog + fxInr (auto-managed) |
~/.pi/agent/extensions/pi-cost/state.json |
{ modelId, currency } (auto-managed) |
Delete catalog.json to force a refetch; delete state.json to reset
model/currency to defaults.
Development
node --experimental-strip-types check.ts # pure-function self-checks
pi -e ./extensions/index.ts # interactive session with the extension
pi -p "hi" -e ./extensions/index.ts # headless smoke test (no dialogs)