This lesson is an optional deeper look that goes with course F06. It has worked examples with numbers and technical words. Start with F06 if you are new. Go to course F06 →
Money, Tokens and Quotas
You can turn a token table into a monthly cost in kronor, with a separate price for fresh input, cached input, and output, and into euro at a rate you state. You can also turn a per-minute rate limit into the most that limit could cost across a month.
- Level
- First Light
- Time
- 8 h
- Prerequisites
- F06

Jump to
After this course you can
The student can calculate exact monthly token, caching, and rate-limit ceiling costs in SEK from a supplied price table across low, median, and abuse traffic scenarios.
Input tokens and output tokens are priced apart
You are billed for two piles of text on every call. Input is what you send: the question, the instructions, and any attached document. Output is the reply the model writes, plus any hidden reasoning tokens the provider bills as output. On this lesson's example price sheet, fresh input costs 30 kronor per million tokens and output costs 150 kronor per million tokens. Five million output tokens then cost 750 kronor, while the same number of input tokens costs 150 kronor. The sheet is an invented example, so the sums can be checked by hand.
Tokens add up faster than messages. One call that pastes a 20-page report can hold more tokens than fifty short questions. Providers count tokens on their side, and the count is the one that gets billed. If a dashboard shows 2,400,000 input tokens and 400,000 output tokens for a day, the example sheet prices that day at 2.4 times 30 kronor plus 0.4 times 150 kronor, which is 72 kronor plus 60 kronor, 132 kronor. Check that multiplication before you trust a monthly total.
Cached input and batch jobs use lower example rates
When a block of input is repeated, a cache can bill that block at a lower rate. On the example sheet, cached input is 3 kronor per million tokens, against 30 kronor for fresh input. A standing block of 2 million tokens, reused on 80 calls, is 160 million cached tokens if every reuse hits. At 3 kronor per million that is 480 kronor. The same 160 million billed as fresh input would be 4,800 kronor.
A cache hit still costs money. A miss is billed as fresh input. Batch pricing is a lower rate for work you can wait on. On the example sheet, batch fresh input is 15 kronor per million and batch output is 75 kronor per million. Cached input in batch is 1.50 kronor per million. Ten million fresh input tokens and two million output tokens, run as a batch, cost 150 kronor plus 150 kronor, which is 300 kronor.
Read the price sheet as a grid. Live and batch are columns. Fresh input, cached input, and output are rows. Pick the cell that matches the call, then multiply the token count, in millions, by that cell. A live call with a cache hit uses the 3 kronor cell. A batch call that misses the cache uses the 15 kronor cell. Mixing those cells is how a hand estimate drifts away from the invoice.
A flat subscription, an API bill, and a machine at home
A subscription charges a fixed fee for a month and hides a quota behind it. When the quota runs out, new replies stop or slow until the next period. An API bill prices every token, so the month moves with use. Take an example subscription of 250 kronor. A quiet month still costs 250 kronor. The same chats on the example API sheet cost whatever the tokens add up to. Short notes often land under that 250. A desk pasting long files every hour will go over it.
Owning a machine moves the cost from tokens to capital and electricity. Example: a computer bought for 18,000 kronor, spread evenly over 36 months, is 500 kronor a month. If it draws 300 watts for 4 hours a day, that is 0.3 kilowatts times 4 hours times 30 days, which is 36 kilowatt-hours. At an example power price of 2 kronor per kilowatt-hour, electricity is 72 kronor. The month is 572 kronor whether the day is light or heavy, until the machine cannot keep up.
The median case, 40 million fresh, 160 million cached, and 8 million output, comes out at 2,880 kronor on the live sheet. The machine at 572 kronor costs less if the local model is good enough for that desk. The low case, one quarter of those piles, is 720 kronor, close to the machine. The machine still costs about 572 kronor in a month you barely switch it on. Use the API when volume swings, and the machine when a steady job fits on it.
Caps, quotas, and what a rate limit can cost
A spending cap is a kronor limit on an API account. With an example cap of 3,000 kronor, the median desk at 2,880 kronor stays under it. An abuse month at 12,000 kronor stops only when new calls are refused at the cap. A warning does not stop a script. After you save a cap, make one small call and read the account page. The remaining budget should drop by the price of that call. If the budget does not move, the cap is not enforced yet.
An example plan allows 100 messages a day. That daily count is the quota. Message 101 fails even though the monthly fee is already paid. A rate limit example allows 500,000 input tokens and 100,000 output tokens per minute. Fill both for one minute on the live sheet. Input costs 0.5 times 30 kronor, which is 15 kronor. Output costs 0.1 times 150 kronor, which is 15 kronor. The full minute is 30 kronor, the most that limit can bill in sixty seconds.
Hold that 30 kronor minute for a full hour and the hour is 1,800 kronor. A full day is 24 times 1,800, which is 43,200 kronor. A 30-day month at every minute is 30 times 43,200, which is 1,296,000 kronor. At an example 10 kronor per euro, that ceiling is 129,600 euro. The ordinary month at 2,880 kronor is 288 euro. One figure is a ceiling. The other is an ordinary month.
Three months on the example sheet
Live rates on the example sheet: fresh input 30 kronor per million, cached input 3, output 150. The desk waits on answers, so the calls stay on live rates. Median month: 40 million fresh input tokens, 160 million cached input tokens, 8 million output tokens. Fresh input is 40 times 30, so 1,200 kronor. Cached input is 160 times 3, so 480 kronor. Output is 8 times 150, so 1,200 kronor. The sum is 1,200 plus 480 plus 1,200, which is 2,880 kronor.
Check the cache effect on that same month. Input tokens are 40 million plus 160 million, which is 200 million. The cached share is 160 divided by 200, which is 0.8, or 80 percent. If every input token were fresh, input would cost 200 times 30, which is 6,000 kronor, plus output of 1,200 kronor, so 7,200 kronor. The cached bill was 2,880 kronor. The gap is 7,200 minus 2,880, which is 4,320 kronor. That gap stays only while the repeated block keeps hitting.
Now scale the same desk. Fresh input is 10 million times 30, so 300 kronor. Cached input is 40 million times 3, so 120 kronor. Output is 2 million times 150, so 300 kronor. The low total is 300 plus 120 plus 300, which is 720 kronor. Abuse month misses the cache and writes five times the median output: 200 million fresh input and 40 million output. Fresh input is 200 times 30, so 6,000 kronor. Output is 40 times 150, so 6,000 kronor. Abuse total is 12,000 kronor.
Set the three months beside an example cap of 3,000 kronor. Low is 720, median is 2,880, abuse is 12,000. Low and median fit under the cap. Abuse goes over the cap, so the bill stops near 3,000 only if new calls are refused there. At an example 10 kronor per euro, the three months are 72 euro, 288 euro, and 1,200 euro. The rate-limit ceiling calculated above is 1,296,000 kronor, or 129,600 euro. That sits far above the 12,000 kronor abuse month. The ceiling is the meter held open all month.
Price a fourth month by hand
Take a blank page or a plain text file. Use the example sheet: fresh input 30 per million, cached input 3, output 150, and 10 kronor per euro. Price one live month with 25 million fresh input tokens, 75 million cached input tokens, and 5 million output tokens. Write each product on its own line, then add the three lines. Divide the sum by 10 for euro. Subtract the sum from an example cap of 3,000 kronor and write what is left. Check every product by hand.
The three lines should read 750 kronor, 225 kronor, and 750 kronor. The month should read 1,725 kronor. In euro that is 172.50. Against the 3,000 kronor cap, 1,275 kronor of room remains, so the month fits. If your fresh-input line is 75 kronor, you used the cached rate on fresh tokens. If the total is 17,250 kronor, each rate was applied per 100,000 tokens.
Check questions
On the example sheet, what is the live cost of 8 million output tokens?
1,200 kronor. Multiply 8 by the example output rate of 150 kronor per million.
What is the median month total on live rates, with 40 million fresh input, 160 million cached input, and 8 million output?
2,880 kronor. The three lines are 1,200, 480, and 1,200.
If both example rate ceilings stay full every minute for 30 days, what is the ceiling in kronor?
1,296,000 kronor. A full minute is 30 kronor, an hour is 1,800, a day is 43,200, and 30 days multiply to 1,296,000.
A live month has 25 million fresh input tokens, 75 million cached input tokens, and 5 million output tokens on the example sheet. What is the total in kronor?
1,725 kronor. The lines are 750, 225, and 750.
Multiply each pile, in millions of tokens, by the single price cell that matches it, then add the lines. A spending cap limits kronor, a quota limits how many uses you get, and a rate limit limits speed, and the cap holds the bill down only when new calls are refused.
Final task
Solve 15 keyed cost-calculation tasks from frozen price sheets (checked within declared rounding rules) and submit a cost-calculator module (cost_calc.py or .js) that passes 12 fixed unit tests across cached, uncached, and burst workloads.
This lesson is open to read. Tests, diplomas and accounts come later; the waitlist is for those. Join the waitlist