Skip to navigation

Token pricing for a model API

Coho Models sells API access to three model families: large, medium and small. Each family is released as dated snapshots, such as model-medium-20260929. Prices differ by model family and token type, batch requests get 50% off, and requests with more than 200,000 input tokens pay a long-context premium. Its biggest customer, Initech, has signed a $50,000 prepaid annual commit with 20% off large-model output.

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, customers=v1, orders=v1, commits=v1 and events=v1, plus event_costs=v1 for an event that sends cost. Writes should also send an Idempotency-Key. See request headers and idempotency.

Rate-card amounts are decimal strings in cents. Commit amounts are integers in cents, so $50,000.00 is 5000000.

Set up the catalog

These calls run once.

Create a product for the API:

POST /v1/products
{
"externalId": "model_api",
"name": "Model API"
}

Create a meter for each token type. Each meter sums one usage field from the model_call event and groups by model and service tier, so the rate card can price each combination separately:

POST /v1/meters
{
"key": "input_tokens",
"name": "Input tokens",
"eventNames": ["model_call"],
"measure": {
"type": "events",
"events": {
"aggregation": {
"type": "sum",
"sum": { "path": "payload.usage.inputTokens" }
},
"unit": "token",
"groupBy": ["payload.model", "payload.serviceTier"]
}
}
}

Create three more the same way:

Meter keySummed path
output_tokenspayload.usage.outputTokens
cache_read_tokenspayload.usage.cacheReadInputTokens
cache_write_tokenspayload.usage.cacheCreationInputTokens

inputTokens counts uncached input only, so no token is billed twice.

The list prices, per million tokens:

FamilyInputOutputCache readCache write
model-large$15.00$75.00$1.50$18.75
model-medium$3.00$15.00$0.30$3.75
model-small$0.80$4.00$0.08$1.00

Set up a rate card, api_list_prices, with one rate per meter and family. The rate card API is in preview; Introduction to pricing explains how a rate card prices meters. Each rate matches on the model name by prefix, so every snapshot of a family, past or future, bills at that family’s rate. Each rate’s key is its family and token type, such as large_output. Modifiers on the rate card apply multipliers on top of the rates, for every customer:

  • Batch halves every rate for events whose serviceTier is batch.
  • Long context doubles input, cache read and cache write when the three input counts on one event sum to more than 200,000.
  • Long context multiplies output by 1.5 under the same condition.

Sign Initech

Create the customer:

POST /v1/customers
{
"externalId": "initech",
"name": "Initech",
"currency": "usd"
}

Create an order for the 2027 contract. It bills the rate card monthly and carries the negotiated terms inline:

  • A negotiated discount takes 20% off the large_output rate. It has no dates, so it lasts as long as the order.
  • A $50,000 prepaid commit for the whole term. Usage draws it down, and billAtRate bills any usage beyond it at the normal rates.
POST /v1/orders
{
"customer": "initech",
"externalId": "initech-2027",
"startsAt": "2027-01-01T00:00:00Z",
"endsAt": "2028-01-01T00:00:00Z",
"billingCycle": { "interval": "month" },
"lines": [
{ "type": "rateCard", "rateCard": { "rateCard": "api_list_prices" } }
],
"negotiatedPricing": [
{
"key": "large_output_discount",
"type": "discount",
"discount": {
"type": "percentage",
"percentage": { "percentOff": "20" }
},
"target": {
"type": "rate",
"rate": { "rateCard": "api_list_prices", "rate": "large_output" }
},
"displayName": "Negotiated discount"
}
],
"commits": [
{
"type": "prepaid",
"amount": 5000000,
"currency": "usd",
"period": "term",
"prepaid": { "invoiceBehavior": "start", "overage": "billAtRate" }
}
]
}

An order with a rate card line is activated when you create it, so there is no separate activate call: Paid pins the version of api_list_prices in effect on 1 January 2027 and starts billing. This request needs an Idempotency-Key. If Paid can’t confirm the activation, it returns a retryable 503 with the order ID; retry with the same key. Because the commit is on the order, activation issues the $50,000.00 prepaid invoice straight away.

Send usage

Coho Models sends an event for every request, with the model, service tier and token counts in the payload. The request ID is the dedupeKey, so a retried send is not counted twice. This one is a long-context request: its three input counts sum to 240,000.

The optional cost line records what the request cost Coho Models to serve, for margin reporting. It is never shown to Initech.

POST /v1/events
{
"eventName": "model_call",
"customer": "initech",
"product": "model_api",
"dedupeKey": "req_8f2c41d9",
"payload": {
"model": "model-medium-20260929",
"serviceTier": "standard",
"usage": {
"inputTokens": 40000,
"cacheReadInputTokens": 200000,
"cacheCreationInputTokens": 0,
"outputTokens": 2000
}
},
"cost": [
{
"type": "compute",
"amount": { "amount": "0.04", "currency": "usd" },
"compute": {
"resource": "gpu",
"instanceType": "gpu-large",
"duration": { "value": "0.0004", "unit": "hour" }
}
}
]
}

To send many requests at once, send a batch of up to 1,000 events.

Initech’s first month

RequestsModelTierPer request (input / cache read / cache write / output)Charge
40,000model-medium-*standard2k / 4k / 0 / 700$708.00
5,000model-medium-*standard, long context40k / 200k / 0 / 2k$2,025.00
300model-medium-20250929 (older snapshot)standard5k / 0 / 0 / 500$6.75
20,000model-small-*batch3k / 0 / 0 / 300$36.00
2,000model-large-*standard4k / 0 / 8k / 3.5k$840.00
Total usage$3,615.75

How each line is priced:

  • Medium, standard: input 80M × $3.00/M = $240.00, cache read 160M × $0.30/M = $48.00, output 28M × $15.00/M = $420.00. Total $708.00.
  • Medium, long context: the three input counts sum to 240k, over 200k, so input and cache read are ×2 and output ×1.5. Input 200M × $3.00/M × 2 = $1,200.00, cache read 1,000M × $0.30/M × 2 = $600.00, output 10M × $15.00/M × 1.5 = $225.00. Total $2,025.00.
  • Older medium snapshot: the prefix match bills it at the medium rate. Input 1.5M × $3.00/M = $4.50, output 0.15M × $15.00/M = $2.25. Total $6.75.
  • Small, batch: input 60M × $0.80/M = $48.00, output 6M × $4.00/M = $24.00, then ×0.5 for batch. Total $36.00.
  • Large, standard: input 8M × $15.00/M = $120.00, cache write 16M × $18.75/M = $300.00, output 7M × $75.00/M = $525.00, for $945.00 at list price. The negotiated discount takes 20% off output: $525.00 − $105.00 = $420.00. Total $840.00.

The invoice shows usage at list price, $3,720.75, then the “Negotiated discount” line of −$105.00, then “Drawn from prepaid commit” of −$3,615.75. Amount due: $0.00.

Retrieve the commit to see what is left. Its balance.remaining drops from 5000000 to 4638425 ($46,384.25), counted at Initech’s negotiated rate:

GET /v1/commits/cmt_123
{
"id": "cmt_123",
"object": "commit",
"type": "prepaid",
"amount": 5000000,
"currency": "usd",
"period": "term",
"balance": {
"consumed": 361575,
"remaining": 4638425,
"asOf": "2027-02-01T00:00:00Z"
}
}

The response is trimmed to the fields that matter here.