Skip to content
Source
Sign inSign up
TanStack/schemas

Price ranges for routed model ids (#406) #433

Mergedtombeckenhammerged 2 commits intomain fromrefs/pull/433/headmerged by tombeckenham View on GitHub

tombeckenhamcommented

Closes #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: null with absent.pricing: 'cleared' (the listing states there is no one price) and a pricingRange:
    { "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 } }
    Built only from the routes' published cards (pricingRange in src/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, not cleared.
  • Catalog: every model row serves pricingRange (or null), with factSources.pricingRange pointing at the routes' listing path. Each route is its own pinned row with its full card.
  • POST /v1/estimate / MCP estimate_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/max are full results plus model (the route). Any route that cannot be priced (no card, or a 422 such as unknown_usage_key) refuses the whole estimate and names the route: without it the bounds are unknown. Mixed currencies are a 422 mixed_currency.
  • DB: additive models.pricing_range (migration 0015_pricing_range).
  • Row shape v2 (row-shape.ts), OpenAPI (PricingRange, PriceBounds, EstimateRangeResult, EstimateRouteResult, estimate 200 is now a oneOf), 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}/endpoints for each of the 58 varies_by_provider rows 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 stay pricing: null with 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}/pricing calculator page renders only for rows with a card; it does not show ranges.
    1. Deploying with  Cloudflare Workers  Cloudflare Workers

      The latest updates on your project. Learn more about integrating Git with Workers.

      StatusNameLatest CommitUpdated (UTC)
      ✅ Deployment successful!
      View logs
      modelschemas376717e2Oct 22 2026, 12:13 PM
    2. tombeckenham merged this7210a10

    3. tombeckenham closed this

Sign in to join this conversation.