AI for product managers Running it

Lesson 8 of 9

Cost, speed, and quality.

What one AI answer really costs, what makes customers wait, how to trade the two against quality with evals, and the gateway teams put between their apps and their models.

By Nagesh Koritala, product manager October 2026

  • About 16 minutes
  • 7 parts
  • 6 quick questions
  • A worksheet
A triangle with three corners: quality, is the answer right; cost, what each conversation costs; and speed, how long the shopper waits. In the middle, your evals decide. A note: set the quality floor first, then find the cheapest, fastest setup that still clears it. Qualityis the answer right? Costper conversation Speedhow long they wait Your evalsdecide set the quality floor, then find the cheapest, fastest setup that clears it

Before you start

The made-up furniture store’s shopping assistant has been live for a month. Finance forwards you the first model bill: about three times what your team estimated, though shopper numbers matched the plan. Before you read on: where do you think the extra cost came from? Write it in one sentence.

It stays on this device only. You’ll see it again at the end.

In this lesson, you’ll learn to

  • Explain what one AI answer costs, and why input and output tokens are priced differently
  • Estimate the cost of one conversation for an agent that makes several model calls
  • Choose between the main levers for lowering cost, and know the catch in each
  • Tell time to first token apart from total time, and design for the wait customers feel
  • Use evals to decide the trade-off between cost, speed, and quality
  • Explain what an AI gateway does, why teams add one, and what to ask about it

Key terms

Input tokens
Everything the model reads for one call: instructions, tool descriptions, the conversation so far, added facts, and tool results.
Output tokens
The tokens the model writes in reply. Usually priced higher per token than input.
Prompt caching
A provider feature that stores the start of a prompt so later calls that begin with exactly the same text are processed faster and billed at a lower rate.
Batch processing
Sending many non-urgent requests together, to be processed later instead of right away, usually at a discount. At Anthropic, most batches finish within an hour, and any request not done within 24 hours expires.
Latency
The time between sending a prompt and receiving the model’s output.
Time to first token (TTFT)
The time from sending the prompt until the model produces the first token of its answer.
AI gateway
A layer between your apps and the models they call, where access, routing, limits, caching, logs, and spending are managed in one place.

The idea

When a feature is new, nobody looks at the bill. Then it works, usage grows, and someone in finance asks what one conversation costs. It’s a hard question to answer if nobody planned for it. Or the answers are great, but shoppers leave before the first word appears.

This lesson gives you the numbers to have that conversation early. You’ll see where the cost of an answer comes from, which waits customers feel, and how to trade cost and speed against quality without guessing. Then you’ll meet the AI gateway. It’s not glamorous work. It’s often what decides whether a good AI feature can stay live.

