Per-request pricing for an infrastructure API
Proseware sells a web search API to AI agents. It has three endpoints, each priced per 1,000 requests: search at $5, answer at $10 and deep research at $25. New developers get 10,000 free credits a month to try it. Tailspin Research, its biggest customer, has signed a discount that grows with the number of requests it sends.
This example uses:
- Products and meters
- Rate cards, in preview
- Credit currencies and a price that grants credits, for the free tier
- Customers and orders, with negotiated pricing
- Events
The calls below show only the request body. Every request also sends the Authorization and Paid-Version headers, and a Paid-Beta header opting in to the betas these endpoints require: products=v1, meters=v1, rate_cards=v1, credits=v1, prices=v1, customers=v1, orders=v1 and events=v1. Writes should also send an Idempotency-Key. See request headers and idempotency.
Set up the catalog
These calls run once.
Create a product for the API:
Create a meter that counts requests and groups them by endpoint, so each endpoint can have its own price:
Set up two rate cards on the requests meter, one rate per endpoint. The rate card API is in preview. search_api charges paying customers in dollars, and search_api_credits charges the free tier in credits, at 1 credit to $0.001:
Give developers a free tier
Create a credit currency for the free credits. With no conversion, requests past a developer’s credits are recorded as overage but never billed:
Create a price for the free tier. It costs nothing, and grants 10,000 credits each month that expire at the end of it:
This returns prc_freeTier01. When a developer signs up, create the customer and an order with the free tier price and the credits rate card:
An order with a rate card line is activated when you create it, so there is no separate activate call. Each month, Paid grants 10,000 credits, and every request spends from them: 2,000 searches use the whole allowance. To stop serving a developer who has used it, read their credit balance before serving a request. This is a soft limit: requests checked at the same time can all see credits left, so a developer can go a little past the allowance, and with no conversion that overage is never billed.
Sign Tailspin at volume
Tailspin’s discount depends on its total requests in the month. The bands are graduated: each band’s percentages apply only to the requests inside it.
Create the order with the search_api rate card, and the discount as negotiated pricing. basis names the meter whose total picks the band:
Send usage
Proseware sends an event for every request, with the endpoint in the payload. The request ID is the dedupeKey, so a retried send is not counted twice:
At this volume, send a batch of up to 1,000 events at a time.
Tailspin’s first month
In December, Tailspin sends 3.2 million requests: 2 million searches, 800,000 answers and 400,000 deep research requests, in the same mix every day. The first 1 million fall in the first band and the other 2.2 million in the second:
The invoice shows each endpoint at list price, $28,000.00, then a “Contracted volume discount” line of −$3,460.00. Amount due: $24,540.00.
A free-tier developer’s month
In the same month, Priya sends 1,000 searches, 400 answers and 60 deep research requests: 5,000 + 4,000 + 1,500 = 10,500 credits against her 10,000. The last 500 credits are recorded as overage and never billed, and her invoice is $0.00.
Next steps
- Migrations: publish a new version of a rate card, such as search priced by speed, and move orders onto it.
- Credit balances and ledger: what a developer has left, and every spend.