Skip to content
echogeco
The tech a PM needs · Models and cost

The token bill

Price the drafting feature's month from requests, tokens and assumed rates, then pick the lever that brings it under a $30,000 budget.

codeeasyExercise · 4 min · 33 of 59
On this page

The drafting feature works, and at the volume it now serves it costs 90% of the revenue it earns. The tokens lesson set out the three lines of a model bill; here the bill is computed by a function, so every figure in the answer is one that ran.

The situation

The same feature across all 12,000 seats and every tenant: 200,000 requests a day, about 17 a seat on average, though usage is skewed and one tenant sends a quarter of it. Each prompt is 1,500 input tokens, 1,100 of them a fixed system prompt that is identical on every call, and the model returns 300 output tokens. Assume $3 per million input tokens, $15 per million output tokens and a 30-day month; the vendor also publishes a cached-input rate that you have not looked up. The eval shows 70% of tickets need a short reply, and their drafts run under 150 tokens when the model is told to be brief; a smaller model exists at a tenth of the price, but its golden-set score is not yet known. A wrong draft the agent catches costs about 20 seconds, at an assumed $30 an hour. The monthly budget for the feature is $30,000, half the $60,000 of add-on revenue in pricing an AI feature.

The question

What does the feature cost a month as specified, does it fit, and if not, which lever do you pull first and what does it save? Write the function that prices one slice of traffic, and use it for every figure.

def solve(daily_requests, in_tokens, out_tokens, price_in, price_out):
    """Monthly cost in USD over 30 days; prices are per million tokens.

    daily_requests: requests a day in this slice of traffic.
    in_tokens, out_tokens: tokens per request, prompt and reply.
    price_in, price_out: USD per million input and per million output tokens.
    Returns the month rounded to the dollar, rounded once, at the end.
    """
solve(200_000, 1500, 300, 3.0, 15.0)   ->  54000
solve(10_000, 4000, 500, 0.5, 2.0)     ->  900
solve(1_000_000, 800, 120, 1.0, 5.0)   ->  42000

A strong answer · Rubric · Where answers go wrong · Solution

Write your answer first, then open