The lesson, in seven parts

  1. What one answer really costs.

    Lesson 1 said every word in front of the model, and every word it writes, has a price. Providers usually bill per token, and they bill input and output separately. Input is everything the model reads. Output is what it writes.

    Output usually costs more per token. At the time of writing (October 2026), Anthropic’s pricing page lists output at five times the input price for each of its models. Other providers set their own rates.

    Here’s what surprises many people new to agents. An agent doesn’t make one call per question. As lesson 2 showed, it works in a loop, and each turn is a separate model call. Anthropic’s Messages API is stateless: every call sends the full conversation again. So the model re-reads its instructions, its tool descriptions, and everything so far, every time. And Anthropic’s pricing page notes that tool descriptions and the results tools return all count as input tokens.

    One shopper question becomes three model calls. Each call starts with the same instructions and tool descriptions, then a growing part that is new: the question, then the results of the size check and the delivery date check. The first two calls ask for a check; the third writes the answer. Made-up totals: 10,400 tokens in and 500 out, and most of the input is the same instructions, read three times. One shopper question, three model calls Call 1 Same instructions 100 out asks for size checkCall 2 Same instructions 100 out asks for date checkCall 3 Same instructions 300 out writes the answer same every call new this call tokens written made up: 10,400 tokens in, 500 out, mostly the same instructions
    One shopper question becomes three model calls, and each one re-reads the same instructions. All numbers are made up.

    Anthropic engineers Erik Schluntz and Barry Zhang put it plainly: “Agentic systems often trade latency and cost for better task performance.” That’s not a reason to avoid agents. It’s a reason to know what each question costs before launch. Subagents (lesson 4) multiply this again, since each runs its own loop.

  2. Estimate the cost of one conversation.

    You don’t need an engineer for a first estimate. You need four numbers: calls per question, tokens in and out on each call, questions per conversation, and your provider’s current prices. Later, your engineers can pull real token counts from the logs (lesson 7). Here’s the method, with made-up numbers.

    A shopper asks the made-up furniture store’s assistant: “Will the Harbor sofa fit through a 30-inch door, and can it arrive by Saturday?” The instructions and tool descriptions come to 2,900 tokens. To keep the math simple, use made-up prices in “credits”: 1 credit per 1,000 input tokens and 5 credits per 1,000 output tokens.

    CallWhat the model doesInput tokensOutput tokens
    1Reads the question, asks for the doorway-size check3,000 (2,900 instructions + the question)100
    2Reads the size result, asks for the delivery date check3,500 (call 1 again + its request + the result)100
    3Reads the delivery result, writes the answer3,900 (call 2 again + its request + the result)300
    TotalOne question10,400 = 10.4 credits500 = 2.5 credits

    Made-up example. The store, token counts, and credit prices are invented. Swap in your provider’s current prices and your own token counts.

    • One question costs about 12.9 credits. A team that estimated one call per question (instructions, question, and answer) would have guessed about 4.5, a third of the real cost.
    • Input is about four-fifths of the bill, though each output token costs five times as much. Most of it is the same 2,900 tokens of instructions, read three times.
    • With three questions per conversation, each re-reading the ones before, a conversation costs a bit over 40 credits. Multiply by monthly conversations for a budget line finance can check.
  3. Prompt caching: stop paying full price to re-read the same instructions.

    Look at that table again. The model read the same 2,900 tokens three times, at full price. Prompt caching is built for exactly this. The provider stores the start of your prompt, and later calls that begin with exactly the same text read it from the cache, faster and cheaper.

    The discount depends on the provider and the model, so a rule of thumb like “a cache hit costs about 10%” is too loose to plan with. At the time of writing (October 2026):

    ProviderReading from the cacheWriting to the cacheWorth knowing
    Anthropic0.1 times the normal input price on most models; 0.05 or 0.025 times on some of its newest1.25 times the input price for a 5-minute cache; 2 times for a 1-hour cacheThe cache lasts 5 minutes by default and refreshes each time it’s used. A 5-minute cache pays for itself after one read.
    OpenAIDepends on the model; OpenAI says cached input is discounted by up to 95%No extra charge on older models; 1.25 times the input price on its newestCaching is on by default for supported models.

    Ratios from each provider’s pricing and caching pages, October 2026. They change, so check the current pages before you plan.

    Back to the made-up store, with Anthropic’s standard ratios. On a busy day the cache stays warm, so all three calls read the 2,900 instructions at a tenth of the price. Input drops from 10.4 credits to about 2.6, and the question costs about 5.1 credits instead of 12.9. (Made-up numbers; a real system also pays for cache writes now and then.)

    • Order matters. A hit needs the start of the prompt to be exactly the same, so what never changes (instructions, tool descriptions) goes first and the question goes last. Even a timestamp in the cached part means no hits.
    • There’s a minimum. Each provider only caches a prompt start of at least a set length, and it differs by model: at the time of writing (October 2026), anywhere from 512 to 4,096 tokens at Anthropic. Below it, nothing is cached and no error tells you. Check the number for your model.
    • It doesn’t change the answer. Anthropic says the response is identical to what you’d get without caching.
    • It can make answers start sooner: Anthropic says you’ll generally see improved time to first token for long documents.
  4. Four more levers, and what each one costs you.

    Caching is often the easiest saving. Here are the other main levers. Each has a catch, and the catch is usually quality or speed, which is why the next parts matter.

    LeverWhat it meansAt the made-up storeThe catch
    Choose the model per stepSend simple steps to a smaller, cheaper, faster modelA small model picks which check to run; a larger one writes the answerThe small model may pick wrong. Test each step with evals
    Batch non-urgent workSend many requests together and collect results later. Anthropic’s Batch API costs 50% less; most batches finish within an hour, and anything unfinished after 24 hours expiresRewriting 5,000 product descriptions overnightNever for a shopper who’s waiting
    Shorter prompts and answersCut instructions nobody needs; ask for concise answersAnswer in three sentences, not tenCut too much and quality drops. Rerun your evals
    Fewer stepsSkip tools a question doesn’t need, and stop the loop when the job is doneAnswer “What colors does the Harbor come in?” without the delivery checkSkipping a needed check makes answers wrong

    Made-up examples. Batch figures from Anthropic’s batch processing page, October 2026.

    A close cousin appears in Anthropic’s guide to agents as routing: Schluntz and Zhang describe sending easy, common questions to smaller, cost-efficient models and hard or unusual ones to more capable models. Choosing a model per step applies the same thinking inside one question. Your question as a product manager: which steps are simple enough for a cheaper model, and how will we know?

  5. Speed: the wait customers actually feel.

    Speed has more than one number. Anthropic’s glossary and its guide to reducing latency define the two you’ll hear most. Latency is the time from sending a prompt to getting the output. Time to first token (TTFT) is the time until the first piece of the answer appears.

    Streaming connects them to the customer. Without it, the shopper sees nothing until the whole answer is done. With it, the answer appears word by word. Anthropic says this can significantly improve perceived responsiveness. Note the word perceived. Streaming doesn’t shorten the total time; it makes the wait feel shorter.

    Two timelines for the same answer, with made-up seconds. Without streaming, the shopper sees nothing for six seconds, then the whole answer appears at once. With streaming, the checks run for about three and a half seconds while a status line says checking delivery dates, then the words appear one after another until about six seconds. The wait for the first word includes the checks. The total time is about the same. Without streaming shopper sees nothing whole answerat once With streaming “Checking delivery dates…” wordsappear wait for the first word total time: about the same 0s2s4s6s made up
    Streaming shows words sooner. The total time is about the same. Seconds are made up.
    • In an agent, tool calls happen before the answer starts, so the shopper’s wait for the first word includes every check, not just the model’s time to first token on the final call. A short progress line, like “Checking delivery dates…”, shows something is happening.
    • Longer answers take longer to finish. Anthropic’s first suggestions for speed are choosing the right model and keeping prompts and outputs short.
    • Set targets in customer terms (first words within, full answer within), and measure both after launch (lesson 7).
  6. The three-way trade-off, decided with evals.

    Cost, speed, and quality pull against each other. A bigger model is often better and slower. A shorter prompt is cheaper and may drop a rule. Teams get into trouble when opinion settles it: “the big model feels smarter”, or “finance wants it cheaper”.

    Settle it with evals instead (lesson 5). Anthropic’s latency guide gives a sensible order: “It’s always better to first engineer a prompt that works well without model or prompt constraints, and then try latency reduction strategies afterward.” Here’s one way to work:

    • Set the quality floor: the eval results that must pass. At the made-up store, every measurement and delivery date is correct and sourced.
    • Set budgets: a cost per conversation, and a wait in customer terms.
    • Get a version that clears the floor, ignoring cost and speed for now.
    • Change one lever at a time, and rerun the same evals after each change.
    • Pick the cheapest, fastest version that still clears the floor. Write down why.

    Here’s how that might look at the made-up store, on a set of 200 real shopper questions:

    VersionEval resultCost per questionFirst words appear
    A: large model for every stepPasses the floor12.9 creditsAbout 4 seconds
    B: A plus prompt cachingPasses (caching doesn’t change how it answers)About 5.1 creditsA little sooner
    C: small model for every stepFails: wrong doorway math on 14 questionsMuch lowerAbout 2 seconds
    D: small model picks the checks, large model answers, with cachingPasses the floorLower than BAbout 3 seconds

    Made-up example. Every number and result is invented to show the method.

    Version C is the trap: cheapest, fastest, and wrong about whether a sofa fits. Version D wins, but only because the evals proved it held the line. Rerun the comparison when your provider releases a new model or changes prices. The best answer moves.

  7. The AI gateway: one control point for every model call.

    Picture the store a year from now. The shopping assistant, a product copy tool, and a support summary tool all call models, sometimes from two providers. Each team keeps its own keys, retry code, and cost tracking. Nobody can say what the company spends on AI this month.

    An AI gateway puts one layer between your apps and the models, so every request passes through one place. Microsoft’s Azure Architecture Center describes it as a general pattern that takes complexity away from each app and adds authentication, rate limiting, monitoring across models, routing, failover to healthy models, and caching. Gateway products differ, but the jobs are similar.

    Three apps on the left: the shopping assistant, a product copy tool, and support summaries. All of them call one AI gateway in the middle, which sends each request on to one of three models on the right: a large model, a small model, or a backup provider. Below the gateway, its jobs: keys and access, routing and fallback, rate limits, caching, logs and costs, and spend limits. A note: one place to see and change how every app uses models. Shopping assistantProduct copy toolSupport summaries Large modelSmall modelBackup provider AIgateway Keys and accessRouting, fallbackRate limitsCachingLogs and costsSpend limits one place to see and change how every app uses models
    Every app calls the gateway, and the gateway decides which model gets the request. Apps and models are made up.

    Here are the jobs, and why each one matters to you:

    JobWhat it doesWhy a product manager cares
    Keys and accessApps sign in to the gateway; provider keys stay in one placeKeys aren’t copied into every app, and you know which app made each call
    Routing and fallbackSends each request to the right model, or to a backup when one is downThe assistant keeps answering in an outage, if the backup passed your evals
    Rate limitsCaps requests or tokens per app per minuteOne busy tool can’t starve the shopping assistant
    CachingCan return a stored answer to a repeated or similar questionFast and cheap, but possibly out of date
    Logs and costsRecords requests, responses, tokens, and cost, by appReal cost per conversation, and data for lesson 7
    Spend limitsUsage caps per app or team per hour, day, or monthA looping bug hits a cap, not your budget

    Generic jobs; what you get depends on what your team builds or buys. Don’t confuse the gateway’s response cache, which can skip the model and return an earlier answer (fine for “What’s your return policy?”, risky for “Is the Harbor in stock?”), with prompt caching (part 3), which still runs the model.

    Ask

    • Does every model call from our apps go through the gateway?
    • If our main model is down, what does the assistant use, and has that backup passed our evals?
    • What are the rate and spend limits for each app, and who’s alerted when one is hit?
    • Which answers may come from a response cache, and how stale can they be?
    • What does the gateway store, for how long, and who can read it?

    Avoid

    • “Let’s cache everything.” (A cached stock or delivery answer can be wrong by the time a shopper reads it.)
    • “Fallback to any model is fine.” (A model your evals never tested is an untested product.)
    • “We’ll add limits after launch.” (A looping agent can run up a large bill before anyone looks.)

    A gateway has costs too. Microsoft’s guide warns it can become a single point of failure, sees raw requests and responses (so privacy rules cover it), and adds running costs, and it says not to add one if it puts your service targets at risk. Weigh those against the control it gives you. Lesson 9 puts it together with every other part.

