Skip to content

Quote catalog prices per 1,000 requests - #12

Merged
kev1n merged 2 commits into
mainfrom
quote-catalog-prices-per-1k
Aug 15, 2026
Merged

Quote catalog prices per 1,000 requests#12
kev1n merged 2 commits into
mainfrom
quote-catalog-prices-per-1k

Conversation

@kev1n

@kev1n kev1n commented Aug 15, 2026

Copy link
Copy Markdown
Member

The gateway publishes every static discovery price in two denominations: maxUsd (USD billed for one request, unchanged) and maxPer1kUsd (the same maximum per 1,000 requests), with failoverMaxPer1kUsd twinning failoverMaxUsd. Lane-level pricing carries maxPer1kUsd too. Per 1,000 requests is what AnyAPI quotes customers, because most of the catalog costs a fraction of a cent per call and per-request figures cannot be compared by eye. The website, the gateway's MCP tool descriptions, and the canonical agent skill already quote per-1k and label it /1k req; this brings the CLI in line.

What changed

  • src/types.ts - maxPer1kUsd on both offer shapes, failoverMaxPer1kUsd on DiscoveryPricing.
  • src/discovery.ts - the handwritten discovery reader reads both fields and rejects an offer published without the per-1k rate, so a missing field is a loud contract error rather than a silently blank price.
  • src/format.ts - the catalog price display quotes maxPer1kUsd labeled /1k req. A metered offer keeps its per-item rate per item, which is what the customer's limit actually moves.

Where the per-1k figure now appears

anyapi list and anyapi search share one price column, and anyapi describe prints the reader's projection, so all three now carry the rate. Live output against production:

sku                 name                price
booking.search      Booking.com Search  up to USD 96.60/1k req (USD 0.0021 + USD 0.00473/result)
tripadvisor.search  Tripadvisor Search  from USD 3.60/1k req

Read, never multiplied

0.0966 * 1000 is 96.60000000000001 in JavaScript, and 20 of the 313 live catalog prices behave that way. The published field is read straight off the wire; nothing here scales a price by 1,000, and there was no pre-existing local scaling to replace. __tests__/discovery.test.ts pins that with expect(api.pricing.from.maxPer1kUsd).not.toBe(0.0966 * 1000) beside an exact 96.6. Both new tests fail against the previous reader and formatter.

Payable amounts deliberately left per request

costUsd on a completed run and the wallet balance state what a specific call is charged, not a comparison rate, so they stay per request and gained no per-1k twin. Putting a per-1k figure beside a payable amount invites acting on the wrong number. The CLI has no quote command, so there was no maxCostUsd / minCostUsd output to leave alone.

Gate

npm run build && npm test passes: 10 files, 87 tests. npm run canary:live also passes against production (313 catalog APIs), which confirms every live /catalog, /catalog/search, /public/try/*/schema, and /v1/apis/* response carries the fields the reader now requires.

kev1n and others added 2 commits August 14, 2026 18:26
The gateway publishes every static discovery price in two denominations:
`maxUsd` for one request and `maxPer1kUsd` for 1,000 of them, with
`failoverMaxPer1kUsd` twinning `failoverMaxUsd`. Per 1,000 requests is the
denomination AnyAPI quotes customers in, because most of the catalog costs a
fraction of a cent per call and per-request figures cannot be compared by eye.

The discovery reader now requires both figures on every offer, so `anyapi
describe` prints them and the `anyapi list` / `anyapi search` price column
quotes the per-1k rate labeled `/1k req`. The rate is read from the wire and
never scaled locally: `0.0966 * 1000` is `96.60000000000001`, and 20 of the 313
live catalog prices behave that way.

Payable amounts stay per request. `costUsd` on a completed run and the wallet
balance state what a specific call is charged rather than a comparison rate, so
they get no per-1k twin.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
formatUsd pads sub-dollar amounts to four decimals because a per-request
charge really is that small. A rate for a thousand requests is not: one
credit is $0.00001 and lane prices are whole credits, so the rate is
always a whole number of cents, and two decimals is exact rather than a
rounding.

Without this, the cheapest 39 of the catalog's 313 SKUs printed as
`USD 0.9000/1k req`. The shared formatter is untouched, so balance and
costUsd keep their per-request precision.
@kev1n
kev1n merged commit c8068fd into main Aug 15, 2026
2 checks passed
@kev1n
kev1n deleted the quote-catalog-prices-per-1k branch August 15, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant