{"by":"dipampaul17","descendants":26,"id":44742710,"kids":[44743048,44743049,44743095,44744000,44745758,44743962,44743606,44743689,44746104],"score":47,"text":"Your AI agent hits an infinite loop and racks up $2000 in API charges overnight. This happens weekly to AI developers.<p>AgentGuard monitors API calls in real-time and automatically kills your process when it hits your budget limit.<p>How it works:<p>Add 2 lines to any AI project:<p><pre><code>  const agentGuard = require(&#x27;agent-guard&#x27;);\n  await agentGuard.init({ limit: 50 }); &#x2F;&#x2F; $50 budget\n\n  &#x2F;&#x2F; Your existing code runs unchanged\n  const response = await openai.chat.completions.create({...});\n  &#x2F;&#x2F; AgentGuard tracks costs automatically\n</code></pre>\nWhen your code hits $50 in API costs, AgentGuard stops execution and shows you exactly what happened.<p>Why I built this:<p>I got tired of seeing &quot;I accidentally spent $500 on OpenAI&quot; posts. Existing tools like tokencost help you <i>measure</i> costs after the fact, but nothing prevents runaway spending in real-time.<p>AgentGuard is essentially a circuit breaker for AI API costs. It&#x27;s saved me from several costly bugs during development.<p>Limitations: Only works with OpenAI and Anthropic APIs currently. Cost calculations are estimates based on documented pricing.<p>Source: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;dipampaul17&#x2F;AgentGuard\">https:&#x2F;&#x2F;github.com&#x2F;dipampaul17&#x2F;AgentGuard</a><p>Install: npm i agent-guard","time":1753941244,"title":"Show HN: AgentGuard – Auto-kill AI agents before they burn through your budget","type":"story","url":"https://github.com/dipampaul17/AgentGuard"}