With AI: Use an AI assistant to check your arithmetic, not to supply your prices. Give it your token counts and your provider’s current rates, ask it to show each step, then check the steps yourself. Never trust a price an assistant remembers. Prices change often, and the source is your provider’s current pricing page.

Check your understanding

Answer each one in your head or on paper first. Then open the answer to check.

1Why does one shopper question often cost far more than its question and answer suggest?

An agent makes several model calls per question, and each call re-reads the instructions, tool descriptions, conversation, and tool results, all billed as input.

2Output costs five times as much as input in the worked example. Why was input still most of the bill?

Far more input tokens were read: the same 2,900 tokens of instructions on every call, plus the growing conversation, against 500 output tokens.

3What does prompt caching change, and what doesn’t it change?

It makes re-reading the same start of a prompt cheaper and often faster. The model still runs and writes the same answer it would have.

4Why is “a cache hit costs about 10%” too loose to plan with?

The discount varies by provider and model, and some providers charge extra to write to the cache. Anthropic charges 0.1 times the input price on most models and less on some newer ones; OpenAI says up to 95% off, depending on the model.

5Streaming is on, and the full answer still takes six seconds. What did streaming improve?

The wait the shopper feels: words appear sooner. The total time is about the same.

6Name three jobs an AI gateway does, and one risk it adds.

