cleary5779 on Discord builds an agent on magpie's gateway and wants the
list to say what a call costs. Each model magpie knows a price of now has
"pricing": {"prompt": "<USD/token>", "completion": "<USD/token>",
"input_cache_read": ..., "input_cache_write": ...}
as OpenRouter's /models writes it: decimal strings, the decimal point
moved rather than the float divided (perToken: $0.3/M is "0.0000003",
not 2.9999999999999997e-07). prompt and completion are always there for
a priced model (a price the user set at 0 included); the cache parts
only when they have a price. A model with no known price has no pricing
key at all, never a 0. Base price only: no tiers, no 1-hour write.
The price is the Usage page's (provider.EntryPricer, as EntryPriceIn):
the user's own, else the provider's list price or its maker's at the
price rate, a subscription's model at list price, a group only when
every member costs the same. It goes to the callers magpie_price goes to
(local or sharedWith), with or without X-Magpie-Prices; magpie_price
itself is still only for a list that asks. GET /v1/models/{id} carries
it too (pricedModelObject).
Siblings left without it: Claude Desktop's and Claude Science's lists
(Anthropic's shape, their apps read their own fields), Muse Code's
(models.dev metadata Muse reads), Codex's catalog, Ollama's tags, the
decision models (another magpie's System One), and the image and video
models, whose price isn't a token's.
Cost on the poll path (LESSONS: work added to a path every request or
poll takes): 755 models, 30 providers, the real models.dev catalog:
before the previous commit the pricing added ~30ms to a ~10ms list; with
it, the list is ~13-20ms against ~8-10ms without pricing, at load 65.
Run at 9afa86306 (both commits, on origin/main 40a0b442c), load 73-95:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./...: exit 0, 70 packages ok
(gateway 810s, agent 652s, provider 306s, catalog 29s); log kept whole
and grepped, no FAIL. No other ./... suite ran meanwhile.
- go test ./internal/gateway ./internal/catalog ./internal/provider
again beside it: ok.
- TestModelsListPricing is red with the pricing assignment taken out
(both the list and GET /v1/models/{id} lose pricing), green with it.
Not tried: a real agent reading the list; Windows run (vet only).