promptdojo_

Read the token bill — what your LLM feature actually costs — step 6 of 9

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 4.6 is $3/1M input, $15/1M output. Fix the code to track the two rates separately and apply the correct rate to each side.

Expected output:

estimated cost: $0.036
The break is on lines 6, 8 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.