<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vojtěch</title>
    <description>The latest articles on DEV Community by Vojtěch (@v0it3ch).</description>
    <link>https://dev.to/v0it3ch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4241214%2F61c6d9fb-7cc2-4c24-865e-7418e20413c1.png</url>
      <title>DEV Community: Vojtěch</title>
      <link>https://dev.to/v0it3ch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/v0it3ch"/>
    <language>en</language>
    <item>
      <title>Your AI agent's token bill grows quadratically. Here's the math (and a free calculator)</title>
      <dc:creator>Vojtěch</dc:creator>
      <pubDate>Thu, 12 Nov 2026 13:47:20 +0000</pubDate>
      <link>https://dev.to/v0it3ch/your-ai-agents-token-bill-grows-quadratically-heres-the-math-and-a-free-calculator-dib</link>
      <guid>https://dev.to/v0it3ch/your-ai-agents-token-bill-grows-quadratically-heres-the-math-and-a-free-calculator-dib</guid>
      <description>&lt;p&gt;Most token calculators multiply tokens by price. That works for a single API call. It is wrong for an agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why agent loops get expensive
&lt;/h2&gt;

&lt;p&gt;Each step of an agent loop sends the whole conversation so far: the system prompt, every earlier turn, and every tool result.&lt;/p&gt;

&lt;p&gt;Say your system prompt is 2,000 tokens and each step adds 800 tokens. Then:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Input tokens sent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3,600&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;6,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;10,800&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A 12-step run sends &lt;strong&gt;76,800 input tokens in total&lt;/strong&gt;. The naive estimate of 12 × 2,800 gives 33,600, so the real number is &lt;strong&gt;2.3× higher&lt;/strong&gt;. The total grows with the square of the step count:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;total_input = n * system + adds * n * (n - 1) / 2
            = 12 * 2000 + 800 * 12 * 11 / 2 = 76,800
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Three levers that actually move the bill
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prompt caching.&lt;/strong&gt; The system prompt and the early turns repeat on every step, so cached reads cut most of that cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summarize after N steps.&lt;/strong&gt; Swap old turns for a short summary, which caps context growth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Route by step.&lt;/strong&gt; Use a small model for tool-call formatting and a big one only for planning.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Get your own number in 10 minutes
&lt;/h2&gt;

&lt;p&gt;I built a &lt;strong&gt;free&lt;/strong&gt; spreadsheet for this: cost per query, cost per user and gross margin, with dated, cited list prices for six current models. It works in Excel and Google Sheets.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://sventek7.gumroad.com/l/xdsdxk" rel="noopener noreferrer"&gt;AI API Cost Calculator Lite (free)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need agent loops, caching, sub-agent fan-out and break-even pricing per plan, the full &lt;a href="https://sventek7.gumroad.com/l/ibjhhr" rel="noopener noreferrer"&gt;AI Cost &amp;amp; Margin Model&lt;/a&gt; covers it. Code &lt;code&gt;LAUNCH20&lt;/code&gt; takes 20% off until 18 Nov.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How do you budget for agent runs? Tell me in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>startup</category>
      <category>saas</category>
    </item>
  </channel>
</rss>
