Doubling context doubles the input count, not the total cost. The effect follows the input share of the starting call.
The base call from the first lesson costs 0.030 units. Each row below doubles one side of it.
Case | Input | Output | Total (units) | Against base |
|---|---|---|---|---|
Base | 8000 | 500 | 0.030 | 1.00x |
Double input | 16000 | 500 | 0.054 | 1.80x |
Double output | 8000 | 1000 | 0.036 | 1.20x |
Double both | 16000 | 1000 | 0.060 | 2.00x |
base: 8000 in, 500 out -> 0.024 + 0.006 = 0.030 units
double input: 16000 in -> 0.048 + 0.006 = 0.054 units = 1.80x base
double output: 1000 out -> 0.024 + 0.012 = 0.036 units = 1.20x base
double both: 0.048 + 0.012 = 0.060 units = 2.00x baseInput-heavy calls move with input, and review and summary jobs are input-heavy. Output trims matter most when replies are long.
The split varies by task and model. Measure the real token counts before choosing what to cut.
The program below prices any job from token counts at the EXAMPLE prices. Its five self-checks repeat the hand arithmetic from every lesson.
import sys
PRICE_IN = 3.0
PRICE_OUT = 12.0
PER_M = 1000000.0
def job_cost(in_tokens, out_tokens):
return in_tokens / PER_M * PRICE_IN + out_tokens / PER_M * PRICE_OUT
def close(got, want):
return abs(got - want) < 1e-9
checks = [
(job_cost(8000, 500), 0.030),
(job_cost(12000, 800), 0.0456),
(job_cost(60000, 2000), 0.204),
(30 * job_cost(60000, 2000), 6.12),
(job_cost(16000, 500), 0.054),
]
for i in range(len(checks)):
got, want = checks[i]
if not close(got, want):
print("FAIL: check " + str(i + 1) + " got " + str(got) + " want " + str(want))
sys.exit(1)
print("PASS: calculator agrees with hand arithmetic on 5 checks")It gives 0.036 units, which is 1.20x base. Output starts at 20% of the total, so doubling it adds little.
It proves the code agrees with the hand-worked totals. It leaves open whether the token estimates match any real service.