# The Cost of Running AI in Production by [kirupa](https://www.kirupa.com/me/index.htm) | filed under [Economics & Finance](https://www.kirupa.com/economics_and_finance/index.htm) **TL;DR:** Every time a customer uses an AI feature, we pay for it, so those serving costs belong in cost of goods sold. Count the whole stack: model calls, retries, safety checks, search, and human review. Then forecast from what drives usage, and pull levers like caching, routing, and shorter answers to protect the margin. - The starter coach's model fee was 3 cents a question, but every bill added up came to 4.33 cents, and a person reviewing flagged chats was the second-biggest piece. - The costs of delivering the product, like every request's model calls and each member's hosting, are cost of goods sold. Building costs, like an engineer's time and a coding agent's tokens, are research and development. - Caching the repeated prompt, routing easy questions to a small model, shorter answers, batching, and better flagging cut a question from 4.33 to 1.26 cents. - Forecast from the drivers, questions per user times cost per question, with a range, and budget for the busiest month. Our spreadsheet says the Bake-Along's starter coach costs about **3 cents** a question. That's what the model's pricing page works out to, and it leaves our $10 membership with a healthy **82%** gross margin. Then the bills for last month arrived (from the model provider, the search service, and Tess's timesheet), and when Kofi added them all up, the coach had cost us a lot more than 3 cents a question. Every AI feature has two numbers like this. One is the price on the model's pricing page. The other is what a question really costs once everything around the model is counted. In this article, we are going to find that second number, use it to forecast next year, and pull the levers that protect our margin. Onwards! ## A Meter Beside the Till Here is the Bake-Along as it looks from Kofi's desk: [![On the left, a cash register showing $10: a member pays the Bake-Along once a month. On the right, a meter like a taxi's, ticking up 3 cents at a time: every starter coach question costs us money, all month long.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_meter.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_meter.png?v=6936d5ae7795) A member pays us $10 once a month. Every question they ask the starter coach runs a little meter, and that meter keeps running all month long. Most software didn't have a meter at all. Once it was built, serving one more customer cost almost nothing. AI features are different. They run the meter on every single use, so every question becomes part of what it costs us to deliver what we sell. ## Where Did the Extra Money Go? Our spreadsheet expected 3,300 questions for every 100 members, at 3 cents each. Here is that number next to what we actually paid: [![Two bars for one month of the starter coach, per 100 members. Kofi's spreadsheet: 3,300 questions at 3 cents is $99. What it actually cost once every bill came in: $143.00, or about 4.33¢ a question.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_invoice.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_invoice.png?v=d26d038a9f57) Our members asked 3,300 questions for every 100 of them, right on plan. So where did the extra $44 come from? It came from everything else that happens when a member asks a question. Once we add up every bill, each question cost us **4.33 cents**, and every 100 members cost us **$143** instead of $99. Here is everything one question costs us: [![A stacked bar of what one starter coach question costs, 4.33¢ in all: model answer 3.00¢, retries 0.15¢, safety check 0.10¢, recipe search 0.05¢, quality checks 0.20¢, tess's reviews 0.83¢. The model's answer is the biggest piece, and Tess's reviews are the second biggest.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_stack.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_stack.png?v=cfe819723d95) The model's answer is still the biggest piece, at 3 cents. Second place surprised everybody. One chat in every 100 gets flagged (a member asking whether the pink streaks in their starter are safe, for example), and Tess spends about 2 minutes reading it. Here is how that turns into a cost per question: [![Four steps from left to right. 1 in 100 starter coach chats gets flagged for a person to read. Tess spends about 2 minutes on each one, which at $25 an hour is $0.83 a review. Spread across every question, that is 0.83¢ per question.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_tess.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_tess.png?v=ff233f08b3f2) Tess's reviews add **0.83 cents** to every question we answer. That's more than the retries, the safety check, the recipe search, and the nightly quality checks put together! This is a trap that a lot of us fall into. The price on a model's pricing page is only where a question's cost starts. ## Is This Really a Cost of Goods? Every cost in that stack shows up again each time a member asks a question, and the card fees and video hosting show up again every month for every member. The costs of making and delivering what we sell are called **cost of goods sold** (aka **COGS**). They are different from the money we spend building and improving the coach: [![Two buckets. Cost of goods sold, the costs of delivering the coach to members: model answers and retries, safety checks and search, Tess's reviews, and card fees and hosting. Research and development, the costs of building and improving the coach: Wren's time, the coding agent's tokens, and prompt experiments.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_buckets.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_buckets.png?v=ba3e6341a0c7) Wren's time and the coding agent's tokens built the coach, and they'd be the same whether our members asked ten questions or ten thousand. That's research and development, which counts as an operating expense. The model answering a member's question is COGS. It's the same kind of AI, sometimes the very same model, and it lands in two different places on our P&L. This matters because gross margin is what's left of our revenue after COGS, as a share of that revenue, so any serving cost we sweep into research and development makes our margin look better than it really is. (How a company classifies its costs is up to its accountants and the accounting rules it follows, and none of this is accounting advice.) ## What Does a Member Really Cost? With the full 4.33 cents, we can redo our per-member math. Each member costs us $0.80 a month before asking a single question (card fees and video hosting), plus whatever their questions cost. Here is each kind of member, first counting only the model's fee and then counting every cost: [![Grouped bars of gross margin for each kind of member, counting only the 3-cent model fee and then counting every cost behind a question. Light member (10 questions): 89% on the model fee, 88% with every cost; Average member (33 questions): 82% on the model fee, 78% with every cost; Regular member (100 questions): 62% on the model fee, 49% with every cost; Heavy member (200 questions): 32% on the model fee, 5% with every cost.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_members.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_members.png?v=518e491bb99e) Our average member asks 33 questions a month and costs us **$2.23**, which makes our margin 78%. We thought it was 82%. Is that a big deal? For the average member, not really. Even with Wren's 200-question monthly allowance, a heavy member costs us $9.47 a month, and our margin on them drops from 32% to just **5%**. Those 5 heavy members out of every 100 ask 1,000 of our 3,300 questions, which is almost a third of the bill. ## Pulling the Margin Levers Wren listed every lever that could make a question cheaper, and we're going to pull them one at a time. Each one gets tested against the coach's quality checks before it's turned on, because a cheap answer that's wrong is the most expensive kind. To see where the savings will come from, we first need to look at what the model reads and writes for a single question: [![Two bars of tokens. What the model reads: 6,000 tokens, made of coach instructions (1,500), starter guide (2,500), recipe snippets (1,000), the question and photo (1,000). The first two, 4,000 tokens, are the same for every question. What the model writes: an answer of 800 tokens.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_tokens.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_tokens.png?v=b5c3bf61b856) Two-thirds of what the model reads (the coach's instructions and the starter guide) is the same for every question. Providers can hold on to a repeated chunk like that for a few minutes and charge much less to read it again, which is called [prompt caching](https://www.kirupa.com/ai_fundamentals/prompt_caching.htm). Anthropic, for example, [charges a tenth of the normal input price](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for cached tokens, or even less on some newer models. (Writing to the cache costs a little extra now and then, 1.25 times the normal input price for Anthropic's five-minute cache, so our numbers assume a warm cache, which is what we get when questions come in steadily.) Here is what happened as Wren pulled the levers, one at a time: [![A waterfall of the cost of one starter coach question. Today: 4.33¢. Cache the repeated prompt: down to 3.20¢. Small model, easy questions: down to 2.06¢. Shorter answers: down to 1.86¢. Batch the quality checks: down to 1.76¢. Flag fewer chats for Tess: down to 1.26¢. Altogether, the cost falls from 4.33¢ to 1.26¢.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_levers.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_levers.png?v=39992cb3ab83) Caching the repeated prompt saved the most. Next, Wren sent easy questions ("How warm should my kitchen be?") to a small model, which now handles 60% of them for a fraction of the price (a practice known as [routing easy tasks to cheaper models](https://www.kirupa.com/ai_fundamentals/routing_to_cheaper_models.htm)). Shorter answers trimmed each reply from 800 tokens to 500. The nightly quality checks moved to a batch service, which both [OpenAI](https://developers.openai.com/api/docs/guides/batch) and [Anthropic](https://platform.claude.com/docs/en/about-claude/pricing) offer at 50% off for work that can wait. Last of all, better flagging means Tess reads 1 chat in 250 instead of 1 in 100. Altogether, a question now costs **1.26 cents**. Here is what that does to our margins: [![Grouped bars of gross margin for each kind of member, counting every cost, before and after the five levers. Light member: 88% before, 91% after; Average member: 78% before, 88% after; Regular member: 49% before, 79% after; Heavy member: 5% before, 67% after.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_margins.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_margins.png?v=a1246f85bbe5) Our average member is back up to **88%**, and our heavy member went from 5% to **67%**. Look at what's left in a question's cost, though. With the model this cheap, Tess's reviews are now about a quarter of every question, so our next savings will come from people and process more than from tokens. And for members who still cost too much, the last lever is the price itself, which is what [Pricing and Packaging](https://www.kirupa.com/economics_and_finance/pricing_and_packaging.htm) is all about. ## How Do We Forecast Next Year? Kofi now needs a budget for next year. What's the worst way to forecast an AI bill? It's taking this month's invoice and multiplying it by twelve. A better way is to rebuild our bill from the things that drive it: [![A tree. The coach's cost per member each month is questions per member multiplied by cost per question. Cost per question is the model's answer plus everything else. The model's answer comes from tokens read and written multiplied by the price per token. Everything else is retries, the safety check, recipe search, quality checks, and Tess's reviews.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_drivers.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_drivers.png?v=12be2719cbc8) Each box is something we can look up or argue about. Questions per member change with the seasons, with new features (photo questions use a lot more tokens), and with how many heavy members we have. Cost per question changes when we pull levers and when providers change their prices. Because every box is per member, our forecast works no matter how many members we end up with. Here is Kofi's forecast of the coach's cost per member for each month of next year: [![A forecast of the starter coach's cost per member for each month of next year, at 1.26¢ a question, with a shaded band for 30% fewer or 30% more questions. The base line starts at $0.62 in January, dips to $0.29 in June and July, and peaks at $0.66 in December, with the high case at $0.86.](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_forecast.png)](https://www.kirupa.com/economics_and_finance/images/ai_cost_of_goods_forecast.png?v=f259f8803816) January is busy with New Year's bakers, summer is quiet, and December is the busiest month of all. The shaded band shows what happens if members ask 30% fewer or 30% more questions than we expect, and Kofi budgets for the top of the band. Even in a busy December at the top of our band, the coach will cost us about **86 cents** per member. At the old 4.33 cents a question, that same December would have cost us $2.97. There is one more thing to plan for. Model prices keep falling, and Guido Appenzeller of Andreessen Horowitz [estimated in 2024](https://a16z.com/llmflation-llm-inference-cost/) that the price for the same ability drops about 10x every year. Cheaper answers tend to bring more questions, longer answers, and new features, though (the [Jevons paradox](https://www.kirupa.com/economics_and_finance/jevons_paradox.htm) in action), so a smart forecast tracks the drivers instead of hoping the price alone will save us. ## Try the Token Bill Calculator Below is a Token Bill Calculator, set up with our starter coach's numbers before any of the levers: Interactive example: [Token Bill Calculator](https://www.kirupa.com/economics_and_finance/examples/token_bill_calculator.htm) **Try it:** 1. Set **Repeated tokens cached** to 4,000 2. Move **Easy questions on a small model** to 60% 3. Drag **Questions per member, a month** to 200 With the first two levers, a question drops to about 2.06 cents, which matches the third row of our waterfall. Push the questions per member all the way up to 200, and the cost per member climbs fast. That's our heavy member again, and it's why the heaviest users are the first place to look whenever the bill jumps. ## Try It This Week Build a per-user cost model for one AI feature you run: 1. List every bill a single request touches: model calls, retries, safety checks, search, logging, and human review. 2. Divide last month's total for each one by last month's requests to get your real cost per request. 3. Multiply that by the requests a light, typical, and heavy user makes, and add your fixed per-user costs. 4. Compare each one with what that user pays, and find your heaviest user's margin. 5. Pick the biggest piece of the stack, and pull one lever on it. ## Frequently Asked Questions **Is AI Inference a Cost of Goods Sold?** Usually, yes. The model calls, safety checks, search, and human reviews behind every use of an AI feature are part of delivering what you sell, so they belong in cost of goods sold. The money spent building and improving the feature, like engineering time and a coding agent’s tokens, is research and development. Your accountants and accounting rules have the final say. **How Do You Calculate the Cost per User of an AI Feature?** Add up every bill a request touches for a month, not only the model provider’s, and divide by the number of requests to get a real cost per request. Multiply that by how many requests a light, typical, and heavy user makes, then add your fixed per-user costs like card fees and hosting. Compare each one with what that user pays. **How Do You Forecast AI Inference Costs?** Rebuild the bill from its drivers instead of multiplying last month’s invoice by twelve. Forecast questions per user, including seasons, new features, and heavy users, and multiply by the cost per question you expect after any levers or price changes. Put a range around it and budget for the top of it. **How Do You Lower AI Inference Costs Without Hurting Quality?** Start with the biggest piece of the cost stack. Cache prompts that repeat, route easy requests to a smaller model, keep answers as short as they need to be, and batch work that can wait. Test each change against your quality checks before turning it on, and use pricing limits for the heaviest users. ## Conclusion Phew! We started with a starter coach that was supposed to cost 3 cents a question and actually cost 4.33. That gap is what happens when we count every cost around the model: retries, safety checks, search, quality checks, and a person reading the tricky chats. All of it comes with every question we answer, so it's all cost of goods sold, and our real margin was 78% instead of 82%. Then we pulled five levers (caching, routing, shorter answers, batching, and better flagging) and brought a question down to 1.26 cents. Last of all, we built next year's forecast from the drivers instead of from last month's invoice. None of this makes the meter go away. As long as members ask questions, the meter beside the till keeps running...and that's a good thing, because a running meter means people are using what we built. Our job is to know exactly what each tick costs. Before you go, here are a few things you can do: 1. Test your knowledge by taking the quiz below. 2. Read the next article in the series, [Capital Allocation](https://www.kirupa.com/economics_and_finance/capital_allocation.htm), or check out some related content: - [Pricing and Packaging](https://www.kirupa.com/economics_and_finance/pricing_and_packaging.htm). Charge for the value you deliver, and fence off the expensive features. - [Time Value of Money](https://www.kirupa.com/economics_and_finance/time_value_of_money.htm). Why a lifetime deal on an AI feature can lose money on its heaviest users. - [Cost per Query and Cost per User](https://www.kirupa.com/ai_fundamentals/cost_per_query_and_user.htm). The per-query math behind every number in an AI bill. 3. Stuck on something, or curious about a detail we skipped? [Ask on the forums](https://forum.kirupa.com/), and we’ll help you out. ## Test your knowledge! [Take the The Cost of Running AI in Production Quiz](https://www.kirupa.com/quizzes/ai_cost_of_goods.htm). Practice with 6 multiple-choice questions and an explanation after every answer.