Lesson 10 of 30 ~15 min
Course progress
0%

Thinking Token Cost Calculations

Detailní kalkulace nákladů na extended thinking pro různé scénáře.

Extended thinking generuje extra tokeny, které se účtují. Pojďme to spočítat.

Cenová struktura thinking tokens

Opus 4.5 thinking tokens:
- Input: $15 / 1M tokens (standard)
- Thinking: $15 / 1M tokens (jako input)
- Output: $75 / 1M tokens

Pozor: Thinking tokens se účtují jako input cena, ne output!

Kalkulační vzorec

Total Cost = (Input × $15) + (Thinking × $15) + (Output × $75)
             ────────────────────────────────────────────────
                              1,000,000

Praktické příklady

Jednoduchý debugging

Scénář: Debug funkce

Input: 500 tokens (kód + prompt)
Thinking: 2,000 tokens (analýza)
Output: 300 tokens (odpověď)

Cost = (500×$15 + 2000×$15 + 300×$75) / 1M
     = ($7,500 + $30,000 + $22,500) / 1M
     = $0.06

Komplexní architektonická analýza

Scénář: Review celé architektury

Input: 15,000 tokens (codebase context)
Thinking: 25,000 tokens (hluboká analýza)
Output: 3,000 tokens (detailní report)

Cost = (15000×$15 + 25000×$15 + 3000×$75) / 1M
     = ($225,000 + $375,000 + $225,000) / 1M
     = $0.825

Matematický problém

Scénář: Komplexní optimalizace

Input: 800 tokens (problém)
Thinking: 40,000 tokens (mnoho iterací)
Output: 1,500 tokens (řešení + vysvětlení)

Cost = (800×$15 + 40000×$15 + 1500×$75) / 1M
     = ($12,000 + $600,000 + $112,500) / 1M
     = $0.725

Srovnání s/bez thinking

ÚlohaBez thinkingS thinkingRozdíl
Quick Q&A$0.02$0.08
Code review$0.05$0.15
Deep analysis$0.12$0.453.75×
Complex math$0.08$0.72

Budget strategies

Strategy 1: Tiered budgets

def get_thinking_budget(task_complexity):
    budgets = {
        "simple": 2000,
        "medium": 8000,
        "complex": 20000,
        "exhaustive": 50000
    }
    return budgets.get(task_complexity, 8000)

Strategy 2: Cost caps

MAX_COST_PER_REQUEST = 0.50  # $0.50 max

def calculate_max_thinking(input_tokens, expected_output):
    remaining = MAX_COST_PER_REQUEST * 1_000_000
    remaining -= input_tokens * 15  # input cost
    remaining -= expected_output * 75  # output cost
    max_thinking = remaining / 15  # thinking uses input rate
    return max(0, int(max_thinking))

Strategy 3: Dynamic adjustment

# Start s nízkým budgetem, zvyšuj pokud potřeba
response = client.messages.create(
    model="claude-opus-4-5-20250101",
    thinking={"type": "enabled", "budget_tokens": 5000},
    messages=[...]
)

# Pokud odpověď není dostatečná, retry s vyšším
if not is_satisfactory(response):
    response = client.messages.create(
        thinking={"type": "enabled", "budget_tokens": 20000},
        messages=[...]  # stejný prompt
    )

Monthly cost projections

Light usage (50 queries/day)

Bez thinking: 50 × $0.04 × 20 dní = $40/měsíc
S thinking:   50 × $0.15 × 20 dní = $150/měsíc

Heavy usage (200 queries/day)

Bez thinking: 200 × $0.04 × 20 dní = $160/měsíc
S thinking:   200 × $0.15 × 20 dní = $600/měsíc

Klíč je používat thinking selektivně pouze tam, kde to má smysl.