<?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: Varad Khoriya</title>
    <description>The latest articles on DEV Community by Varad Khoriya (@vrd1710).</description>
    <link>https://dev.to/vrd1710</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3951978%2Feb6602c7-026f-44d9-9d3d-8d2124b9b675.jpg</url>
      <title>DEV Community: Varad Khoriya</title>
      <link>https://dev.to/vrd1710</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vrd1710"/>
    <language>en</language>
    <item>
      <title>I got a $100 AI bill. Then I found the $80,000 ones. So I built a kill switch.(2026)</title>
      <dc:creator>Varad Khoriya</dc:creator>
      <pubDate>Tue, 26 May 2026 13:47:37 +0000</pubDate>
      <link>https://dev.to/vrd1710/i-got-a-100-ai-bill-then-i-found-the-80000-ones-so-i-built-a-kill-switch2026-4b7e</link>
      <guid>https://dev.to/vrd1710/i-got-a-100-ai-bill-then-i-found-the-80000-ones-so-i-built-a-kill-switch2026-4b7e</guid>
      <description>&lt;p&gt;A few weeks ago I woke up to a $100 charge from my AI provider.&lt;/p&gt;

&lt;p&gt;For a lot of people that's nothing. For me, a solo dev who obsessively keeps infrastructure costs near zero, it genuinely stung. But that wasn't even the part that got me.&lt;/p&gt;

&lt;p&gt;The part that got me was what I found when I went looking for answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Actual Problem
&lt;/h2&gt;

&lt;p&gt;Reddit threads. Developer forums. People waking up to $10,000. $30,000. $80,000 bills.&lt;/p&gt;

&lt;p&gt;Three root causes, over and over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leaked API keys&lt;/strong&gt; scraped from public GitHub repos&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autonomous agents&lt;/strong&gt; stuck in retry loops, burning tokens all night&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider "budget alerts"&lt;/strong&gt; that notify you after the money is already gone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one is what really broke my brain. The alerts are just dashboards with email attachments. They don't stop anything. You still get the bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Thing I Built
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://www.tryloopers.com/" rel="noopener noreferrer"&gt;Loopers&lt;/a&gt;- a reverse proxy that sits between your application and your LLM provider and enforces a hard dollar cap.&lt;/p&gt;

&lt;p&gt;Not a soft alert. &lt;strong&gt;A kill switch.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Your app talks to Loopers instead of OpenAI directly
curl http://localhost:8080/openai/v1/chat/completions \
  -H "Authorization: Bearer lp-your-key" \
  -H "X-Loopers-Provider-Key: sk-your-openai-key" \
  -d '{"model": "gpt-4o-mini", "messages": [...]}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your budget is hit, the request dies right there. The provider is never called. No tokens burned. No bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Interesting Engineering Bit
&lt;/h2&gt;

&lt;p&gt;The hard part isn't blocking pre-call requests. That's easy. The hard part is streaming.&lt;/p&gt;

&lt;p&gt;With SSE streaming, the provider is already sending you tokens by the time you realize cost is climbing. So Loopers intercepts the stream in real-time, counts tokens chunk-by-chunk, and severs the connection the moment cost crosses the reservation.&lt;/p&gt;

&lt;p&gt;And when a client disconnects mid-generation (dropped connection, timeout, whatever), Loopers captures the exact token count generated up to that millisecond and refunds the remainder of the reservation back to Redis. No phantom charges.&lt;/p&gt;

&lt;p&gt;The budget enforcement itself runs through Redis Lua scripts- single atomic transaction, no TOCTOU race conditions, even under heavy concurrent load.&lt;/p&gt;

&lt;h2&gt;
  
  
  What It Supports
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;6 providers:&lt;/strong&gt; OpenAI, Anthropic, Gemini, AWS Bedrock, Azure OpenAI, Mistral&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5 budget windows:&lt;/strong&gt; per-minute, hourly, daily, weekly, monthly - first limit hit wins&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session budgets:&lt;/strong&gt; cap an entire agent run across N steps&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail-closed:&lt;/strong&gt; if Redis goes down, all requests are blocked. Your wallet is safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MIT-licensed&lt;/strong&gt;, self-hosted, Docker Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'm Still Figuring Out
&lt;/h2&gt;

&lt;p&gt;The concurrent Lua atomicity holds up in tests (100 goroutines, same key), but I'd genuinely love a second pair of eyes on the scripts from anyone who's done serious Redis work.&lt;/p&gt;

&lt;p&gt;And the streaming reconciliation pattern, I'm curious if others have solved mid-stream token accounting differently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It / Rip It Apart
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run github.com/loopers-oss/loopers/cmd/loopers init
docker-compose up -d

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;a href="//github.com/CURSED-ME/loopers-oss"&gt;github.com/CURSED-ME/loopers-oss&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is my first major Go project. I'd love brutal, honest feedback on the architecture, the code, the README clarity, anything. Drop it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The core is fully MIT. I'm building a managed cloud version to fund continued OSS work but nothing is held back from the community repo.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>opensource</category>
      <category>ai</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
