Price ranges for routed model ids (#406) #433
Merged
tombeckenhammerged 2 commits into
main fromrefs/pull/433/head·merged by tombeckenham View on GitHubCloses #406
What#
A routed bare id whose routes bill different prices has no single billed price. Before, it showed no price at all. Now:
- Adapter (LLM Gateway): a bare id with 2+ routes, all priced and disagreeing, stores
pricing: nullwithabsent.pricing: 'cleared'(the listing states there is no one price) and apricingRange:
Built only from the routes' published cards ({ "currency": "USD", "routes": [{ "model": "groq/gpt-oss-120b", "pricing": { "per": "token", "inputPerMillion": 0.15, ... } }, ...], "inputPerMillion": { "min": 0.032, "max": 0.35 }, "outputPerMillion": { "min": 0.14, "max": 0.75 } }pricingRangeinsrc/server/rate-card.ts). It is null, not partial, when any route has no readable card, the routes differ in currency, a card is tiered or not linear, or a route is the gateway's own (llmgateway, no pinned row). A route this cannot read leaves the bare price a plain omission, notcleared. - Catalog: every model row serves
pricingRange(or null), withfactSources.pricingRangepointing at the routes' listing path. Each route is its own pinned row with its full card. POST /v1/estimate/ MCPestimate_cost: on a row with no card and a range, the call is priced on each route's own stored card and returns{ currency, min, max, routes }.min/maxare full results plusmodel(the route). Any route that cannot be priced (no card, or a 422 such asunknown_usage_key) refuses the whole estimate and names the route: without it the bounds are unknown. Mixed currencies are a 422mixed_currency.- DB: additive
models.pricing_range(migration0015_pricing_range). - Row shape v2 (
row-shape.ts), OpenAPI (PricingRange,PriceBounds,EstimateRangeResult,EstimateRouteResult, estimate 200 is now aoneOf),openapi.json, generated client and SKILL.md regenerated. Changeset for@modelschemas/client. README: Breaking note (estimate can return a range).
Not published / left out#
- Vercel ranges: not added. A Vercel range needs
GET /v1/models/{id}/endpointsfor each of the 58varies_by_providerrows on every poll. The 15-minute models poll runs the whole registry in one Worker invocation under the 1,000-subrequest budget, and each D1 query there also counts against it. These rows staypricing: nullwith no range (#346). - OpenRouter's per-provider endpoints could fill the same shape later (it is compare-only for other providers' facts; a range on its own rows would be fine).
- The
/models/{p}/{id}/pricingcalculator page renders only for rows with a card; it does not show ranges.
- 1
tombeckenham merged this7210a10
tombeckenham closed this
Sign in to join this conversation.
Deploying with
Cloudflare Workers#
The latest updates on your project. Learn more about integrating Git with Workers.
View logs