Any three of: keys and access, routing and fallback, rate limits, caching, logs and costs, spend limits. Risks include a single point of failure, access to raw data, and running costs.

Practice: estimate a feature’s cost and set its budgets

The made-up furniture store wants a room-planner helper: a shopper describes a room, and the assistant suggests three pieces that fit. Using the worksheet below:

  1. List the model calls one request needs, with input and output tokens for each.
  2. Work out the cost per request in made-up credits (1 per 1,000 input tokens, 5 per 1,000 output).
  3. Name two levers you’d try first, and the catch in each.
  4. Set a quality floor and a wait target in customer terms.
Show a model answer

Calls: (1) read the room description and pick a search, 3,000 in and 100 out; (2) read 20 matching products and choose three, 5,100 in and 150 out; (3) check the fit with the room planner and answer, 5,600 in and 300 out. Total: 13,700 in (13.7 credits) and 550 out (2.75 credits), about 16.5 credits per request. Levers: prompt caching for the instructions (they must come first and stay identical); a smaller model for picking the search (rerun evals to check it picks well). Quality floor: on 150 real room descriptions, every suggested piece fits and is in stock. Wait: a progress line within a second, first words within about four seconds. (Made-up example: all numbers invented.)

Back to where you started

The short answer

Every AI answer has a price and a wait, and both grow with the tokens the model reads and writes and the number of calls it makes. So you estimate cost per conversation, not per call, lower it with a few levers, and use evals to check that quality held. Many teams run all of this through an AI gateway, one control point between their apps and their models.

