Inference and Serving, lesson 20
Pricing a single request
Turn tokens, hardware and utilisation into a cost per request.
You know throughput and goodput ("Throughput and Little's law", "Goodput under errors and timeouts"), and how batch size changes tokens per second ("Reading a roofline chart").
Part 1. Tokens in, tokens out, dollars
A hosted API bills tokens, and it bills input and output at different rates. Take example prices: $3 per million input tokens and $15 per million output tokens. Real prices vary by provider and model and change often, so treat these as stand-ins.
One chat request sends 2,000 tokens (system prompt, history, question) and gets back 400.
Your turn
Output costs 5 times as much per token. With 2,000 tokens in and 400 out, which side costs more?
Example 1.1
One request, then a month of them
- 2,000 in×$3 per M=$0.006
Input tokens at the input price.
- 400 out×$15 per M=$0.006
Output tokens at the output price.
- $0.006+$0.006=$0.012
About a cent per request.
- 50,000 a day×30 days×$0.012=$18,000
A month at 50,000 requests a day. Small per-request numbers add up fast.
Output usually costs more because of how it's made. Prefill handles all the input tokens in one parallel pass. Decode makes output one memory-bound step at a time, as in "Reading a roofline chart", so each output token holds the GPU for longer.
Part 2. Self-hosting: dollars per GPU hour
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Self-hosting: dollars per GPU hour
- Batch size sets the price of a token
- Cost per request on your own GPUs
- Hidden multipliers
Inference and Serving overviewSpotted a mistake? Tell us.