C.W.K.
Stream
Lesson 12 of 12 · published

Token Economics: Why Pricing Is Per Token

~10 min · pricing, economics, inference

Level 0Token
0 XP0/94 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Every major LLM API charges per token, and per-token cost differs between input and output. This is not arbitrary — it directly tracks the compute the provider must spend.

Model (mid-2026 pricing)Input ($/1M)Output ($/1M)
GPT-4o$2.50$10.00
Gemini 2.5 Pro$1.25$10.00
Claude 3.7 Sonnet$3.00$15.00
Gemini 2.5 Flash$0.30$2.50

Why output is 4-10× more expensive than input

Input tokens are processed in parallel during the prefill phase — one big matmul over the entire prompt. Output tokens are produced sequentially, one full forward pass per token through every layer, attending to the entire growing context. Per-token compute is similar; the per-token throughput on shared hardware differs by an order of magnitude. That gap is what the pricing reflects.

Implications for your application: long context is cheaper than long generation. RAG-style "stuff lots of retrieved documents in, generate a short answer" is favorably priced; "stuff a short prompt in, generate a 5,000-token essay" is the expensive shape. When you architect features, understanding this asymmetry shifts which strategies are economic.

Code

Cost estimator — be honest before you build·python
def estimate_cost(prompt_tokens, output_tokens,
                  in_per_1m, out_per_1m):
    return prompt_tokens / 1_000_000 * in_per_1m \
         + output_tokens / 1_000_000 * out_per_1m

# Pricing (USD / 1M tokens) — update with current sheet
PRICES = {
    "gpt-4o":             (2.50, 10.00),
    "claude-3.7-sonnet":  (3.00, 15.00),
    "gemini-2.5-flash":   (0.30,  2.50),
}

# Daily budget for 100k requests, average 800-token prompt + 400-token answer
for model, (in_p, out_p) in PRICES.items():
    daily = 100_000 * estimate_cost(800, 400, in_p, out_p)
    print(f"{model:>22}  ${daily:>9,.2f}/day")

External links

Exercise

Take one feature in your codebase that calls an LLM. Log 100 real requests with their (prompt, completion) token counts. Compute the actual per-request cost in three different models (one frontier, one mid-tier, one cheap). Where does the bigger model win on quality vs. cost? Is the win worth it?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.