Go back to your sentence. If you wrote that the team counted one call per question, or forgot that the model re-reads its instructions and tool results every time, you found the most common cause. Now you can estimate a conversation step by step, cut the bill with the right levers, and use evals to prove quality held.

Common mistakes

New product managers on AI features often:

  • Estimate cost per call, forgetting that an agent makes several calls per question.
  • Ignore input tokens because output costs more per token.
  • Quote one caching discount for every provider and model.
  • Treat streaming as a way to make answers finish sooner.
  • Ship without spend limits, and find out about a looping agent from the bill.

Try this today

Three small exercises, with any AI assistant or any AI feature you work on:

  1. Open your provider’s pricing page. Write down the input price, output price, and any caching and batch discounts, with today’s date.
  2. Ask your engineers for the calls and token counts in one real conversation, and turn them into a cost per conversation.
  3. Time an assistant you use: how long until the first words, and until the answer is done?

Worksheet: cost, speed, and quality plan

COST, SPEED, AND QUALITY PLAN

Feature:
Provider and model(s):
Prices checked on (date), from (page):
  Input:        Output:        Cache read/write:        Batch:

One request, call by call:
  Call 1:  does:            In:        Out:
  Call 2:  does:            In:        Out:
  Call 3:  does:            In:        Out:

Cost per request:
Requests per conversation:
Cost per conversation:
Monthly cost (estimate):

Quality floor (evals that must pass):
Wait targets: first words within ___ / full answer within ___

Levers, one at a time (rerun evals after each):
  [ ] Prompt caching   [ ] Smaller model for simple steps
  [ ] Batch            [ ] Shorter prompt/answers   [ ] Fewer steps

Gateway: spend limit ___  alert goes to ___  backup model (passed evals?) ___

Compare estimate with real costs on (date):

Questions people ask

Why do output tokens cost more than input tokens?

Providers set their own prices, and many charge more for output than for input. At the time of writing (October 2026), Anthropic lists output at five times the input price for each of its models. Check your provider’s current pricing page.

How do I estimate the cost of an AI feature?

Count the model calls one request makes and the input and output tokens on each (including instructions, tool descriptions, and tool results). Multiply by your provider’s current prices, then by requests per conversation and expected conversations. After launch, compare with real costs from your logs.

What is prompt caching?

A provider feature that stores the start of a prompt, such as your instructions, so later calls that begin with exactly the same text are faster and cheaper. The discount varies by provider and model, and it doesn’t change the answer.

What is time to first token (TTFT)?

The time from sending a prompt until the model produces the first token of its answer. With streaming, it’s roughly how long a customer waits before words appear, which matters most in chat.

What is an AI gateway?

A layer between your apps and the AI models they call, so access, routing and fallback, rate limits, caching, logs, and spending are managed in one place. It also adds a component that can fail, sees raw data, and costs money to run.

Sources and further reading

All lessons

Keep going

Up next:
the agent harness.

You’ve met the model, the loop, tools, subagents, evals, guardrails, observability, and now cost and speed. Last, see how the harness holds them together into one product you can run.

Got a question this lesson didn’t answer? Email me. I read every note.

A large sheet labeled the harness. In its center, the model, in red. Around it, eight parts, each with the lesson that covers it: the loop and the planner (lesson 2), tools (lesson 3), memory and state (lesson 9), context management (lessons 1 and 9), guardrails (lesson 6), evals (lesson 5), and observability (lesson 7). A note: same model, different harness, different product. The harness everything around the model The looplesson 2The plannerlesson 2Toolslesson 3Memoryand statelesson 9Contextmanagementlessons 1 and 9Guardrailslesson 6Evalslesson 5Observabilitylesson 7 The modelfrom a provider same model, different harness, different product