Skip to navigation

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:

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:

POST /v1/products
{
"externalId": "search_api",
"name": "Search API"
}

Create a meter that counts requests and groups them by endpoint, so each endpoint can have its own price:

POST /v1/meters
{
"key": "requests",
"name": "Requests",
"eventNames": ["api_request"],
"measure": {
"type": "events",
"events": {
"aggregation": { "type": "count" },
"unit": "request",
"groupBy": ["payload.endpoint"]
}
}
}

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:

RateEndpointsearch_api, per 1,000 requestssearch_api_credits, per request
searchsearch$5.005 credits
answeranswer$10.0010 credits
deepdeep$25.0025 credits

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:

POST /v1/credit-currencies
{
"key": "proseware_credits",
"name": "Proseware credits",
"conversion": null
}

Create a price for the free tier. It costs nothing, and grants 10,000 credits each month that expire at the end of it:

POST /v1/prices
{
"product": "search_api",
"name": "Free tier",
"displayName": "Proseware free tier",
"currency": "usd",
"type": "recurring",
"recurring": {
"interval": "month",
"pricing": { "type": "perUnit", "perUnit": { "unitAmount": "0" } },
"grants": [
{
"creditCurrency": "proseware_credits",
"amountPerUnit": "10000",
"grantedOn": "activation",
"expiresAfter": { "value": "1", "unit": "month" }
}
]
}
}

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:

POST /v1/customers
{
"externalId": "dev_7c21",
"name": "Priya Raman",
"email": "priya@example.com",
"currency": "usd"
}
POST /v1/orders
{
"customer": "dev_7c21",
"startsAt": "2026-12-01T00:00:00Z",
"billingCycle": { "interval": "month" },
"lines": [
{ "type": "price", "price": { "price": "prc_freeTier01" } },
{
"type": "rateCard",
"rateCard": { "rateCard": "search_api_credits" }
}
]
}

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

Create the customer:

POST /v1/customers
{
"externalId": "tailspin",
"name": "Tailspin Research",
"currency": "usd"
}

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.

Requests in the monthSearchAnswerDeep
0 to 1M5% off10% off15% off
1M to 5M8% off12% off20% off
Above 5MList priceList priceList price

Create the order with the search_api rate card, and the discount as negotiated pricing. basis names the meter whose total picks the band:

POST /v1/orders
{
"customer": "tailspin",
"externalId": "tailspin-2027",
"startsAt": "2026-12-01T00:00:00Z",
"endsAt": "2027-12-01T00:00:00Z",
"billingCycle": { "interval": "month" },
"lines": [
{ "type": "rateCard", "rateCard": { "rateCard": "search_api" } }
],
"negotiatedPricing": [
{
"key": "request_volume",
"type": "discount",
"target": { "type": "rateCard", "rateCard": { "rateCard": "search_api" } },
"displayName": "Contracted volume discount",
"discount": {
"type": "bandedPercentage",
"bandedPercentage": {
"mode": "graduated",
"basis": { "meter": "requests", "measure": "requests" },
"bands": [
{
"upTo": "1000000",
"targets": [
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "search" } }, "percentOff": "5" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "answer" } }, "percentOff": "10" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "deep" } }, "percentOff": "15" }
]
},
{
"upTo": "5000000",
"targets": [
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "search" } }, "percentOff": "8" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "answer" } }, "percentOff": "12" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "deep" } }, "percentOff": "20" }
]
},
{
"upTo": null,
"targets": [
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "search" } }, "percentOff": "0" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "answer" } }, "percentOff": "0" },
{ "target": { "type": "rate", "rate": { "rateCard": "search_api", "rate": "deep" } }, "percentOff": "0" }
]
}
]
}
}
}
]
}

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:

POST /v1/events
{
"eventName": "api_request",
"customer": "tailspin",
"product": "search_api",
"dedupeKey": "req_5d1e9a",
"payload": { "endpoint": "search" }
}

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:

EndpointRequestsList priceFirst bandSecond bandDiscount
Search2,000,000$10,000.00625,000 at 5%: $156.251,375,000 at 8%: $550.00$706.25
Answer800,000$8,000.00250,000 at 10%: $250.00550,000 at 12%: $660.00$910.00
Deep400,000$10,000.00125,000 at 15%: $468.75275,000 at 20%: $1,375.00$1,843.75
Total3,200,000$28,000.00$3,460.00

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.