lesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costs
This estimator uses ONE rate for both input and output tokens. But output is 5× the price of input on most Anthropic models — so this code under-estimates the real bill by ~60% on a typical chat workload.
Real numbers: Claude Sonnet 5 is $2/1M input, $10/1M output. Fix the code to track the two rates separately and apply the correct rate to each side.
Expected output:
estimated cost: $0.024
The break is on lines 6, 8 — but read the whole snippet first.