告诉 HN:我把 Claude API 的费用从每月 70 美元降到了几美分

13作者: ok_orco21 天前
第一次运行 Chatter.Plus(我正在构建的一个聚合来自 Discord/GitHub/论坛的社区反馈的工具)一天后,我拉取了使用成本,结果是 2.30 美元。算了一下,每月 70 美元,每年 840 美元。这还只是一次实例。感觉糟透了。 之前我做过草稿计算,所以知道这可能是一个 bug,但即便如此。事实证明,这只是部分是 bug。剩下的原因是我需要重新思考我构建这个东西的方式。 接下来的几天,我一直在拆解它。进行调整,用实时数据测试,检查结果,然后重试。我发现我发送 API 请求的频率太高,而且没有优化我发送和接收的内容。 以下是能显著降低成本的几个关键点,大致按重要性从大到小排列(除了那个每天让我损失 1 美元的 bug): * 完全放弃了 Claude Sonnet 模型 - 在相同的数据上测试了两个模型,Haiku 实际上表现更好,而且成本只有 Sonnet 的三分之一 * 开始批量处理所有内容 - 每小时调用一次简直是烧钱 * 在 AI 之前进行过滤 - “哈哈”和“谢谢”是很多在线闲聊。我却在花钱让 AI 告诉我那不是反馈。不过,我仍然会处理像“+1”和“我也一样”这样的赞同。 * 更短的输出 - 用“H/M/L”代替“高/中/低”,推荐 40 个字符的标题 * 在处理之前删除代码片段 - 只是重复问题并膨胀调用 到周末:每天几美分。质量却保持不变。 我不是在构建一个可以亏损多年、有风投支持的应用程序。我失业了,试图构建一些可能也能支付房租的东西。从第一天起,这个账就得算得过来。 好处是:这些节省让我能够将定价层级的限制提高 3 倍,并添加间歇性的质量检查。这让我有了额外的空间,否则我根本无法做到。 很乐意回答问题。
查看原文
The first time I pulled usage costs after running Chatter.Plus - a tool I&#x27;m building that aggregates community feedback from Discord&#x2F;GitHub&#x2F;forums - for a day hours, I saw $2.30. Did the math. $70&#x2F;month. $840&#x2F;year. For one instance. Felt sick.<p>I&#x27;d done napkin math beforehand, so I knew it was probably a bug, but still. Turns out it was only partially a bug. The rest was me needing to rethink how I built this thing. Spent the next couple days ripping it apart. Making tweaks, testing with live data, checking results, trying again. What I found was I was sending API requests too often and not optimizing what I was sending and receiving.<p>Here&#x27;s what moved the needle, roughly big to small (besides that bug that was costin me a buck a day alone):<p>- Dropped Claude Sonnet entirely - tested both models on the same data, Haiku actually performed better at a third of the cost<p>- Started batching everything - hourly calls were a money fire<p>- Filter before the AI - &quot;lol&quot; and &quot;thanks&quot; are a lot of online chatter. I was paying AI to tell me that&#x27;s not feedback. That said, I still process agreements like &quot;+1&quot; and &quot;me too.&quot;<p>- Shorter outputs - &quot;H&#x2F;M&#x2F;L&quot; instead of &quot;high&#x2F;medium&#x2F;low&quot;, 40-char title recommendation<p>- Strip code snippets before processing - just reiterating the issue and bloating the call<p>End of the week: pennies a day. Same quality.<p>I&#x27;m not building a VC-backed app that can run at a loss for years. I&#x27;m unemployed, trying to build something that might also pay rent. The math has to work from day one.<p>The upside: these savings let me 3x my pricing tier limits and add intermittent quality checks. Headroom I wouldn&#x27;t have had otherwise.<p>Happy to answer questions.