Skip to content
Source
Sign inSign up
TanStack/schemas

Vercel: price ranges for varies_by_provider rows from per-model /endpoints #451

Send to my agent
Closedtombeckenham opened this issue 0 comments
tombeckenhamcommented

Follow-up to #346 and #406. Since #346, the 58 Vercel rows whose listing has pricing.varies_by_provider: true store pricing: null, and they count as price gaps. Vercel does publish each route's price, one request per model:

GET https://ai-gateway.vercel.sh/v1/models/{creator}/{model}/endpoints → data.endpoints[], each with provider_name, pricing.prompt / completion (USD per token, as strings), context_length, max_completion_tokens, status and quantization.

There's no bulk form, so this takes about 58 subrequests. It must not run in the 15-minute models poll, which shares one 1,000-subrequest budget across every provider.

Do

  1. Own cron, own budget. Follow the FAL precedent (FAL_PRICING_EXTRACT_CRONS, extract-fal-pricing.ts): a separate cron firing (daily is enough; hourly if cheap) that, for each live Vercel row with varies_by_provider, fetches its /endpoints and writes the range. Add the firing to wrangler.jsonc and the src/worker.ts dispatch. Run bun run types if the bindings change.
  2. Range per #406. Store pricingRange using the existing type, helper and fail-closed rules: null, never partial, when any route has no readable price, currencies differ, or a price is tiered or unreadable. pricing stays null, with factSources.pricingRange citing the /endpoints URL and hash.
    • #406's range names each route by a pinned catalog row and /v1/estimate loads those rows. Vercel has no per-route rows, so extend the range so a route can be identified by Vercel's provider_name and carry its own compiled card inline (use the existing listing compiler in @modelschemas/rate-card for the per-token strings). Keep one range type and one estimate path. Don't fork them.
    • Decide and document in the PR whether to skip endpoints with a non-zero status (unavailable route). Whichever you choose, state it in factSources. Don't drop a route silently.
  3. The poll keeps the range. The 15-minute poll must not clear a range it didn't fetch. When a row's listing stops saying varies_by_provider, the listing's card applies and the range is cleared.
  4. Estimate. /v1/estimate and MCP estimate_cost on these rows return the #406 { min, max, routes } answer, naming each end by provider. Coordinate with #450 (per-value estimates), which may touch the same estimate code. Rebase on whichever merges first.
  5. Count. Log fetched, ranged and refused rows per run. A failed /endpoints fetch keeps the stored range and emits ingest_failed naming the model. It never writes a partial range.
  6. Regenerate OpenAPI, client and SKILL.md if the range shape changes. Add a changeset and a README note.

Not this

  • No cheapest or default route picked as the price.
  • Don't copy prices from the upstream provider's own catalog row. Only Vercel's own /endpoints prices count, since that's what Vercel bills.
  1. tombeckenham closed this

Sign in to join this conversation.